Wysłany: 2014-05-25, 13:44
Zgredek666
LUA
Wiek: 27 Na forum: 4722 dni Posty: 251
Nick w MP: Zgredek
Piwa : 442
Tak ma wygl?da? kod:
xml = xmlLoadFile ( "pojazdy.xml" )
if not xml then return end
child = xmlFindChild ( xml , "auto" , 0 )
childd = xmlFindChild ( childd , "pojazd" , 0 )
opis = "test"
success = xmlNodeSetAttribute ( childd , "opis" , opis )
if success then
outputDebugString ( "doda?o" )
xmlSaveFile ( xml )
end
Wysłany: 2014-05-25, 13:53
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
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 )
Wysłany: 2014-05-25, 13:54
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
daj zmienn? "success" tylko przy ostatnim xmlNodeSetAttribute. Wszystkie wy?ej pousuwaj zmienne.
Wysłany: 2014-05-25, 14:02
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
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?
Wysłany: 2014-05-25, 14:06
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
No to m?w, ?e z hp itp
zamiast vehicle daj source
Wysłany: 2014-05-25, 14:17
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
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.
Wysłany: 2014-05-25, 16:15
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Chcesz aby tylko po wyj?ciu w?a?ciciela zapisywa?o si??
Wysłany: 2014-05-25, 17:12
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
a zapomnia?em o tym
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
Wysłany: 2014-05-26, 20:40
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
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
Wysłany: 2014-05-27, 15:54
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
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)
Wysłany: 2014-05-27, 16:13
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
zmieni?by? mi ten kod bo ja si? z xml nie lubi? bawi?
za pomoc piffko
Wysłany: 2014-05-27, 16:18
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
no to powiedz mi jak ma wygl?da? xmlNodeGetAttribute, a zrobi? sobie sam...
Wysłany: 2014-05-27, 16:35
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Kod: for k,v in ipairs ( xmlNodeGetChildren ( xml )) do
Wysłany: 2014-05-27, 19:29
maxerxxl
Wiek: 30 Na forum: 5067 dni Posty: 285
Nick w MP: MaXI
Piwa : 38
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.
Wysłany: 2014-05-27, 19:45
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Bo nie wystarczy doda? linijk? no kurde, pokombinuj sam, nie b?d? wszystkiego za Ciebie robi?..
Tagi: ustawianie :: attributa :: xml
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: