Thread: Token problem
View Single Post
  #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