exports.scoreboard:addScoreboardColumn( 'afk_state' )
addEventHandler("onPlayerJoin",getRootElement(),
function ()
setElementData(source,"afk_state","back")
setElementData(source,"HideState","disabled")
end)
addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()),
function ()
for i,v in pairs (getElementsByType("player")) do
setElementData(v,"afk_state","back")
setElementData(v,"HideState","disabled")
end
end)
addCommandHandler("afk",
function (thePlayer)
if getElementData(thePlayer,"afk_state") == "back" then
triggerClientEvent(thePlayer,"god_mode",thePlayer)
setPedFrozen(thePlayer,true)
setPlayerNametagText (thePlayer, "|AFK|" .. getPlayerName (thePlayer))
outputChatBox(getPlayerName(thePlayer).." is AFK!",getRootElement(),255,50,0)
setElementData(thePlayer,"afk_state","afk")
if getPedOccupiedVehicle(thePlayer) then
fixVehicle(getPedOccupiedVehicle(thePlayer),true)
setVehicleFrozen(getPedOccupiedVehicle(thePlayer),true)
setVehicleDamageProof(getPedOccupiedVehicle(thePlayer),true)
end
elseif getElementData(thePlayer,"afk_state") == "afk" then
setElementData(thePlayer,"afk_state","back")
triggerClientEvent(thePlayer,"disable_god_mode",thePlayer)
setPedFrozen(thePlayer,false)
setPlayerNametagText (thePlayer, "" .. getPlayerName (thePlayer))
outputChatBox(getPlayerName(thePlayer).." is back!",getRootElement(),0,255,0)
if getPedOccupiedVehicle(thePlayer) then
setVehicleFrozen(getPedOccupiedVehicle(thePlayer),false)
setVehicleDamageProof(getPedOccupiedVehicle(thePlayer),false)
end
end
end)
جرب لاني ما جربت