Jump to content

my script is not working


Sami_~>

Recommended Posts

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.

Link to comment
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 )

 

  • Like 1
Link to comment
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 ..

Link to comment
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

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