3B00DG4MER Posted March 19, 2014 Posted March 19, 2014 Hello,Today i want A script which when you Attack(I'm In police Team) a someone have 1 or Above with Nightstick Will Get to Jail,I made a Jail just do teleport to anywhere SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
Tete omar Posted March 19, 2014 Posted March 19, 2014 I can barely understand what you mean, could you clarify what you mean a bit more please?
3B00DG4MER Posted March 19, 2014 Author Posted March 19, 2014 I can barely understand what you mean, could you clarify what you mean a bit more? Normal Script if the player is in a Police Team when attack someone have 1 star or Above,the Attacked player will teleport to somewhere (I have the jail map,Just give me the script i'll edit) SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
cheez3d Posted March 19, 2014 Posted March 19, 2014 addEventHandler("onPlayerDamage",root,function(attacker,weapon) if getTeamName(getPlayerTeam(attacker)) == "Police" and weapon == 3 and getPlayerWantedLevel(source)>=1 then -- your stuff here end end)
3B00DG4MER Posted March 19, 2014 Author Posted March 19, 2014 addEventHandler("onPlayerDamage",root,function(attacker,weapon) if getTeamName(getPlayerTeam(attacker)) == "Police" and weapon == 3 and getPlayerWantedLevel(source)>=1 then -- your stuff here end end) Can you do it if the Police Attacked Him 3 Times Like GTA-AR server Or CIT or SAUR SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
Tete omar Posted March 19, 2014 Posted March 19, 2014 (I have the jail map,Just give me the script i'll edit) Sorry, we can't give you a ready-made script as you'll just copy & paste, therefore you'll learn nothing, we're here to help you out fixing or setting up the desired code, i'll just give you the functions and events you need: Functions: getPlayerWantedLevel setElementPosition getPlayerTeam Event(s): onPlayerDamage
cheez3d Posted March 19, 2014 Posted March 19, 2014 (edited) local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timer = false addEventHandler("onPlayerDamage",root,function(attacker,weapon) if getTeamName(getPlayerTeam(attacker)) == "Police" and weapon == 3 and getPlayerWantedLevel(source)>=1 then if timer then resetTimer(timer) end setElementData(source,"times_attacked",getElementData(source,"times_attacked") and ,getElementData(source,"times_attacked")+1 or 1) if not timer then timer = setTimer(function() if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end end,cooldown*1000,1) end if getElementData(source,"times_attacked")>=3 then if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end if timer then killTimer(timer) timer = false end -- your stuff here end end end) Edited March 19, 2014 by Guest
3B00DG4MER Posted March 19, 2014 Author Posted March 19, 2014 local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timer addEventHandler("onPlayerDamage",root,function(attacker,weapon) if timer then resetTimer(timer) end setElementData(source,"times_attacked",getElementData(source,"times_attacked") and ,getElementData(source,"times_attacked")+1 or 1) timer = setTimer(function() if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end end,cooldown*1000,1) if getTeamName(getPlayerTeam(attacker)) == "Police" and weapon == 3 and getPlayerWantedLevel(source)>=1 and getElementData(source,"times_attacked")>=3 then if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end if timer then killTimer(timer) end -- your stuff here end end) Thanks man SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
cheez3d Posted March 19, 2014 Posted March 19, 2014 There were some bugs in the code. Copy it again, I updated it.
3B00DG4MER Posted March 19, 2014 Author Posted March 19, 2014 There were some bugs in the code. Copy it again, I updated it. You do a bug when Update, i have fixed it local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timer = false addEventHandler("onPlayerDamage",root,function(attacker,weapon) if getTeamName(getPlayerTeam(attacker)) == "Police" and weapon == 3 and getPlayerWantedLevel(source)>=1 then if timer then resetTimer(timer) end setElementData(source,"times_attacked",getElementData(source,"times_attacked") and getElementData(source,"times_attacked")+1 or 1) if not timer then timer = setTimer( function() if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end end,cooldown*1000,1) end if getElementData(source,"times_attacked")>=3 then if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end if timer then killTimer(timer) timer = false end -- your stuff here end end end) SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
3B00DG4MER Posted March 19, 2014 Author Posted March 19, 2014 local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timer = false addEventHandler("onPlayerDamage",root,function(attacker,weapon) if getTeamName(getPlayerTeam(attacker)) == "Police" and weapon == 3 and getPlayerWantedLevel(source)>=1 then if timer then resetTimer(timer) end setElementData(source,"times_attacked",getElementData(source,"times_attacked") and ,getElementData(source,"times_attacked")+1 or 1) if not timer then timer = setTimer(function() if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end end,cooldown*1000,1) end if getElementData(source,"times_attacked")>=3 then if getElementData(source,"times_attacked") then removeElementData(source,"times_attacked") end if timer then killTimer(timer) timer = false end -- your stuff here end end end) I have Problem fix it please Attempt to compare Boolean with number when i attack him 3 Times SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
Castillo Posted March 19, 2014 Posted March 19, 2014 local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timers = { } addEventHandler ( "onPlayerDamage", root, function ( attacker, weapon ) if ( isElement ( attacker ) and getElementType ( attacker ) == "player" ) then if ( getTeamName ( getPlayerTeam ( attacker ) ) == "Police" and weapon == 3 and getPlayerWantedLevel ( source ) >= 1 ) then if ( timers [ source ] ) then resetTimer ( timers [ source ] ) end local times = ( tonumber ( getElementData ( source,"times_attacked" ) ) or 0 ) setElementData ( source, "times_attacked", ( times + 1 ) ) if ( not timers [ source ] ) then timers [ source ] = setTimer ( function ( ) if getElementData ( source,"times_attacked" ) then removeElementData ( source,"times_attacked" ) timers [ source ] = nil end end ,( cooldown * 1000 ), 1 ) end if ( getElementData ( source, "times_attacked" ) >= 3 ) then if getElementData ( source,"times_attacked" ) then removeElementData ( source, "times_attacked" ) end if ( timers [ source ] ) then killTimer ( timers [ source ] ) timers [ source ] = nil end end end end end ) Try it. I changed the timer part, since you were using a global variable, which means if another player was attacked, the timer for the other players would be the same, so you had to use a table. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
3B00DG4MER Posted March 19, 2014 Author Posted March 19, 2014 local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timers = { } addEventHandler ( "onPlayerDamage", root, function ( attacker, weapon ) if ( isElement ( attacker ) and getElementType ( attacker ) == "player" ) then if ( getTeamName ( getPlayerTeam ( attacker ) ) == "Police" and weapon == 3 and getPlayerWantedLevel ( source ) >= 1 ) then if ( timers [ source ] ) then resetTimer ( timers [ source ] ) end local times = ( tonumber ( getElementData ( source,"times_attacked" ) ) or 0 ) setElementData ( source, "times_attacked", ( times + 1 ) ) if ( not timers [ source ] ) then timers [ source ] = setTimer ( function ( ) if getElementData ( source,"times_attacked" ) then removeElementData ( source,"times_attacked" ) timers [ source ] = nil end end ,( cooldown * 1000 ), 1 ) end if ( getElementData ( source, "times_attacked" ) >= 3 ) then if getElementData ( source,"times_attacked" ) then removeElementData ( source, "times_attacked" ) end if ( timers [ source ] ) then killTimer ( timers [ source ] ) timers [ source ] = nil end end end end end ) Try it. I changed the timer part, since you were using a global variable, which means if another player was attacked, the timer for the other players would be the same, so you had to use a table. Thank you very much SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
Castillo Posted March 19, 2014 Posted March 19, 2014 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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