Seba500PLK Posted August 25, 2014 Posted August 25, 2014 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)
Bonsai Posted August 25, 2014 Posted August 25, 2014 I would say, you should hit the wiki to check how a command Handler works + which arguments getElementRotation needs.
Seba500PLK Posted August 25, 2014 Author Posted August 25, 2014 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
Bonsai Posted August 25, 2014 Posted August 25, 2014 What is theVehicle anyway? Its the player who used the command, if you use a command Handler.
Seba500PLK Posted August 25, 2014 Author Posted August 25, 2014 This is a script to save all the vehicles on the map, using the command
Bonsai Posted August 25, 2014 Posted August 25, 2014 Hmmm. function abc(playerWhoUsedTheCommand, CommandName, arguments...) end addCommandHandler("abc", abc)
Seba500PLK Posted August 25, 2014 Author Posted August 25, 2014 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>
Et-win Posted August 25, 2014 Posted August 25, 2014 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'...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now