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, 13:44


Zgredek666

LUA






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

Piwa: 442

Respekt: 70,1

Tak ma wygl?da? kod:



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


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, 13:53


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
PanMaszyna na jednym xmlNodeSetAttribute dzia?a?o ale jak doda?em kilka xmlNodeSetAttribute to b??dy bad argumenty.

Kod:

function exitVehicle ( thePlayer, vehicle)
local x,y,z=getElementPosition(vehicle)
local r1,r2,r3=getElementRotation(vehicle)
local hp=getElementHealth(vehicle)
local opis=getElementData(vehicle,"opis")
local c1,c1,c3 = getVehicleColor(vehicle,true)

outputChatBox ( "Zapisywanie pojazdu!", thePlayer )
outputChatBox ( "Pojazd zosta? zapisany poprawnie!", thePlayer )

xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auto", 0 )
child2 = xmlFindChild ( child, "pojazd", 0 )
success = xmlNodeSetAttribute ( child2, "x", x )
success = xmlNodeSetAttribute ( child2, "y", y )
success = xmlNodeSetAttribute ( child2, "z", z )
success = xmlNodeSetAttribute ( child2, "c1", c1 )
success = xmlNodeSetAttribute ( child2, "c2", c2 )
success = xmlNodeSetAttribute ( child2, "c3", c3 )
success = xmlNodeSetAttribute ( child2, "r1", r1 )
success = xmlNodeSetAttribute ( child2, "r2", r2 )
success = xmlNodeSetAttribute ( child2, "r3", r3 )
success = xmlNodeSetAttribute ( child2, "opis", opis )
success = xmlNodeSetAttribute ( child2, "health", hp )
if success then
xmlSaveFile ( xml )
end
end
addEventHandler ( "onVehicleStartExit", getRootElement(), exitVehicle )


Postaw piwo autorowi tego posta
 

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


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

daj zmienn? "success" tylko przy ostatnim xmlNodeSetAttribute. Wszystkie wy?ej pousuwaj zmienne.

Podpis

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

 
Wysłany: 2014-05-25, 14:02


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
to samo, bad argumenty i bad argumenty z getElementData, i z hp.

Kod:

function exitVehicle ( thePlayer, vehicle)
local x,y,z=getElementPosition(vehicle)
local r1,r2,r3=getElementRotation(vehicle)
local hp=getElementHealth(vehicle)
local opis=getElementData(vehicle,"opis")
local c1,c1,c3 = getVehicleColor(vehicle,true)

outputChatBox ( "Zapisywanie pojazdu!", thePlayer )
outputChatBox ( "Pojazd zosta? zapisany poprawnie!", thePlayer )

xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auto", 0 )
child2 = xmlFindChild ( child, "pojazd", 0 )
xmlNodeSetAttribute ( child2, "x", x )
xmlNodeSetAttribute ( child2, "y", y )
xmlNodeSetAttribute ( child2, "z", z )
xmlNodeSetAttribute ( child2, "c1", c1 )
xmlNodeSetAttribute ( child2, "c2", c2 )
xmlNodeSetAttribute ( child2, "c3", c3 )
xmlNodeSetAttribute ( child2, "r1", r1 )
xmlNodeSetAttribute ( child2, "r2", r2 )
xmlNodeSetAttribute ( child2, "r3", r3 )
xmlNodeSetAttribute ( child2, "opis", opis )
success = xmlNodeSetAttribute ( child2, "health", hp )
if success then
xmlSaveFile ( xml )
end
end
addEventHandler ( "onVehicleStartExit", getRootElement(), exitVehicle )


czy nie powinna by? funkcja vehicle = GetPlayerOccupiedVehicle?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 14:06


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

No to m?w, ?e z hp itp
zamiast vehicle daj source

Podpis

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

 
Wysłany: 2014-05-25, 14:17


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
dzia?a, thx piwko

temat do zamkni?cia.

[ Dodano: 2014-05-25, 15:57 ]
jeszcze jedna rzecz bo skrypt si? gubi, jak ja wyjd? z pojazdu i potem gracz to m?j pojazd leci do pojazdu drugiego gracza a drugiego gracza pojazd nie zmienia si? w og?le.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-25, 16:15


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Chcesz aby tylko po wyj?ciu w?a?ciciela zapisywa?o si??

Podpis

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

 
Wysłany: 2014-05-25, 17:12


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
a zapomnia?em o tym ;P
ale nie chodzi mi o to, chodzi mi o to ?e si? gubi? pojazdy, ja wyjd? z pojazdu potem gracz ze swojego pojazdu i m?j pojazd leci tam gdzie by? gracza pojazd.

[ Dodano: 2014-05-26, 14:57 ]
refresh

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-26, 20:40


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Musisz mie? dane "co?" dla pojazdu np ID.


za???my, ?e pojazd ma date nadan? jako "id" wi?c :


w xml id = ""

pod p?tla xmlNodeGetChildren robisz


if getElementData ( element_pojazdu, "id" ) == xmlNodeGetAttribute ( v, "id" ) then
--kod

Podpis

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

 
Wysłany: 2014-05-27, 15:54


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
Ja nie mam xmlNodeGetChildren, to gdzie mam to da??
Kod:

addEventHandler ( "onVehicleStartExit", getResourceRootElement(getThisResource()), function()
local x,y,z=getElementPosition(source)
local r1,r2,r3=getElementRotation(source)
local hp=getElementHealth(source)
local opis=getElementData(source,"opis")
local tuning=getVehicleUpgrades ( source )

xml = xmlLoadFile ( "dane/pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml, "auto", 0 )
child2 = xmlFindChild ( child, "pojazd", 0 )
xmlNodeSetAttribute ( child2, "x", x )
xmlNodeSetAttribute ( child2, "y", y )
xmlNodeSetAttribute ( child2, "z", z )
xmlNodeSetAttribute ( child2, "r1", r1 )
xmlNodeSetAttribute ( child2, "r2", r2 )
xmlNodeSetAttribute ( child2, "r3", r3 )
xmlNodeSetAttribute ( child2, "tuning", tuning )
xmlNodeSetAttribute ( child2, "opis", opis )
success = xmlNodeSetAttribute ( child2, "zycie", hp )
if success then
xmlSaveFile ( xml )
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-27, 16:13


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
zmieni?by? mi ten kod bo ja si? z xml nie lubi? bawi? :D
za pomoc piffko

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-27, 16:18


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
no to powiedz mi jak ma wygl?da? xmlNodeGetAttribute, a zrobi? sobie sam...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-27, 16:35


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Kod:

for k,v in ipairs ( xmlNodeGetChildren ( xml )) do


Podpis

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

 
Wysłany: 2014-05-27, 19:29


maxerxxl







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

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
teraz bad argumenty z:
xmlNodeSetAttribute
xmlFindChild

Kod:

addEventHandler ( "onVehicleStartExit", getResourceRootElement(getThisResource()), function()
local x,y,z=getElementPosition(source)
local r1,r2,r3=getElementRotation(source)
local hp=getElementHealth(source)
local opis=getElementData(source,"opis")
local tuning=getVehicleUpgrades ( source )

xml = xmlLoadFile ( "dane/pojazdy.xml" )
if not xml then return end
for k,v in ipairs ( xmlNodeGetChildren ( xml )) do
if getElementData ( source, "id" ) == xmlNodeGetAttribute ( v, "id" ) then
child = xmlFindChild ( xml, "auto", 0 )
child2 = xmlFindChild ( child, "pojazd", 0 )
xmlNodeSetAttribute ( child2, "x", x )
xmlNodeSetAttribute ( child2, "y", y )
xmlNodeSetAttribute ( child2, "z", z )
xmlNodeSetAttribute ( child2, "r1", r1 )
xmlNodeSetAttribute ( child2, "r2", r2 )
xmlNodeSetAttribute ( child2, "r3", r3 )
xmlNodeSetAttribute ( child2, "tuning", tuning )
xmlNodeSetAttribute ( child2, "opis", opis )
success = xmlNodeSetAttribute ( child2, "zycie", hp )
if success then
xmlSaveFile ( xml )
end
end
end
end)


i nie zapisuje pojazdu.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-05-27, 19:45


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Bo nie wystarczy doda? linijk? no kurde, pokombinuj sam, nie b?d? wszystkiego za Ciebie robi?..

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
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 » Ustawianie attributa w xml 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