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 11-29-2009, 05:00 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Clientside Switch

PHP Code:
//#CLIENTSIDE
function onCreated() {
}
function 
onPlayerChats() {
  if (
player.chat.starts("/")) {
    
temp.toks player.chat.tokenize();
    
temp.com player.chat.substring(1temp.toks[0].length());
    echo(
temp.com);
    switch (@
temp.com) {
      case 
"global"
        
player.chat "TELL IT ALL!";
      break;
    }
  }
  else {
    
// Local Chat
  
}
}
function 
onTimeout() {
}
/* CONFIGURATION */
public function config() {
  
// Font
  
this.msgfont "Comic Sans MS";
  
// Message Time
  
this.msgtime 5;
}
/* CONFIGURATION */ 
Am I stupid or is switch() not working for a reason?
__________________
Stan.
Reply With Quote
  #2  
Old 11-29-2009, 05:04 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
switch works fine

PHP Code:
temp.foo "bar";

switch (
foo) {
  case 
"test":
    echo(
"blah"); // you won't see this
  
break;
  
  case 
"bar":
    echo(
"hi"); // you will see this
  
break;

__________________
Reply With Quote
  #3  
Old 11-29-2009, 05:11 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Erm, Chris then explain to me why it's not working at all here. o.o

PHP Code:
function onPlayerChats() {
  
temp.toks player.chat.tokenize();
  
temp.com player.chat.substring(1temp.toks[0].length());
  echo(
temp.toks);
  echo(
temp.com);
  switch (
temp.com) {
    case 
"global":
      echo(
"boo");
    break;
    
    default:
      echo(
"bark");
    break;
  }

Is resulting to the default.
__________________
Stan.
Reply With Quote
  #4  
Old 11-29-2009, 05:12 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Ditch the @ in the switch statement.
Reply With Quote
  #5  
Old 11-29-2009, 05:14 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by DustyPorViva View Post
Ditch the @ in the switch statement.
Did that Dusty...that was just a result of me trying to figure out the problem.
__________________
Stan.
Reply With Quote
  #6  
Old 11-29-2009, 05:16 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Solved the problem.

PHP Code:
function onPlayerChats() {
  
temp.toks null;
  
temp.com null;
  
  
temp.toks player.chat.tokenize();
  
temp.com temp.toks[0].substring(1);

  switch (
temp.com) {
    case 
"global":
      echo(
"boo");
    break;
    
    default:
      echo(
"bark");
    break;
  }

__________________
Stan.
Reply With Quote
  #7  
Old 11-29-2009, 05:19 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Kyranki View Post
Erm, Chris then explain to me why it's not working at all here. o.o

PHP Code:
function onPlayerChats() {
  
temp.toks player.chat.tokenize();
  
temp.com player.chat.substring(1temp.toks[0].length());
  echo(
temp.toks);
  echo(
temp.com);
  switch (
temp.com) {
    case 
"global":
      echo(
"boo");
    break;
    
    default:
      echo(
"bark");
    break;
  }

Is resulting to the default.
Why wouldn't you just do:
PHP Code:
  temp.com temp.toks[0].substring(1);
  switch (
temp.com) {
    case 
"global":
      echo(
"hi");
      break;
  } 
Edit: Ah, see you figured it out before I posted it.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
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 09:46 PM.


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