PDA

View Full Version : Player Commands


xAndrewx
11-26-2006, 12:12 PM
Basically, I made a set of functions for a system. Anything the player says will go through this NPC.

This is the class:

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:

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,'