Chris!i! Posted October 6, 2016 Share Posted October 6, 2016 antiSpam = {} function antiSpamRPG(thePlayer) if isTimer(antiSpam[thePlayer]) then local slot = getPedWeaponSlot(thePlayer) if (slot == 7) then toggleControl(thePlayer, "aim_weapon", false) toggleControl(thePlayer, "fire", false) cancelEvent() else antiSpam[thePlayer] = setTimer(function(thePlayer) antiSpam[thePlayer] = nil end, 7000, 1, thePlayer) toggleControl(thePlayer, "aim_weapon", true) toggleControl(thePlayer, "fire", true) end end end addEventHandler("onPlayerWeaponFire", getRootElement(), antiSpamRPG) first function works, but the second one the player keeps firing RPGs no limit... Link to comment
pa3ck Posted October 6, 2016 Share Posted October 6, 2016 You don't really need to do that server side, you can achieve the same thing client side, which in my opinion much better. local cdTimer function antiSpamRPG(weap) if isTimer(cdTimer) then return end local slot = getPedWeaponSlot(localPlayer) if (slot == 7) then toggleControl("aim_weapon", false) toggleControl("fire", false) cdTimer = setTimer( function() toggleControl("aim_weapon", true) toggleControl("fire", true) end, 7000, 1 ) end end addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), antiSpamRPG) Link to comment
Walid Posted October 7, 2016 Share Posted October 7, 2016 (edited) function antiSpamRPG(weapon) if isTimer(cdTimer) then return end if (weapon == 35) then toggleControl("aim_weapon", false) toggleControl("fire", false) cdTimer = setTimer( function() toggleControl("aim_weapon", true) toggleControl("fire", true) end, 7000, 1 ) end end addEventHandler("onClientPlayerWeaponFire",localPlayer, antiSpamRPG) Edited October 7, 2016 by Walid Link to comment
Gravestone Posted October 8, 2016 Share Posted October 8, 2016 cdTimer = {} function antiSpamRPG(weapon) if isTimer(cdTimer[localPlayer]) then return end if (weapon == 35) then toggleControl("aim_weapon", false) toggleControl("fire", false) cdTimer[localPlayer] = setTimer( function() toggleControl("aim_weapon", true) toggleControl("fire", true) killTimer(cdTimer[localPlayer]) end, 7000, 1 ) end end addEventHandler("onClientPlayerWeaponFire",localPlayer, antiSpamRPG) Link to comment
Walid Posted October 8, 2016 Share Posted October 8, 2016 7 hours ago, Chris!i! said: Not working... Lol it's a client side code check your meta.xml file (working fine for me). Link to comment
Chris!i! Posted October 8, 2016 Author Share Posted October 8, 2016 It's not working, well if it was working i would have said thanks but no.. Sorry for that Link to comment
Chris!i! Posted October 10, 2016 Author Share Posted October 10, 2016 Some help over here.. Link to comment
Gravestone Posted October 11, 2016 Share Posted October 11, 2016 Did you try my code? 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