Bilal135 Posted May 27, 2015 Posted May 27, 2015 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) "Get busy living or get busy dying"
Walid Posted May 27, 2015 Posted May 27, 2015 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) 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
Bilal135 Posted May 27, 2015 Author Posted May 27, 2015 Now it works but when I type /afk to get back, it says "You are already AFK". "Get busy living or get busy dying"
Walid Posted May 27, 2015 Posted May 27, 2015 Now it works but when I type /afk to get back, it says "You are already AFK". it must be like this if getElementData(localPayer,"afk") == true then 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
Bilal135 Posted May 27, 2015 Author Posted May 27, 2015 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) "Get busy living or get busy dying"
Walid Posted May 27, 2015 Posted May 27, 2015 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) 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
Bilal135 Posted May 27, 2015 Author Posted May 27, 2015 Works, but how do I prevent spam of this command? For example, this command can be only used 1 time per minute. This will help to prevent abuse. "Get busy living or get busy dying"
Walid Posted May 27, 2015 Posted May 27, 2015 Works, but how do I prevent spam of this command? For example, this command can be only used 1 time per minute. This will help to prevent abuse. All what you need is setTimer isTimer 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
Enargy, Posted May 27, 2015 Posted May 27, 2015 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) - Inactivo.
Bilal135 Posted May 28, 2015 Author Posted May 28, 2015 That doesn't work Enargy... "Get busy living or get busy dying"
ALw7sH Posted May 28, 2015 Posted May 28, 2015 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)
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