Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-06-2007, 12:40 AM
Sum41Freeeeek Sum41Freeeeek is offline
Future Coder
Join Date: Feb 2004
Location: New York
Posts: 376
Sum41Freeeeek is on a distinguished road
Send a message via AIM to Sum41Freeeeek
Token problem

I'm making a gang system, but I'm having a small problem.
I have this in a class:

PHP Code:
function onPlayerchats()
{
  if (
player.chat.starts(":"))
  {
    
findNpc("Gang Control").leaderCommand(player.chat);
  }

and I have this in the Gang Control npc

PHP Code:
public function leaderCommand(toks)
{
  switch (
temp.toks[0])
  {
    case 
":addmember":
      
player.chat "testing";
    break;
  }

when I say :addmember alone, it switches my test to "testing" which is what I want, sort of (since I'm trying to debug it) but if I say :addmember blahwhatever, it doesn't do anything.

even if I changed it to player.chat = temp.toks[1]; , it doesn't return temp.toks[1] what am I doing wrong?

sorry if I don't explain it that well, I tried my best.
__________________
Frankie Cassini: ex-Era LAT
Quote:
Originally Posted by brakk View Post
omg just go to your room and draw a pony then

**** the chicken wings!
Reply With Quote
  #2  
Old 05-06-2007, 12:42 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Change public function leaderCommand(toks) to (cmd) or something, and then immediately after, do:
PHP Code:
temp.toks temp.cmd.tokenize(); 
Strings don't tokenize themselves; in your script, temp.toks is the full chat string, not a tokenized array from tokenize();.
__________________
Skyld
Reply With Quote
  #3  
Old 05-06-2007, 12:44 AM
Sum41Freeeeek Sum41Freeeeek is offline
Future Coder
Join Date: Feb 2004
Location: New York
Posts: 376
Sum41Freeeeek is on a distinguished road
Send a message via AIM to Sum41Freeeeek
worked, thanks.
__________________
Frankie Cassini: ex-Era LAT
Quote:
Originally Posted by brakk View Post
omg just go to your room and draw a pony then

**** the chicken wings!
Reply With Quote
  #4  
Old 05-06-2007, 12:50 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Ha ha, I was going to post something similar before Mr. Gscript ( phrase originally coined by Twinny ) came in to save the day! :P
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #5  
Old 05-06-2007, 01:41 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 Sum41Freeeeek View Post
I'm making a gang system, but I'm having a small problem.
I have this in a class:

PHP Code:
function onPlayerchats()
{
  if (
player.chat.starts(":"))
  {
    
findNpc("Gang Control").leaderCommand(player.chat);
  }

and I have this in the Gang Control npc

PHP Code:
public function leaderCommand(toks)
{
  switch (
temp.toks[0])
  {
    case 
":addmember":
      
player.chat "testing";
    break;
  }

when I say :addmember alone, it switches my test to "testing" which is what I want, sort of (since I'm trying to debug it) but if I say :addmember blahwhatever, it doesn't do anything.

even if I changed it to player.chat = temp.toks[1]; , it doesn't return temp.toks[1] what am I doing wrong?

sorry if I don't explain it that well, I tried my best.
When I use switch( var ), I find it helpful to do it like this:
PHP Code:
switch ( var )
{
  case 
"test":
  {
    
// Stuff Here
    
break;
  }
  case 
"blah":
  {
    
// More stuff here.
    
break;
  }

The braces organize it better, I think atleast.
__________________
Reply With Quote
  #6  
Old 05-06-2007, 04:28 PM
Sum41Freeeeek Sum41Freeeeek is offline
Future Coder
Join Date: Feb 2004
Location: New York
Posts: 376
Sum41Freeeeek is on a distinguished road
Send a message via AIM to Sum41Freeeeek
I agree. I usually do it like that, but someone told me I didn't really need it for functionallity(sp) so this time I didn't bracket in the case's.
__________________
Frankie Cassini: ex-Era LAT
Quote:
Originally Posted by brakk View Post
omg just go to your room and draw a pony then

**** the chicken wings!
Reply With Quote
  #7  
Old 05-06-2007, 04:32 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
One to their own.
Reply With Quote
  #8  
Old 05-06-2007, 04:43 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
PHP Code:
temp.toks player.chat.tokenize();
(@
"Gang Control").leaderCommandstemp.toks[0], temp.toks[1], temp.toks[2], temp.toks[3]);

...
public function 
leaderCommandcommandparam1param2param3 )
  {
  if ( ! 
isLeaderplayer.account ) )
    return;

  switch ( 
command )
    {
    default:
      echo( 
"Command ["command @"]: Is not recognized." );
    break;
    }
  } 
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 07:31 AM.


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