Jump to content

RPGs anti Spam


Chris!i!

Recommended Posts

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

Posted

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)

 

Posted (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 by Walid

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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)

 

Clan war system http://sh.st/7r4nI

 

Posted
7 hours ago, Chris!i! said:

Not working...

Lol it's a client side code check your meta.xml file (working fine for me).

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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