Hell-Mate Posted March 8, 2014 Share Posted March 8, 2014 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
xXMADEXx Posted March 8, 2014 Share Posted March 8, 2014 You can check how Slothman did it in this script. Link to comment
Hell-Mate Posted March 8, 2014 Author Share Posted March 8, 2014 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 Citizen Posted March 8, 2014 Moderators Share Posted March 8, 2014 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
Hell-Mate Posted March 8, 2014 Author Share Posted March 8, 2014 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 Link to comment
Moderators Citizen Posted March 9, 2014 Moderators Share Posted March 9, 2014 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
Hell-Mate Posted March 9, 2014 Author Share Posted March 9, 2014 Citizen thanks. but can you please write an example in lua ? i just got it 50%, can u write it in lua and real functions to get it 100% ?. thanks , btw dont forget to add the event . thanks very much Link to comment
Moderators Citizen Posted March 9, 2014 Moderators Share Posted March 9, 2014 Haha no. You just have to translate it. It will be a good exercise for a beginner like you. Link to comment
Hell-Mate Posted March 9, 2014 Author Share Posted March 9, 2014 its okay, i will try to translate it, but what event should i add ? Link to comment
Moderators Citizen Posted March 9, 2014 Moderators Share Posted March 9, 2014 addEventHandler ( "onPlayerDamage", root, checkPoliceArrest ) 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