Doffy Posted February 25, 2019 Share Posted February 25, 2019 how i can make a ped on server side and make it chasing the players on server and if player hit the ped the ped will chasing him ? Link to comment
Moderators Patrick Posted February 25, 2019 Moderators Share Posted February 25, 2019 Maybe try something like that: -- CLIENT SIDE addEventHandler("onClientPedDamage", getRootElement(), function(attacker) if attacker == localPlayer then triggerServerEvent("startFollow", localPlayer, source, localPlayer) end end) -- SERVER SIDE local ped = createPed(0, 0, 0, 3) function startFollow(pedElement, playerElement) if isElement(pedElement) then setPedAnimation(pedElement, "muscular", "musclerun") setTimer(function() local x1, y1 = getElementPosition(playerElement) local x2, y2 = getElementPosition(pedElement) local rot = findRotation( x2, y2, x1, y1 ) setPedRotation(pedElement, rot) end, 250, 0) end end addEvent("startFollow", true) addEventHandler("startFollow", root, startFollow) function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end 1 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