Jump to content

Problem.


Recommended Posts

Hello community ,,

i have a problem. i'm making a police job script, my problem is the police when arresting someone.. i made the event onPlayerDamage. the proble is that i want it not getting warped to the jail from only on hit from the nightstick i want it from 3 or 4 or whatever hits .. should i change the event ? should i change somethings in the function ? i hope someone can help. thanks

Link to comment

well i checked ur link and downloaded the script but understood nothing .. where is the part that checking how many hits done to the source or theprisoner ?

function rodneykingcheck ( attacker, weapon, bodypart, loss ) 
    if (attacker) and (weapon == 3) then     
        if getElementParent(attacker) == kingCOP then 
            local thecop = attacker 
            local theprisoner = source 
            local wlevel = getPlayerWantedLevel( source )    
            if (getElementData ( theprisoner, "currentstatus" ) ~= "underarrest") and (wlevel > 0) then  
                if (getElementData ( attacker, "currentarrests" ) ~= "single" ) and (getElementData ( attacker, "currentarrests" ) ~= "double" ) then    
                    setElementData ( thecop, "currentarrests", "single" ) 
                    triggerClientEvent(thecop,"copdirections",thecop) 
                elseif (getElementData ( attacker, "currentarrests" ) == "single" ) then 
                    setElementData ( thecop, "currentarrests", "double" )    
                end 
                setElementData ( theprisoner, "currentstatus", "underarrest" ) 
                setElementData ( theprisoner, "captor", thecop ) 
                showCursor ( source, true ) 
                toggleAllControls ( source, false, true, false ) 
                walktheprisoner ( thecop, theprisoner ) 
                setElementData ( theprisoner, "arrestTimeout", setTimer ( freetheguy, 180000, 1, theprisoner )) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement(), rodneykingcheck ) 

i want anyone help me with a simple example not a whole script .. Thanks

btw thanks xxmadexx for you effort.

Link to comment
  • Moderators

Here is an example:

function checkPoliceArrest( attacker, weapon, bodypart, loss ) 
    -- if there is an attacker and the weapon is a nightstick or a knife 
    if attacker and (weapon == 3 or weapon == 4) then 
  
        -- Do your stuff here 
  
    end 
end 
addEventHandler ( "onPlayerDamage", root, checkPoliceArrest ) 

Link to comment
  • Moderators
Citizen, as i said i want it not from 1 hit, the ex you wrote will do my stuff from only 1 hit by nightstick i want it do my stuff from 2 or more hits by nightstick not only one. thanks

Sorry, was replying to your initial post.

Hum you have to use an element data. Here is how I see it:

if the player is hitted by a nightstick used by a cop then 
    get the element data on source for the key "policeHits" or 0 
    add 1 to the hit count 
    if the hit count >= 2 then --you can change the hit count here 
        send him in jail 
    else 
        save the hit count in the element data in "policeHits" 
        get the element data on source for the key "policeHitsTimer" 
        if the timer ~= false and if the timer we got is a real timer then 
            kill the timer 
        end if 
        set a timer to call a function that will reset the element data "policeHits" to 0 
        save that timer in the element data under the key "policeHitsTimer" 
    end if 
end if 

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...