Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Chat functions (https://forums.graalonline.com/forums/showthread.php?t=74271)

xAndrewx 05-29-2007 06:42 PM

Chat functions
 
HTML Code:

function onActionServerside(playersChat)
{
  temp.chatTokens = temp.playersChat.tokenize();
  switch(temp.chatTokens[0])
  {
    case "help":
      player.displayHelp();
    return true;
   
    case "summon":
      findplayer(temp.playersChat.substring(7)).setlevel2(player.level.name, player.x, player.y);
    return true;
   
    case "addItem":
      player.addItem(temp.chatTokens[1], temp.chatTokens[2]);
    break;
   
    case "removeItem":
      player.removeItem(temp.chatTokens[1], temp.chatTokens[2]);
    break;
   
    case "gani":
      setani(temp.playersChat.substring(4), "");
    break;
   
    case "clear":
      //Place holder [-systemMessages]
    break;
   
    default:
      temp.displayMessage = "No such command...";
    break;
  }
  if (temp.displayMessage)
  {
    player.addMessage("No such command!", "-system");
  }
}

//#CLIENTSIDE
function onPlayerChats()
{
  if (!disableChat)
  {
    if (player.chat.starts("/"))
    {
      triggerserver("weapon", this.name, player.chat.substring(1));
      player.chat = " ";
    }
  }
  else
  {
    player.chat = " ";
  }
}

Here's a basic chat function thing

cbk1994 05-31-2007 01:36 AM

Looks like there are a few things that may only work on a certain server ...

addItem, removeItem, disableChat.

Personally, I'd make an array of commands so if someone says /OMGHEHELOLSAKGJHAKSJGHSKDGJHSKDJGHSKGLJHSGJKSGH it wouldn't trigger.

xAndrewx 05-31-2007 10:38 AM

They're just examples of how it functions.

cbk1994 05-31-2007 12:36 PM

Quote:

Originally Posted by xAndrewx (Post 1313717)
They're just examples of how it functions.

So all it is is a frame for a trigger? You could just do:

PHP Code:

function onActionServerSidecmdtokens )
{
  switch ( 
cmd )
  {
    case 
"test":
    {
       
// FOO
       
break;
    }
  }
}
//#CLIENTSIDE
function onPlayerChats()
{
  if ( ! 
player.chat.starts"/" ) )
  {
    return 
false;
  }
  
tokens player.chat.tokenize();
  
triggerServer"gui"nametokens );



xAndrewx 05-31-2007 04:00 PM

No, as in it can also be a command line...

Kristi 06-01-2007 04:07 PM

Quote:

Originally Posted by cbkbud (Post 1313733)
So all it is is a frame for a trigger? You could just do:

PHP Code:

function onActionServerSidecmdtokens )
{
  switch ( 
cmd )
  {
    case 
"test":
    {
       
// FOO
       
break;
    }
  }
}
//#CLIENTSIDE
function onPlayerChats()
{
  if ( ! 
player.chat.starts"/" ) )
  {
    return 
false;
  }
  
tokens player.chat.tokenize();
  
triggerServer"gui"nametokens );



He COULD have done that, or he could have provided his example, which provides a more hands on experience for the learning scripter. With his example, someone can go OH THATS WHY YOU WOULD DO THAT, whereas with yours, someone might miss the reason entirely.

There was really nothing wrong with what he proposed, and it seems like everytime I come to the scripting forum, every thread leads into an argument to boast/destroy e-pride. Play nice k?


All times are GMT +2. The time now is 03:52 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.