Sign in to follow this  
kowixd

[HELP] Fire bug in AFK script

Recommended Posts

 

Hello, I want it to be impossible to shoot while this / afk
I use toggleControl (player, "fire", false) but this bug in freeroam server ( I think)
and allow to shoot

HELP please :(

addEventHandler("onPlayerJoin",getRootElement(),
function ()
setElementData(source,"afk_state","back")
setElementData(source,"HideState","disabled")
setElementData(source,"tafk",false)
end)


addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
setElementData(v,"tafk",false)
end
end)



function afkstart(player)
local vida = getElementHealth ( player )
local x, y, z = getElementPosition ( player )
local interior = getElementInterior (player )
local dim = getElementDimension (player) 	
if getElementData(player,"afk_state") == "back" then
if vida < 35 then 
return
 outputChatBox ("No puedes ir AFK con la vida baja!",player,255,0,0) 
end
if getElementData (player, "tafk", true) then 
outputChatBox ('#00FF00Espere 10 segundos...',player,255,0,0,true) 
return 
end
local id2 = getPedWeapon (player)
triggerClientEvent(player,"god_mode",player)
setElementFrozen(player,true)
setPlayerNametagText (player, "|AFK|" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00 is AFK!",getRootElement(),255,50,0, true)
setElementData(player,"afk_state","afk")
	if id2 > 0 then
	giveWeapon (player, 0, 1, true)
	end
    
	theMarker = createMarker ( x, y, z-1.5, "cylinder", 1.5, 0, 255, 0, 170 )
	setElementInterior(theMarker, interior, x, y, z-1.5)
	setElementDimension(theMarker, dim, interior, x, y, z-1.5)
	toggleControl (player, "fire", false)
    toggleControl (player, "next_weapon", false)
    toggleControl (player, "previous_weapon", false)
	toggleControl ( player, 'vehicle_fire', false )
    toggleControl (player, "aim_weapon", false)

	    bindKey (player,"w","down","noafk")
        bindKey (player,"d","down","noafk")
        bindKey (player,"s","down","noafk")
        bindKey (player,"a","down","noafk")
		bindKey (player,"num_0","down","noafk")
		bindKey (player,"lctrl","down","noafk")
		--bindKey (player,"mouse1","down","noafk")
		bindKey (player,"arrow_u","down","noafk")
		bindKey (player,"arrow_d","down","noafk")
		bindKey (player,"arrow_l","down","noafk")
		bindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
fixVehicle(getPedOccupiedVehicle(player),true)
setElementFrozen(getPedOccupiedVehicle(player),true)
setVehicleDamageProof(getPedOccupiedVehicle(player),true)
end
setElementData (player, "tafk",true)
setTimer (setElementData, 10000, 1, player, "tafk", false)
end

end    
addCommandHandler("afk", afkstart )

function afkend(player)
if getElementData(player,"afk_state") == "afk" then
setElementData(player,"afk_state","back")
triggerClientEvent(player,"disable_god_mode",player)
setElementFrozen(player,false)
setPlayerNametagText (player, "" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00is back!",getRootElement(),0,255,0, true)
    toggleControl (player, "fire", true)
    toggleControl (player, "next_weapon", true)
    toggleControl (player, "previous_weapon", true)
    toggleControl ( player, 'vehicle_fire', true )
    toggleControl (player, "aim_weapon", true)
	destroyElement(theMarker)
	    unbindKey (player,"w","down","noafk")
        unbindKey (player,"d","down","noafk")
        unbindKey (player,"s","down","noafk")
        unbindKey (player,"a","down","noafk")
		unbindKey (player,"num_0","down","noafk")
		unbindKey (player,"lctrl","down","noafk")
		--unbindKey (player,"mouse1","down","noafk")
		unbindKey (player,"arrow_u","down","noafk")
		unbindKey (player,"arrow_d","down","noafk")
		unbindKey (player,"arrow_l","down","noafk")
		unbindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
setElementFrozen(getPedOccupiedVehicle(player),false)
setVehicleDamageProof(getPedOccupiedVehicle(player),false)
end
end
end
addCommandHandler("noafk", afkend )


addEventHandler( "onResourceStop", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
setElementData(v,"tafk",false)
end
end)

Share this post


Link to post
2 hours ago, kowixd said:

 

Hello, I want it to be impossible to shoot while this / afk
I use toggleControl (player, "fire", false) but this bug in freeroam server ( I think)
and allow to shoot

HELP please :(


addEventHandler("onPlayerJoin",getRootElement(),
function ()
setElementData(source,"afk_state","back")
setElementData(source,"HideState","disabled")
setElementData(source,"tafk",false)
end)


addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
setElementData(v,"tafk",false)
end
end)



function afkstart(player)
local vida = getElementHealth ( player )
local x, y, z = getElementPosition ( player )
local interior = getElementInterior (player )
local dim = getElementDimension (player) 	
if getElementData(player,"afk_state") == "back" then
if vida < 35 then 
return
 outputChatBox ("No puedes ir AFK con la vida baja!",player,255,0,0) 
end
if getElementData (player, "tafk", true) then 
outputChatBox ('#00FF00Espere 10 segundos...',player,255,0,0,true) 
return 
end
local id2 = getPedWeapon (player)
triggerClientEvent(player,"god_mode",player)
setElementFrozen(player,true)
setPlayerNametagText (player, "|AFK|" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00 is AFK!",getRootElement(),255,50,0, true)
setElementData(player,"afk_state","afk")
	if id2 > 0 then
	giveWeapon (player, 0, 1, true)
	end
    
	theMarker = createMarker ( x, y, z-1.5, "cylinder", 1.5, 0, 255, 0, 170 )
	setElementInterior(theMarker, interior, x, y, z-1.5)
	setElementDimension(theMarker, dim, interior, x, y, z-1.5)
	toggleControl (player, "fire", false)
    toggleControl (player, "next_weapon", false)
    toggleControl (player, "previous_weapon", false)
	toggleControl ( player, 'vehicle_fire', false )
    toggleControl (player, "aim_weapon", false)

	    bindKey (player,"w","down","noafk")
        bindKey (player,"d","down","noafk")
        bindKey (player,"s","down","noafk")
        bindKey (player,"a","down","noafk")
		bindKey (player,"num_0","down","noafk")
		bindKey (player,"lctrl","down","noafk")
		--bindKey (player,"mouse1","down","noafk")
		bindKey (player,"arrow_u","down","noafk")
		bindKey (player,"arrow_d","down","noafk")
		bindKey (player,"arrow_l","down","noafk")
		bindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
fixVehicle(getPedOccupiedVehicle(player),true)
setElementFrozen(getPedOccupiedVehicle(player),true)
setVehicleDamageProof(getPedOccupiedVehicle(player),true)
end
setElementData (player, "tafk",true)
setTimer (setElementData, 10000, 1, player, "tafk", false)
end

end    
addCommandHandler("afk", afkstart )

function afkend(player)
if getElementData(player,"afk_state") == "afk" then
setElementData(player,"afk_state","back")
triggerClientEvent(player,"disable_god_mode",player)
setElementFrozen(player,false)
setPlayerNametagText (player, "" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00is back!",getRootElement(),0,255,0, true)
    toggleControl (player, "fire", true)
    toggleControl (player, "next_weapon", true)
    toggleControl (player, "previous_weapon", true)
    toggleControl ( player, 'vehicle_fire', true )
    toggleControl (player, "aim_weapon", true)
	destroyElement(theMarker)
	    unbindKey (player,"w","down","noafk")
        unbindKey (player,"d","down","noafk")
        unbindKey (player,"s","down","noafk")
        unbindKey (player,"a","down","noafk")
		unbindKey (player,"num_0","down","noafk")
		unbindKey (player,"lctrl","down","noafk")
		--unbindKey (player,"mouse1","down","noafk")
		unbindKey (player,"arrow_u","down","noafk")
		unbindKey (player,"arrow_d","down","noafk")
		unbindKey (player,"arrow_l","down","noafk")
		unbindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
setElementFrozen(getPedOccupiedVehicle(player),false)
setVehicleDamageProof(getPedOccupiedVehicle(player),false)
end
end
end
addCommandHandler("noafk", afkend )


addEventHandler( "onResourceStop", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
setElementData(v,"tafk",false)
end
end)

Try with this. ( Not tested )

 

function afkstart(player)
local vida = getElementHealth ( player )
local x, y, z = getElementPosition ( player )
local interior = getElementInterior (player )
local dim = getElementDimension (player) 	
if getElementData(player,"afk_state") == "back" then
if vida < 35 then 
return
 outputChatBox ("No puedes ir AFK con la vida baja!",player,255,0,0) 
end
if getElementData (player, "tafk", true) then 
outputChatBox ('#00FF00Espere 10 segundos...',player,255,0,0,true) 
return 
end
local id2 = getPedWeapon (player)
triggerClientEvent(player,"god_mode",player)
setElementFrozen(player,true)
setPlayerNametagText (player, "|AFK|" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00 is AFK!",getRootElement(),255,50,0, true)
setElementData(player,"afk_state","afk")
	if id2 > 0 then
	giveWeapon (player, 0, 1, true)
	end
    
	theMarker = createMarker ( x, y, z-1.5, "cylinder", 1.5, 0, 255, 0, 170 )
	setElementInterior(theMarker, interior, x, y, z-1.5)
	setElementDimension(theMarker, dim, interior, x, y, z-1.5)
	toggleControl (player, "fire", false)
    toggleControl (player, "next_weapon", false)
    toggleControl (player, "previous_weapon", false)
	toggleControl ( player, 'vehicle_fire', false )
    toggleControl (player, "aim_weapon", false)

	    bindKey (player,"w","down","noafk")
        bindKey (player,"d","down","noafk")
        bindKey (player,"s","down","noafk")
        bindKey (player,"a","down","noafk")
		bindKey (player,"num_0","down","noafk")
		bindKey (player,"lctrl","down","noafk")
		--bindKey (player,"mouse1","down","noafk")
		bindKey (player,"arrow_u","down","noafk")
		bindKey (player,"arrow_d","down","noafk")
		bindKey (player,"arrow_l","down","noafk")
		bindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
fixVehicle(getPedOccupiedVehicle(player),true)
setElementFrozen(getPedOccupiedVehicle(player),true)
setVehicleDamageProof(getPedOccupiedVehicle(player),true)
end
setElementData (player, "tafk",true)
setTimer (setElementData, 10000, 1, player, "tafk", false)
end

end    
addCommandHandler("afk", afkstart )

function afkend(player)
if getElementData(player,"afk_state") == "afk" then
setElementData(player,"afk_state","back")
triggerClientEvent(player,"disable_god_mode",player)
setElementFrozen(player,false)
setPlayerNametagText (player, "" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00is back!",getRootElement(),0,255,0, true)
    toggleControl (player, "fire", true)
    toggleControl (player, "next_weapon", true)
    toggleControl (player, "previous_weapon", true)
    toggleControl ( player, 'vehicle_fire', true )
    toggleControl (player, "aim_weapon", true)
	destroyElement(theMarker)
	    unbindKey (player,"w","down","noafk")
        unbindKey (player,"d","down","noafk")
        unbindKey (player,"s","down","noafk")
        unbindKey (player,"a","down","noafk")
		unbindKey (player,"num_0","down","noafk")
		unbindKey (player,"lctrl","down","noafk")
		--unbindKey (player,"mouse1","down","noafk")
		unbindKey (player,"arrow_u","down","noafk")
		unbindKey (player,"arrow_d","down","noafk")
		unbindKey (player,"arrow_l","down","noafk")
		unbindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
setElementFrozen(getPedOccupiedVehicle(player),false)
setVehicleDamageProof(getPedOccupiedVehicle(player),false)
end
end
end
addCommandHandler("noafk", afkend )


addEventHandler( "onResourceStop", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
setElementData(v,"tafk",false)
end
end)

function cancelfire(player)
if getElementData(player,"afk_state") == "afk" then

cancelEvent()	
	
else	
	
	
end
end
addEventHandler ("onPlayerWeaponFire", getRootElement(), cancelfire)

 

Share this post


Link to post
50 minutes ago, <~kamikaze~> said:

Try with this. ( Not tested )

 


function afkstart(player)
local vida = getElementHealth ( player )
local x, y, z = getElementPosition ( player )
local interior = getElementInterior (player )
local dim = getElementDimension (player) 	
if getElementData(player,"afk_state") == "back" then
if vida < 35 then 
return
 outputChatBox ("No puedes ir AFK con la vida baja!",player,255,0,0) 
end
if getElementData (player, "tafk", true) then 
outputChatBox ('#00FF00Espere 10 segundos...',player,255,0,0,true) 
return 
end
local id2 = getPedWeapon (player)
triggerClientEvent(player,"god_mode",player)
setElementFrozen(player,true)
setPlayerNametagText (player, "|AFK|" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00 is AFK!",getRootElement(),255,50,0, true)
setElementData(player,"afk_state","afk")
	if id2 > 0 then
	giveWeapon (player, 0, 1, true)
	end
    
	theMarker = createMarker ( x, y, z-1.5, "cylinder", 1.5, 0, 255, 0, 170 )
	setElementInterior(theMarker, interior, x, y, z-1.5)
	setElementDimension(theMarker, dim, interior, x, y, z-1.5)
	toggleControl (player, "fire", false)
    toggleControl (player, "next_weapon", false)
    toggleControl (player, "previous_weapon", false)
	toggleControl ( player, 'vehicle_fire', false )
    toggleControl (player, "aim_weapon", false)

	    bindKey (player,"w","down","noafk")
        bindKey (player,"d","down","noafk")
        bindKey (player,"s","down","noafk")
        bindKey (player,"a","down","noafk")
		bindKey (player,"num_0","down","noafk")
		bindKey (player,"lctrl","down","noafk")
		--bindKey (player,"mouse1","down","noafk")
		bindKey (player,"arrow_u","down","noafk")
		bindKey (player,"arrow_d","down","noafk")
		bindKey (player,"arrow_l","down","noafk")
		bindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
fixVehicle(getPedOccupiedVehicle(player),true)
setElementFrozen(getPedOccupiedVehicle(player),true)
setVehicleDamageProof(getPedOccupiedVehicle(player),true)
end
setElementData (player, "tafk",true)
setTimer (setElementData, 10000, 1, player, "tafk", false)
end

end    
addCommandHandler("afk", afkstart )

function afkend(player)
if getElementData(player,"afk_state") == "afk" then
setElementData(player,"afk_state","back")
triggerClientEvent(player,"disable_god_mode",player)
setElementFrozen(player,false)
setPlayerNametagText (player, "" .. getPlayerName (player))
outputChatBox(getPlayerName(player).." #ffff00is back!",getRootElement(),0,255,0, true)
    toggleControl (player, "fire", true)
    toggleControl (player, "next_weapon", true)
    toggleControl (player, "previous_weapon", true)
    toggleControl ( player, 'vehicle_fire', true )
    toggleControl (player, "aim_weapon", true)
	destroyElement(theMarker)
	    unbindKey (player,"w","down","noafk")
        unbindKey (player,"d","down","noafk")
        unbindKey (player,"s","down","noafk")
        unbindKey (player,"a","down","noafk")
		unbindKey (player,"num_0","down","noafk")
		unbindKey (player,"lctrl","down","noafk")
		--unbindKey (player,"mouse1","down","noafk")
		unbindKey (player,"arrow_u","down","noafk")
		unbindKey (player,"arrow_d","down","noafk")
		unbindKey (player,"arrow_l","down","noafk")
		unbindKey (player,"arrow_r","down","noafk")
if getPedOccupiedVehicle(player) then
setElementFrozen(getPedOccupiedVehicle(player),false)
setVehicleDamageProof(getPedOccupiedVehicle(player),false)
end
end
end
addCommandHandler("noafk", afkend )


addEventHandler( "onResourceStop", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
setElementData(v,"tafk",false)
end
end)

function cancelfire(player)
if getElementData(player,"afk_state") == "afk" then

cancelEvent()	
	
else	
	
	
end
end
addEventHandler ("onPlayerWeaponFire", getRootElement(), cancelfire)

 

no work  

Bad argument @ 'getElementData' [Expected element at argument 1


 
Edited by kowixd

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.