Author Topic: commands help  (Read 553 times)

Okay so I am working on a script(for my server) but am clueless on what to do next.

for example it has
Code: [Select]
function servercmdeat(%client)
{
    messageClient(%Client, '', 'you have not chosen a food please type /eathelp for a list of foods,%Client.name);
    return;
}
Can someone post a code that would be like someone types /eat pizza and it will say to the server Blockhead has eaten a slice of pizza?

Code: (Example) [Select]
1 -   function servercmdeat(%client,%object)
      {
2 -     switch(%object)
3 -        {
4 -     case "pizza":
5 -      messageAll('','\c3%1\c5 has eaten a slice of pizza.',%client.name);
         //perhaps do other things e.g. restore health
6 -     default:
7 -      messageClient(%client,'','\c3%1\c5 isn't one of the available food types. Type \c3/eathelp\c5 for a list of food.',%object);
       }
      }
1 - %object is set to the first word of whatever the client types
2 - A switch statement can be used to check a variable against several different 'cases'.
3 - The switch statement is contained in a 'block' of code in these braces. { }
4 - This part will be called if they use "/eat pizza". Add other 'cases' for different food types.
5 - This will message everyone in the server with that. %1 is in yellow (due to the \cX colours) is replaced with the client's name.
6 - This will be called if they say anything which isn't in a case.
7 - This messages the client with an error. %1 is replaced with the what they typed.
« Last Edit: January 23, 2009, 11:42:16 AM by Space Guy »