Monty Posted August 19, 2012 Share Posted August 19, 2012 hi... what's the name of the function to make a player follow another one Link to comment
Tete omar Posted August 19, 2012 Share Posted August 19, 2012 I think you want to attach the players use attachElements or getPedAnimation and setPedAnimation afaik Link to comment
ernst Posted August 19, 2012 Share Posted August 19, 2012 You can use setControlState Link to comment
Flaker Posted August 19, 2012 Share Posted August 19, 2012 Example of "follow" function: --Server Side function addPed(thePlayer) local x, y, z = getElementPosition( thePlayer ); x = x + math.cos( math.rad( getPlayerRotation( thePlayer ) ) ) * 2; y = y - math.sin( math.rad( getPlayerRotation( thePlayer ) ) ) * 2; if (thePed) then destroyElement(thePed) end thePed = createPed ( math.random( 10, 270 ), x, y, z) triggerClientEvent ( "followPlayer", Ped, thePlayer, true ) end addCommandHandler ( "ped", addPed ) --Client Side local followTo local follower addEvent("followPlayer", true) addEventHandler("followPlayer", root, function (thePlayer, value) if (isElement(source) and isElement(thePlayer) ) then if (value) then followTo = thePlayer follower = source removeEventHandler( "onClientRender", root, FollowToPlayer) addEventHandler( "onClientRender", root, FollowToPlayer) else removeEventHandler( "onClientRender", root, FollowToPlayer) end end end) function FollowToPlayer() local ped = follower --Ped who has to follow the player local plr = followTo -- The Player if ped then local x, y, z = getElementPosition( plr ); local px, py, pz = getElementPosition( ped ); local distance = getDistanceBetweenPoints3D( x, y, z, px, py, pz ) if distance < 3.5 then setPedControlState( ped, "forwards", false ); if ( isPedDucked( plr ) ~= isPedDucked( ped ) ) then setPedControlState( ped, "crouch", isPedDucked( getLocalPlayer( ) )); return end else setPedControlState( ped, "forwards", true ); if distance < 6.0 then if isPedDucked( plr ) ~= isPedDucked( ped ) then setPedControlState( ped, "crouch", false ); setPedControlState( ped, "crouch", true ); setPedControlState( ped, "walk", false ); setPedControlState( ped, "sprint", false ); return else setPedControlState( ped, "walk", true ); setPedControlState( ped, "sprint", false ); end elseif distance < 10.0 then setPedControlState( ped, "walk", false ); setPedControlState( ped, "sprint", true ); else setPedControlState( ped, "walk", false ); setPedControlState( ped, "sprint", true ); end local X, Y = 0, 0; X = math.abs( x - px ); Y = math.abs( y - py ); faceMe = math.deg( math.atan2( Y , X ) ); if ( x >= px ) and ( y > py ) then -- north-east faceMe = 90 - faceMe elseif ( x <= px ) and ( y > py ) then -- north-west faceMe = 270 + faceMe elseif ( x >= px ) and ( y <= py ) then -- south-east faceMe = 90 + faceMe elseif ( x < px ) and ( y <= py ) then -- south-west faceMe = 270 - faceMe end setPedRotation( ped, faceMe ); setPedLookAt( ped, x, y, z + .5 ); end end end _setPedRotation = setPedRotation function setPedRotation( ped, rot ) return _setPedRotation( ped, 360 - rot ); end Link to comment
Monty Posted August 20, 2012 Author Share Posted August 20, 2012 is there something more simply Link to comment
ASM Posted August 20, 2012 Share Posted August 20, 2012 is there something more simply If you wanna make a resoursce using actores i mean zombies, enemies etc. i prefer you to create own AI system. You dont have to do it yourself you can just ask somebody for help. Link to comment
Monty Posted August 21, 2012 Author Share Posted August 21, 2012 i need that a player follow anotherone when he get hit by nightstick Link to comment
AMARANT Posted August 21, 2012 Share Posted August 21, 2012 You was given the code example and there is a resource that has a feature you want. Don't be lazy and do something with it instead of waiting for someone who makes the whole script for 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