adithegman Posted March 19, 2013 Posted March 19, 2013 (edited) hello! i am trying to make a cmd for the editor mode in race si that when you type /sw it saves your pos and then if yo type /lw it will warp you to the same pos and the same speed but it doesn't work please help me function saveWarp (playerSource) if(playerSource) then vehicle = getPedOccupiedVehicle(playerSource) local curposx, curposy, curposz = getElementPosition(vehicle) local currotx, curroty, currotz = getElementRotation(vehicle) local speedx, speedy, speedz = getElementVelocity(vehicle) outputChatBox("The Warp has been saved!", playerSource) end end addCommandHandler("sw", saveWarp) function loadWarp (playerSource) if(playerSource) then vehicle = getPedOccupiedVehicle(playerSource) setVehicleFrozen(vehicle, true) setElementPosition(vehicle, curposx, curposy, curposz) setElementRotation(vehicle, currotx, curroty, currotz) setTimer(setFreeze, 3000, 1) outputChatBox("The Warp has been loaded!", playerSource) end end addCommandHandler("lw", loadWarp) function setFreeze (playerSource) if(playerSource) then vehicle = getPedOccupiedVehicle(playerSource) setVehicleFrozen(vehicle, false) setElementVelocity(vehicle, speedx, speedy, speedz) end end Edited March 19, 2013 by Guest
Castillo Posted March 19, 2013 Posted March 19, 2013 local playerData = { } -- Define a table function saveWarp ( playerSource ) local vehicle = getPedOccupiedVehicle ( playerSource ) playerData [ playerSource ] = -- Add the player who used the command to the table, and insert the position, rotation, speed { position = { getElementPosition ( vehicle ) }, rotation = { getElementRotation ( vehicle ) }, speed = { getElementVelocity ( vehicle ) } } outputChatBox ( "The Warp has been saved!", playerSource ) end addCommandHandler ( "sw", saveWarp ) function loadWarp ( playerSource ) local data = playerData [ playerSource ] -- Check if the player is on the table. if ( data ) then -- If he/she is... local vehicle = getPedOccupiedVehicle ( playerSource ) setElementFrozen ( vehicle, true ) setElementPosition ( vehicle, unpack ( data.position ) ) -- Set the position to the value stored on the table. setElementRotation ( vehicle, unpack ( data.rotation ) ) -- Set the rotation to the value stored on the table. setTimer ( setFreeze, 3000, 1, vehicle, data.speed ) -- Pass the speed data to the "setFreeze" function. outputChatBox ( "The Warp has been loaded!", playerSource ) end end addCommandHandler ( "lw", loadWarp ) function setFreeze ( vehicle, speed ) if ( vehicle ) then setElementFrozen ( vehicle, false ) setElementVelocity ( vehicle, unpack ( speed ) ) end end Read the comments.
adithegman Posted March 19, 2013 Author Posted March 19, 2013 o thx now it works! thx man... credit is going to you!
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