Jump to content

AFK Command with sound


Recommended Posts

Okay i wanne make an command: /afk and that it then says in the chat: Player Your Away From Your KeyBoard Move Or Get Kicked! and that it also sends an sound to the client like an blip or something now ive seen this code on the wiki:

  
function onPlayerSpawn ( theSpawnpoint, theTeam ) 
  
    playSoundFrontEnd ( source, 16 ) 
end 
addEventHandler ( "onPlayerSpawn", getElementRoot(), onPlayerSpawn ) 
  

That sends an sound to an player when he spawns but can this be modified to work with my afk command?

If someone knows that would be asoum becuase then ive got an command that sends an sound to the player and he knows to come back to the game :D

Greatings, Thanks

Frank

Link to comment

You need to make a command handler for the "afk" command.

  
function onAFKCommand ( commandPlayer, commandName, argument1 ) 
    -- Get the player with the specified nick 
    local thePlayer = getPlayerFromNick ( argument1 ) 
  
    -- Tell him that and play him the sound 
    outputChatBox ( "Get back or ...", thePlayer ) 
    playSoundFrontEnd ( thePlayer, 43 ) 
end 
  
addCommandHandler ( "afk", onAFKCommand ) 
  

You might to assign each player a three digit ID though that you put in the scoreboard and allow the command to use that instead, because typing the name case-sensitive can be a bitch with long nicknames, clan tags etc... Or make a clientside guy that allows you to select the player and click the "AFK" button and it automatically runs that command.

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