Jump to content

[HELP] save vehicle in file


Seba500PLK

Recommended Posts

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) 
  

Link to comment

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

Link to comment

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> 

Link to comment
float float float getElementRotation ( element theElement [, string rotOrder = "default" ] ) 
local rx, ry, rz = getElementRotation(col, theVehicle) 

How, can you give up the element at the second argument, if it has to be placed at the first argument? Just remove 'theVehicle'...

Link to comment

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...