Jump to content

Help with police


xXMADEXx

Recommended Posts

I have made this script:

function arrest(weapon, _, _, _, _, _, hitElement) 
    local job = getElementData(source,"Job") 
    if (hitElement) and (getElementType(hitElement) == "player") and (weapon == 3) then 
        if (job=="Swat") or (job=="Military") or (job=="Police") or (job=="FBI") then 
            showCursor(hitElement, true) 
        end 
    end 
end 
addEventHandler("onPlayerDamage",root,arrest) 
  

but it won't work, and nothing will show in debugscript...

Link to comment

K, i got this fixed, but i'm not sure what function to use to make the source follow the attacker.

function arrest ( attacker, weapon, bodypart, loss ) 
    local job = getTeamName(getPlayerTeam(attacker)) 
    local wanted = getPlayerWantedLevel(source) 
    if (source) and (getElementType(source) == "player") and (weapon == 3) then 
        if (job=="Swat") or (job=="Military") or (job=="Police") or (job=="FBI") then 
            if wanted > 0 then 
                showCursor(source, true) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerDamage",root,arrest) 
  

Link to comment
If you want the ped to exactly walk into your steps at a distance, I would recommend this:

onClientRender/onClientPreRender/setTimer:

Let ped face towards you using https://wiki.multitheftauto.com/wiki/FindRotation (fill in your x,y and ped's x,y).

Get distance between you and the ped using getDistanceBetweenPoints3D. When distance < x (followdistance), use setPedControlState to make the ped running, if he isn't already running to you. When distance > x, use setPedControlState to stop the ped from running, if he is still running.

Ped will always be looking at you, when you are getting too far away, he will keep running to you until distance between you and him < x.

I already asked for help and Puma answered with this which helped me a lot.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...