Sami_~> Posted September 11, 2017 Posted September 11, 2017 afkmads = {} addEventHandler("onPlayerDamage", root, function(attacker, weapon, bodypart, hp) if afkmads[source] then setElementHealth(source, getElementHealth(source)+hp) end end ) addCommandHandler("afk", function(sot) if getPlayerWantedLevel(sot) > 0 then return outputChatBox("You Can't Go AFK! You Have A Wanted Level!", sot, 255, 0, 0) end afkmads[sot] = true setElementFrozen(sot, true) toggleAllControls(sot, false, true, false) setElementAlpha(sot, 120) addEvent("god_mode",true) setPlayerNametagShowing(sot, false) outputChatBox (""..getPlayerName(player).." #FF0000 IS AFK! You Can't Play With That Player.",root,255,255,255,true) end ) else function(sot) setElementFrozen(sot, false) toggleAllControls(sot, true) setElementAlpha(sot, 255) addEvent("god_mode",false) afkmads[sot] = nil setPlayerNametagShowing(sot, false) outputChatBox (""..getPlayerName(player).." #FF0000 IS NOT AFK! You Can Play With That Player.",root,255,255,255,true) end ) Why this is not working when i type /afk.
Rockyz Posted September 11, 2017 Posted September 11, 2017 afkmads = { }; addEventHandler ( "onPlayerDamage", root, function ( attacker, weapon, bodypart, hp ) if ( afkmads [ source ] ) then setElementHealth ( source, getElementHealth ( source ) + hp ) end end ) addCommandHandler ( "afk", function ( sot ) if ( getPlayerWantedLevel ( sot ) > 0 ) then return outputChatBox ( "You Can't Go AFK! You Have A Wanted Level!", sot, 255, 0, 0 ) end afkmads [ sot ] = not afkmads [ sot ] setElementFrozen ( sot, afkmads [ sot ] ) toggleAllControls ( sot, afkmads [ sot ], afkmads [ sot ], afkmads [ sot ] ) setElementAlpha ( sot, ( afkmads [ sot ] and 120 or 255 ) ) setPlayerNametagShowing ( sot, not afkmads [ sot ] ) outputChatBox ( getPlayerName ( sot ) .. " #FF0000 IS " .. ( afkmads [ sot ] and '' or 'NOT' ) .. " AFK! You Can" .. ( afkmads [ sot ] and '' or "'t" ) .. " Play With That Player Now.", root, 255, 255, 255, true ) end ) 1
Sami_~> Posted September 12, 2017 Author Posted September 12, 2017 (edited) thank u soo much bro. but here is problem in output chat box when player is afk it is showing player in not afk and when player is not afk it is showing player is afk. Edited September 12, 2017 by Sami_~>
iMr.WiFi..! Posted September 12, 2017 Posted September 12, 2017 afkmads = { }; addEventHandler ( "onPlayerDamage", root, function ( attacker, weapon, bodypart, hp ) if ( afkmads [ source ] ) then setElementHealth ( source, getElementHealth ( source ) + hp ) end end ) addCommandHandler ( "afk", function ( sot ) if ( getPlayerWantedLevel ( sot ) > 0 ) then return outputChatBox ( "You Can't Go AFK! You Have A Wanted Level!", sot, 255, 0, 0 ) end afkmads [ sot ] = getElementType ( afkmads [ sot ] ) == "player" and false or afkmads [ sot ] setElementFrozen ( sot, afkmads [ sot ] ) toggleAllControls ( sot, afkmads [ sot ], afkmads [ sot ], afkmads [ sot ] ) setElementAlpha ( sot, ( afkmads [ sot ] and 120 or 255 ) ) setPlayerNametagShowing ( sot, not afkmads [ sot ] ) outputChatBox ( getPlayerName ( sot ) .. " #FF0000 IS " .. ( afkmads [ sot ] and '' or 'NOT' ) .. " AFK! You Can" .. ( afkmads [ sot ] and '' or "'t" ) .. " Play With That Player Now.", root, 255, 255, 255, true ) end ) Try it ..
Rockyz Posted September 12, 2017 Posted September 12, 2017 8 hours ago, Sami_~> said: thank u soo much bro. but here is problem in output chat box when player is afk it is showing player in not afk and when player is not afk it is showing player is afk. Weird. i tried it and its working perfectly. 4 hours ago, iMr.WiFi..! said: afkmads = { }; addEventHandler ( "onPlayerDamage", root, function ( attacker, weapon, bodypart, hp ) if ( afkmads [ source ] ) then setElementHealth ( source, getElementHealth ( source ) + hp ) end end ) addCommandHandler ( "afk", function ( sot ) if ( getPlayerWantedLevel ( sot ) > 0 ) then return outputChatBox ( "You Can't Go AFK! You Have A Wanted Level!", sot, 255, 0, 0 ) end afkmads [ sot ] = getElementType ( afkmads [ sot ] ) == "player" and false or afkmads [ sot ] setElementFrozen ( sot, afkmads [ sot ] ) toggleAllControls ( sot, afkmads [ sot ], afkmads [ sot ], afkmads [ sot ] ) setElementAlpha ( sot, ( afkmads [ sot ] and 120 or 255 ) ) setPlayerNametagShowing ( sot, not afkmads [ sot ] ) outputChatBox ( getPlayerName ( sot ) .. " #FF0000 IS " .. ( afkmads [ sot ] and '' or 'NOT' ) .. " AFK! You Can" .. ( afkmads [ sot ] and '' or "'t" ) .. " Play With That Player Now.", root, 255, 255, 255, true ) end ) Try it .. line 13 is wrong
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