Jump to content

[HELP] save vehicle in file


Seba500PLK

Recommended Posts

Posted

Hello, saves the file when I got this error:

[2014-08-25 17:10:07] WARNING: [skrypty]/Zapis/zapis.lua:19: Bad argument @ 'getElementRotation' [Expected rotation-order at argument 2, got player]  

<Pojazd> 
    <Pojazd rotX="false" rotY="nil" rotZ="nil"></Pojazd> 
</Pojazd> 

function save(theVehicle) 
  
for i, col in ipairs(getElementsByType("vehicle")) do 
  
    local time = getRealTime() 
    local sec = time.second 
    local minu = time.minute 
    local h = time.hour 
    local day = time.monthday 
    local month = time.month + 1 
    local year = time.year + 1900 
local rx, ry, rz = getElementRotation(col, theVehicle) 
  
Node = xmlLoadFile("Pojazdy/[" .. year .. "-" .. month .. "-" .. day .. "_" .. h .. "-" .. minu .. "].xml") 
    if Node then 
        local child = xmlCreateChild(Node,"Pojazd") 
  
        xmlNodeSetAttribute(child,"rotX",tostring(rx)) 
        xmlNodeSetAttribute(child,"rotY",tostring(ry)) 
        xmlNodeSetAttribute(child,"rotZ",tostring(rz)) 
        xmlSaveFile(Node) 
        xmlUnloadFile(Node) 
        --outputChatBox("Saved 1") 
    else 
        Node = xmlCreateFile("Pojazdy/[" .. year .. "-" .. month .. "-" .. day .. "_" .. h .. "-" .. minu .. "].xml","Pojazd") 
        local child = xmlCreateChild(Node,"Pojazd") 
  
        xmlNodeSetAttribute(child,"rotX",tostring(rx)) 
        xmlNodeSetAttribute(child,"rotY",tostring(ry)) 
        xmlNodeSetAttribute(child,"rotZ",tostring(rz)) 
        xmlSaveFile(Node) 
        xmlUnloadFile(Node) 
        --outputChatBox("Saved 2") 
    end 
end 
end 
addCommandHandler("save",save) 
  

Posted

If the insertion is: local rx, ry, rz = getElementRotation(theVehicle)

  
  
    <Pojazd rotX="0" rotY="0" rotZ="119.59625244141"></Pojazd> 
    <Pojazd rotX="0" rotY="0" rotZ="119.59625244141"></Pojazd> 
    <Pojazd rotX="0" rotY="0" rotZ="119.59625244141"></Pojazd> 
    <Pojazd rotX="0" rotY="0" rotZ="119.59625244141"></Pojazd> 
  
  

Rotation is the same for all vehicle

Posted

What??

if I give the positions of the vehicle it works

local x, y, z = getElementPosition(col, theVehicle)

    <Pojazd posX="-92.9951171875" posY="2823.0908203125" posZ="76.721649169922" rotX="false" rotY="nil" rotZ="nil"></Pojazd> 
    <Pojazd posX="-2448.99609375" posY="-1335.8662109375" posZ="310.97662353516" rotX="false" rotY="nil" rotZ="nil"></Pojazd> 
    <Pojazd posX="-173.2470703125" posY="-2635.5341796875" posZ="26.608192443848" rotX="false" rotY="nil" rotZ="nil"></Pojazd> 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...