Jump to content

Doesn't work


Recommended Posts

This doesn't work, gives a strange error in debug. Here's the code:

function dxDraw() 
        dxDrawText("You are now AFK!", 432, 266, 1015, 331, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText("Type /afk to come back!", 568, 321, 836, 341, tocolor(255, 255, 255, 255), 0.70, "bankgothic", "left", "top", false, false, false, false, false) 
end 
  
function setPlayerAFK() 
local wanted = getPlayerWantedLevel(localPlayer) 
if getElementData(localPlayer, "afk", true) then return outputChatBox("You are already AFK!", 255, 0, 0) end 
if isPedInVehicle(localPlayer) or wanted > 1 then return outputChatBox("Unable to go AFK!", 255, 0, 0) end 
setElementFrozen(localPlayer, true) 
setElementData(localPlayer, "invincible", true) 
setElementAlpha(localPlayer, 100) 
fadeCamera(false) 
addEventHandler("onClientRender", root, dxDraw) 
setElementData(localPlayer, "afk", true) 
else 
setElementFrozen(localPlayer, false) 
setElementData(localPlayer, "back", true) 
setElementAlpha(localPlayer, 255) 
removeEventHandler("onClientRender", root, dxDraw) 
fadeCamera(true) 
end 
addCommandHandler("afk", setPlayerAFK) 

Link to comment
function dxDraw() 
    dxDrawText("You are now AFK!\nType /afk to come back!", 432, 266, 1015, 331, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "left", "top", false, false, false, false, false) 
end 
  
function setPlayerAFK() 
    local wanted = getPlayerWantedLevel(localPlayer) 
        if getElementData(localPlayer, "afk", true) then 
            return outputChatBox("You are already AFK!", 255, 0, 0) 
        end 
        if isPedInVehicle(localPlayer) or wanted > 1 then  
            return outputChatBox("Unable to go AFK!", 255, 0, 0)  
        end 
        if getElementData(localPlayer, "afk") then  
            setElementFrozen(localPlayer, false) 
            setElementData(localPlayer, "afk", false) 
            setElementAlpha(localPlayer, 255) 
            removeEventHandler("onClientRender", root, dxDraw) 
            fadeCamera(true) 
        else 
            setElementFrozen(localPlayer, true) 
            setElementData(localPlayer, "invincible", true) 
            setElementAlpha(localPlayer, 100) 
            fadeCamera(false) 
            addEventHandler("onClientRender", root, dxDraw) 
            setElementData(localPlayer, "afk", true) 
    end  
end 
addCommandHandler("afk", setPlayerAFK) 

Link to comment

You meant something like this? It still doesn't work!

function dxDraw() 
    dxDrawText("You are now AFK!\nType /afk to come back!", 432, 266, 1015, 331, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "left", "top", false, false, false, false, false) 
end 
  
function setPlayerAFK() 
    local wanted = getPlayerWantedLevel(localPlayer) 
        if getElementData(localPlayer,"afk") == true then  then 
            return outputChatBox("You are already AFK!", 255, 0, 0) 
        end 
        if isPedInVehicle(localPlayer) or wanted > 1 then 
            return outputChatBox("Unable to go AFK!", 255, 0, 0) 
        end 
            if getElementData(localPlayer,"afk") == true then  
            setElementFrozen(localPlayer, false) 
            setElementData(localPlayer, "afk", false) 
            setElementAlpha(localPlayer, 255) 
            removeEventHandler("onClientRender", root, dxDraw) 
            fadeCamera(true) 
        else 
            setElementFrozen(localPlayer, true) 
            setElementData(localPlayer, "invincible", true) 
            setElementAlpha(localPlayer, 100) 
            fadeCamera(false) 
            addEventHandler("onClientRender", root, dxDraw) 
            setElementData(localPlayer, "afk", true) 
    end 
end 
addCommandHandler("afk", setPlayerAFK) 

Link to comment
You meant something like this? It still doesn't work!

:3

function dxDraw() 
    dxDrawText("You are now AFK!\nType /afk to come back!", 432, 266, 1015, 331, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "left", "top", false, false, false, false, false) 
end 
  
function setPlayerAFK() 
    local wanted = getPlayerWantedLevel(localPlayer) 
        if isPedInVehicle(localPlayer) or wanted > 1 then 
            return outputChatBox("Unable to go AFK!", 255, 0, 0) 
        end 
            if getElementData(localPlayer,"afk") then 
            setElementFrozen(localPlayer, false) 
            setElementData(localPlayer, "afk", false) 
            setElementAlpha(localPlayer, 255) 
            removeEventHandler("onClientRender", root, dxDraw) 
            fadeCamera(true) 
        else 
            setElementFrozen(localPlayer, true) 
            setElementData(localPlayer, "invincible", true) 
            setElementAlpha(localPlayer, 100) 
            fadeCamera(false) 
            addEventHandler("onClientRender", root, dxDraw) 
            setElementData(localPlayer, "afk", true) 
    end 
end 
addCommandHandler("afk", setPlayerAFK) 

Link to comment
function setPlayerAFK() 
    local wanted = getPlayerWantedLevel(localPlayer) 
        if isPedInVehicle(localPlayer) or wanted > 1 then 
            return outputChatBox("Unable to go AFK!", 255, 0, 0) 
        end 
            if getElementData(localPlayer,"afk") == true then 
            setElementFrozen(localPlayer, false) 
            setElementData(localPlayer, "afk", false) 
            setElementAlpha(localPlayer, 255) 
            removeEventHandler("onClientRender", root, dxDraw) 
            fadeCamera(true) 
        else 
            setElementFrozen(localPlayer, true) 
            setElementData(localPlayer, "invincible", true) 
            setElementAlpha(localPlayer, 100) 
            fadeCamera(false) 
            addEventHandler("onClientRender", root, dxDraw) 
            setElementData(localPlayer, "afk", true) 
    end 
end 
  
tickA = {} 
  
function toggleAFK() 
    local one_min = 1000*60 -- one minute. 
    if tickA[localPlayer] and tickA[localPlayer] + one_min > getTickCount() then 
        return 
    else 
    tickA[localPlayer] = getTickCount() 
        setPlayerAFK() 
    end 
end 
addCommandHandler("afk", toggleAFK) 

Link to comment
tickA = {} 
  
function toggleAFK() 
    local one_min = 1000*60 -- one minute. 
    if tickA[localPlayer] and getTickCount()-tickA[localPlayer] < one_min then 
        return 
    else 
        tickA[localPlayer] = getTickCount() 
        setPlayerAFK() 
    end 
end 
addCommandHandler("afk", toggleAFK) 

Link to comment

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