FatalTerror Posted January 6, 2012 Posted January 6, 2012 (edited) Hi, I want Move the ped of player as if he walked but i don't know if exist an function for it Possible ? Thanks Edited January 7, 2012 by Guest
Castillo Posted January 6, 2012 Posted January 6, 2012 You want to make a player walk or a ped? for peds: https://wiki.multitheftauto.com/wiki/SetPedControlState for players: https://wiki.multitheftauto.com/wiki/SetControlState
FatalTerror Posted January 6, 2012 Author Posted January 6, 2012 I want to player walk automatically of posA to posB I was without touching the keyboard
FatalTerror Posted January 7, 2012 Author Posted January 7, 2012 Ye i see but it don't give me how move him to x, y and z positions
FatalTerror Posted January 7, 2012 Author Posted January 7, 2012 getPedRotation setPedRotation setTimer This don't help me addEventHandler("onClientClick", getRootElement(), function( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if(button == "left")then if(state == "down")then local x, y, z = worldX, worldY, worldZ if x and y and z then -- Move the player to x, y and z end end end)
JR10 Posted January 7, 2012 Posted January 7, 2012 function findRotation ( posX , posY , _posX , _posY ) return 360 - ( math.deg ( math.atan2 ( _posX - posX , _posY - posY ) ) % 360 ) end Will get you the rotation to x,y,z addEventHandler("onClientClick", getRootElement(), function( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if(button == "left")then if(state == "down")then local x, y, z = worldX, worldY, worldZ if x and y and z then local posx , posy , posz = getElementPosition ( localPlayer ) local rot = findRotation ( posx , posy , x , y ) setPedRotation ( localPlayer , rot ) setControlState ( "forwards" , true ) end end end end) function findRotation ( startx , starty , endx , endy ) return 360 - ( math.deg ( math.atan2 ( endx - startx , endy - starty ) ) % 360 ) end Now you need to work something out for stopping him when he arrive. And prevent him from stopping due to obstacles.
FatalTerror Posted January 7, 2012 Author Posted January 7, 2012 function findRotation ( posX , posY , _posX , _posY ) return 360 - ( math.deg ( math.atan2 ( _posX - posX , _posY - posY ) ) % 360 ) end Will get you the rotation to x,y,z addEventHandler("onClientClick", getRootElement(), function( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if(button == "left")then if(state == "down")then local x, y, z = worldX, worldY, worldZ if x and y and z then local posx , posy , posz = getElementPosition ( localPlayer ) local rot = findRotation ( posx , posy , x , y ) setPedRotation ( localPlayer , rot ) setControlState ( "forwards" , true ) end end end end) function findRotation ( startx , starty , endx , endy ) return 360 - ( math.deg ( math.atan2 ( endx - startx , endy - starty ) ) % 360 ) end Now you need to work something out for stopping him when he arrive. And prevent him from stopping due to obstacles. Big thanks !
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