Imposter Posted July 19, 2012 Share Posted July 19, 2012 For some strange reason, when i type "/pos" in mta, it dumps my position as 0,0,0. look. positiondump.txt 0, 0, 0 ---------- Server Side: function outputPOS () local x, y, z = getElementPosition( getRootElement() ) local car = getPedOccupiedVehicle( getRootElement() ) local cx, cy, cz = getElementPosition( car ) local file = fileOpen("positiondump.txt") if not file then file = fileCreate("positiondump.txt") outputDebugString("Creating positiondump.txt") end if file then if (car) then fileSetPos(file,fileGetSize(file)) local written = fileWrite( file, cx .. ", " .. cy .. ", " .. cz,"\r\n----------\r\n") fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved your car's position!",source) outputChatBox(valuetype,source) end else fileSetPos(file,fileGetSize(file)) local written = fileWrite( file, x .. ", " .. y .. ", " .. z,"\r\n----------\r\n") fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved your position!",source) outputChatBox(valuetype,source) end end else outputDebugString("ERROR: Cannot find or create positiondump.txt") end end addEvent("OutputGUIToFile",true) addCommandHandler("pos" ,outputPOS) Link to comment
AMARANT Posted July 19, 2012 Share Posted July 19, 2012 You're trying to get the position of root element instead of a specific player or vehicle. Link to comment
Imposter Posted July 19, 2012 Author Share Posted July 19, 2012 You're trying to get the position of root element instead of a specific player or vehicle. OHHH!!!! So i have to use source? Link to comment
Al3grab Posted July 19, 2012 Share Posted July 19, 2012 You're trying to get the position of root element instead of a specific player or vehicle. OHHH!!!! So i have to use source? No , addCommandHandler function have 3 parameters : player , command and the passed arguments .. so your function should be "function outputPOS ( player , command )" while player is the player who wrote the command you will use player instead of getRootElement() .. "local x, y, z = getElementPosition( player )" and so on. Link to comment
Imposter Posted July 19, 2012 Author Share Posted July 19, 2012 (edited) You're trying to get the position of root element instead of a specific player or vehicle. OHHH!!!! So i have to use source? No , addCommandHandler function have 3 parameters : player , command and the passed arguments .. so your function should be "function outputPOS ( player , command )" while player is the player who wrote the command you will use player instead of getRootElement() .. "local x, y, z = getElementPosition( player )" and so on. AL3GRAB u are a genius. i am going to release the resource right now with u and AMARANT in the credits thanks! here is the link : https://community.multitheftauto.com/ind ... ls&id=5242 Edited July 19, 2012 by Guest Link to comment
TwiX! Posted July 19, 2012 Share Posted July 19, 2012 if it's client so function outputPOS () local x, y, z = tonumber(getElementPosition( localPlayer )) local car = getPedOccupiedVehicle( localPlayer ) local cx, cy, cz = tonumber(getElementPosition( car )) local file = fileOpen("positiondump.txt") if not file then file = fileCreate("positiondump.txt") outputDebugString("Creating positiondump.txt") end if file then if (car) then fileSetPos(file,fileGetSize(file)) local written = fileWrite( file, cx .. ", " .. cy .. ", " .. cz,"\r\n----------\r\n") fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved your car's position!") outputChatBox(valuetype) end else fileSetPos(file,fileGetSize(file)) local written = fileWrite( file, x .. ", " .. y .. ", " .. z,"\r\n----------\r\n") fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved your position!") outputChatBox(valuetype) end end else outputDebugString("ERROR: Cannot find or create positiondump.txt") end end addCommandHandler("pos" ,outputPOS) if server-side function outputPOS (playerSource) local x, y, z = tonumber(getElementPosition( playerSource )) local car = getPedOccupiedVehicle( playerSource ) local cx, cy, cz = tonumber(getElementPosition( car )) local file = fileOpen("positiondump.txt") if not file then file = fileCreate("positiondump.txt") outputDebugString("Creating positiondump.txt") end if file then if (car) then fileSetPos(file,fileGetSize(file)) local written = fileWrite( file, cx .. ", " .. cy .. ", " .. cz,"\r\n----------\r\n") fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved your car's position!",playerSource) outputChatBox(valuetype,playerSource) end else fileSetPos(file,fileGetSize(file)) local written = fileWrite( file, x .. ", " .. y .. ", " .. z,"\r\n----------\r\n") fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved your position!",playerSource) outputChatBox(valuetype,playerSource) end end else outputDebugString("ERROR: Cannot find or create positiondump.txt") end end addCommandHandler("pos" ,outputPOS) Link to comment
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