Thread: Player Commands
View Single Post
  #1  
Old 11-26-2006, 12:12 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Player Commands

Basically, I made a set of functions for a system. Anything the player says will go through this NPC.

This is the class:
HTML Code:
function displayHelp()
{
  sendrpgmessage("Help Functions :-");
  sendrpgmessage(" Random Functions :-");
  sendrpgmessage("   /sit                   :- Makes the player sit");
  sendrpgmessage("   /sleep                 :- Makes the player sleep");
  sendrpgmessage("   /die                   :- Makes the player die");
  
  player.chat = "Read your console log! (F2)";
}

function doAction(newGani)
{
  if (player.freezesecs > 0)
  {
    return false;
  }
  if ((timevar2 - this.lastAction) in |0, 0.2|)
  {
    return false;
  }
  this.lastAction = timevar2;
  player.setAni(temp.newGani, "");
  player.freezePlayer(0.15);
}
This is the weapon:
HTML Code:
function onActionServerside(curOption)
{
  temp.currentChat = temp.curOption.tokenize();
  temp.currentOption = temp.currentChat[0];
  temp.currentAssign = temp.currentChat[1];
 
  switch(temp.currentOption)
  {
    case "help":
      newplayer_chat::displayHelp();
    break;
    
    case "sit":
    case "sleep":
    case "die":
      temp.curGani = (temp.currentOption == "die"?
                      "dead": temp.currentOption);
      newplayer_chat::doAction(temp.curGani);
    break;    
  }  
}
this.join("newplayer_chat");

//#CLIENTSIDE
function onPlayerChats()
{
  if (client.disabled.index("chat") > -1)
  {
    player.chat = " ";
    return false;
  }
  if (player.chat.starts("/"))
  {
    triggerserver("weapon", this.name, player.chat.substring(1));
  }
    else
  {
    return false;
  }
  player.chat = "";
}
To disable the player's chat, simply add this in to the player's attributes
'client.disabled=chat,'
__________________
Reply With Quote