addCommandHandler ( "zapisz", function ( plr )
local accName = getAccountName ( getPlayerAccount ( plr ) )
if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
return outputChatBox ( "Nie posiadasz praw Administratora", plr, 255, 0, 0 ) end
xml = xmlLoadFile ( "xml.xml" )
for _,v in ipairs ( xmlNodeGetChildren ( xml ) ) do
xmlDestroyNode ( v )
end
xmlSaveFile ( xml )
for _,v in ipairs ( getElementsByType ( "vehicle" ) ) do
model = getElementModel ( v )
x,y,z = getElementPosition ( v )
c1,c2,c3,c4,c5,c6 = getVehicleColor ( v )
r1,r2,r3 = getVehicleRotation ( v )
child = xmlCreateChild ( xml, "pojazd" )
id = tonumber ( getElementData ( v, "id" ) )
owner = getElementData ( v, "owner" )
if not tonumber ( getElementData ( v, "id" ) ) then
id = tonumber ( math.random ( 1, 1000 ) ) end
if not owner then
owner = "Publiczne" end
xmlNodeSetAttribute ( child, "model", tonumber(model) )
xmlNodeSetAttribute ( child, "x", tonumber(x) )
xmlNodeSetAttribute ( child, "y", tonumber(y) )
xmlNodeSetAttribute ( child, "z", tonumber(z) )
xmlNodeSetAttribute ( child, "color1", tonumber(c1) )
xmlNodeSetAttribute ( child, "color2", tonumber(c2) )
xmlNodeSetAttribute ( child, "color3", tonumber(c3) )
xmlNodeSetAttribute ( child, "color4", tonumber(c4) )
xmlNodeSetAttribute ( child, "color5", tonumber(c5) )
xmlNodeSetAttribute ( child, "color6", tonumber(c6) )
xmlNodeSetAttribute ( child, "rotation1", tonumber(r1) )
xmlNodeSetAttribute ( child, "rotation2", tonumber(r2) )
xmlNodeSetAttribute ( child, "rotation3", tonumber(r3) )
xmlNodeSetAttribute ( child, "owner", owner )
xmlNodeSetAttribute ( child, "id", tonumber(id) )
end
xmlSaveFile ( xml )
if xml then
outputChatBox ( "Pojazdy zapisane", plr )
xmlUnloadFile ( xml )
end
end)
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), function ()
xml = xmlLoadFile ( "xml.xml" )
for _,v in ipairs ( xmlNodeGetChildren ( xml ) ) do
model = tonumber ( xmlNodeGetAttribute ( v, "model" ) )
id = tonumber ( xmlNodeGetAttribute ( v, "id" ) )
owner = xmlNodeGetAttribute ( v, "owner" )
x,y,z = tonumber ( xmlNodeGetAttribute ( v, "x" ) ), tonumber ( xmlNodeGetAttribute ( v, "y" ) ), tonumber ( xmlNodeGetAttribute ( v, "z" ) )
c1, c2, c3 = tonumber ( xmlNodeGetAttribute ( v, "color1" ) ), tonumber ( xmlNodeGetAttribute ( v, "color2" ) ), tonumber ( xmlNodeGetAttribute ( v, "color3" ) )
c4, c5, c6 = tonumber ( xmlNodeGetAttribute ( v, "color4" ) ), tonumber ( xmlNodeGetAttribute ( v, "color5" ) ), tonumber ( xmlNodeGetAttribute ( v, "color6" ) )
r1, r2, r3 = tonumber ( xmlNodeGetAttribute ( v, "rotation1" ) ), tonumber ( xmlNodeGetAttribute ( v, "rotation2" ) ), tonumber ( xmlNodeGetAttribute ( v, "rotation3" ) )
auto = createVehicle ( model, x,y,z, r1, r2, r3 )
setVehicleColor ( auto, c1, c2, c3, c4, c5, c6 )
setElementData ( auto, "owner", owner )
setElementData ( auto, "id", id )
end
end)
addEventHandler ( "onVehicleStartEnter", root, function ( gracz, miejsce, kierowca )
if kierowca then
name = getPlayerName ( kierowca )
return outputChatBox ( "*"..name.." ju? prowadzi ten pojazd!", gracz, 255, 255, 255 ) end
if miejsce ~= 0 then return end
if getElementData ( source, "owner" ) == "Publiczne" then
return outputChatBox ( "Pami?taj, ?e prowadzenie publicznego pojazdu jest nielegalne!", plr, 255, 255, 255 ) end
if getElementData ( source, "owner" ) ~= getPlayerName ( gracz ) then
outputChatBox ( "* Ten pojazd nale?y do "..getElementData ( source, "owner" ).."!", gracz, 255, 255, 255 )
return cancelEvent() end
end)