adithegman Posted March 19, 2013 Share 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 Link to comment
Waileer Posted March 19, 2013 Share Posted March 19, 2013 I think this should go to Scripting Link to comment
adithegman Posted March 19, 2013 Author Share Posted March 19, 2013 ok sorry guys i am new Link to comment
Castillo Posted March 19, 2013 Share 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. Link to comment
adithegman Posted March 19, 2013 Author Share Posted March 19, 2013 ooo thx Castillo you the best Link to comment
Castillo Posted March 19, 2013 Share Posted March 19, 2013 Did the script work? I didn't test it myself. Link to comment
adithegman Posted March 19, 2013 Author Share Posted March 19, 2013 no man... /lw doesn't work... Link to comment
Castillo Posted March 19, 2013 Share Posted March 19, 2013 You set the script as server side, right? Link to comment
adithegman Posted March 19, 2013 Author Share Posted March 19, 2013 o thx now it works! thx man... credit is going to you! 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