Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2014-05-25, 10:58


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
Witam, czy by?bym kto? taki dobry i zrobi? mi funkcj? xml kt?ra szuka przedrostka "pojazd" i w nim ustawia dany element np struktur? opis="" zamienia na opis="test", by?bym wdzi?czny, m?j kod kt?ry posiadam w xml:
Kod:

<pojazdy>
<auto>
<pojazd id="1" model="411" x="34.28" y="1205.01" z="19.03" c1="3" c2="1" c3="0" r1="" r2="" r3="" opis="" health="1000" wlasciciel="maxerxxl"></pojazd>
</auto>
</pojazdy>


chcia?bym ?eby wyszukiwa?o <pojazd ..... </pojazd>

Pozdrawiam, za pomoc lec? browarki cieplutkie!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:24


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

zeby doda?o ci linjke potrzebujesz xmlFindChild, do atrybut?w wstawiasz xmlNodeSetAttribute ( zmienna_findchild, "nazwa", warto?? )

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:25


Zgredek666

LUA






Wiek: 27
Na forum: 4722 dni
Posty: 251
Nick w MP: Zgredek

Piwa: 442

Respekt: 70,1

Zeby to wykonac uzyj funkcji xmlload i xmlfindchild

Podpis
Piszę skrypty lua na serwery Truck/RPG/Race/DayZ. Kontakt pw!

Pomogłem? Wystarczy jak postawisz :piwo:



Zapraszam na mój kanał na yt:
https://www.youtube.com/c...vgsF65M-Xw5hEDQ
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:29


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Sko?cz? rund? i CI PMOG?.

[ Dodano: 2014-05-25, 11:34 ]
przyk?ad :


Kod:

addCommandHandler ( "dodaj", function( plr )
xml = xmlLoadFile ( "plik.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auta", 0 )
id = getElementModel ( plr )
xmlNodeSetAttribute ( child, "pojazd", tonumber(id) )
end)



Ustawia dla "pojazd" tw?j obecny skin.


XML :


Kod:

<cos>
<auta>
</auta>
</cos>


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:42


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
Dobra, ale mam problem z zmian? bo bad argument, m?g?by? mi doda?
?eby zmienia?o <pojazd opis=""></pojazd> opis na np test.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:43


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Kod:

DANY_OPIS = "test"


xmlNodeSetAttribute ( child, "pojazd", DANY_OPIS )



Takie zmienne przydaj? si? je?li kod ma du?o linijek :)

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:46


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
nie dzia?a, bad argument z xmlNodeSetAttribute
Kod:

xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auta", 0 )
opis = "kupa"
xmlNodeSetAttribute ( child, "opis", opis )


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 11:51


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Co? ?le robisz :)
U mnie dzia?a :

Kod:

<cos>
<auta opis="test"></auta>
</cos>


[ Dodano: 2014-05-25, 11:52 ]
Spr?buj :

Kod:

addCommandHandler ( "dodajxd", function()
xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auta", 0 )
nowe = xmlCreateChild ( child, "pojazd" )
opis = "test"
success = xmlNodeSetAttribute ( nowe, "opis", opis )
if success then
outputDebugString ( "doda?o" )
xmlSaveFile ( xml )
end
end)


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:19


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
dzi?ki, dzia?a doda?o si? do xml,
da?by? mi kod kt?ry edytuje wybran? formu?k? ? bo domy?lnie teraz to dodaje si? nowa struktura "<pojazd opis="test"></pojazd>"
a chcia?bym ?eby do wybranej struktury si? zmienia?o.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:20


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Nie rozumiem Ci?. Jakiej struktury ?

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:24


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
Wyt?umacz? ci.
Tw?j kod co poda?e? dodaje childa nowego, a ja chce aby w childzie kt?ry teraz istnieje zmieni? formu?k? opis....

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:25


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

ta sama zasada, tylko, ?e bez xmlCreateChild.

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:32


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
jak to usun??em to formu?ka opis dodaje si? do <auto> (<auto opis="">) a powinna do <pojazd opis=""></pojazd>

M?j plik:
Kod:

xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auto", 0 )
opis = "test"
success = xmlNodeSetAttribute ( child, "opis", opis )
if success then
outputDebugString ( "doda?o" )
xmlSaveFile ( xml )
end


xml
Kod:

<pojazdy>
<auto opis="">
<pojazd id="1" model="411" x="34.28" y="1205.01" z="19.03" c1="3" c2="1" c3="0" r1="" r2="" r3="" opis="" health="1000" wlasciciel="maxerxxl"></pojazd>
</auto>
</pojazdy>


co wida? w code ?e doda?o mi si? opis nie do tego childa: <auto opis="">
powinno do <pojazd.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:33


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Kod:


xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auto", 0 )
child2 = xmlFindChild ( child, "pojazd", 0 )
opis = "test"
success = xmlNodeSetAttribute ( child2, "opis", opis )
if success then
outputDebugString ( "doda?o" )
xmlSaveFile ( xml )
end


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 13:38


Zgredek666

LUA






Wiek: 27
Na forum: 4722 dni
Posty: 251
Nick w MP: Zgredek

Piwa: 442

Respekt: 70,1

Musisz doda? co? takiego:

childd xmlFindChild xml"pojazd")


i jeszcze:

success xmlNodeSetAttribute childd"opis"opis )


Dzieje ci si? tak poniewa? masz :
child xmlFindChild xml"auto"


i
success xmlNodeSetAttribute child"opis"opis 


Podpis
Piszę skrypty lua na serwery Truck/RPG/Race/DayZ. Kontakt pw!

Pomogłem? Wystarczy jak postawisz :piwo:



Zapraszam na mój kanał na yt:
https://www.youtube.com/c...vgsF65M-Xw5hEDQ
Postaw piwo autorowi tego posta
 

 
Tagi: ustawianie :: attributa :: xml
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku