Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-29-2007, 06:42 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
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
__________________
Reply With Quote
  #2  
Old 05-31-2007, 01:36 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #3  
Old 05-31-2007, 10:38 AM
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
They're just examples of how it functions.
__________________
Reply With Quote
  #4  
Old 05-31-2007, 12:36 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xAndrewx View Post
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 );

__________________
Reply With Quote
  #5  
Old 05-31-2007, 04:00 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
No, as in it can also be a command line...
__________________
Reply With Quote
  #6  
Old 06-01-2007, 04:07 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by cbkbud View Post
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?
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:28 PM.


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