Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Switch needed for triggerserver? (https://forums.graalonline.com/forums/showthread.php?t=134262232)

Schetti 02-26-2011 02:21 PM

Switch needed for triggerserver?
 
Do I need a switch command for triggerserver?
I tried to check the command via if-funktion, but that didn't work, can someone tell me why?
PHP Code:

function onActionserverside() 
{
   if (
params[0] == "summon")   //If instead of a switch
   
{
      
temp.pl findplayerbycommunityname(params[1]);
      if (
pl != NULL
      {
       
pl.setlevel2(player.levelplayer.xplayer.y);
       
pl.chat format(""player.account);
       
player.chat format(""pl.communityname);
      }else
    
player.chat format("Community name '%s' not found!"params[1]);
   }
}
//#CLIENTSIDE
function onPlayerChats() 
{
   if (
player.chat.starts("/summon") && player.account != NULL
   {
    
triggerserver("gui"this.name"summon"player.chat.substring(8));
   }



fowlplay4 02-26-2011 06:03 PM

Switch docu: http://forums.graalonline.com/forums...ad.php?t=76294

A switch is just a glorified stack of if statements, at a quick glance I can't really see anything wrong unless you're putting this in a level npc and not a weapon.

cbk1994 02-26-2011 07:35 PM

Your code looks correct. Try adding echoes to it to see if the trigger is being received.

Deas_Voice 02-26-2011 09:14 PM

to start with,
PHP Code:

  pl.chat format(""player.account); 
  
player.chat format(""pl.communityname); 

wont work, because you won't chat the account/communityname because there is no %s in the first parameter.
edit:
2nd, there's a space after //#CLIENTSIDE, remove that and the trigger will work.
3rd, there's no reason to have "&& player.account != NULL" since it's not possible to have no account and be a player chatting "/summon" !

Schetti 02-26-2011 09:38 PM

to 1st: useless, agreed
to 2nd: It works without space, but why? o.o' :confused:
to 3rd: useless, agreed

Deas_Voice 02-26-2011 09:57 PM

Quote:

Originally Posted by Schetti (Post 1633406)
to 1st: useless, agreed

didn't say it was useless :p

Quote:

Originally Posted by Schetti (Post 1633406)
to 2nd: It works without space, but why? o.o' :confused:

dono, but it's a common error, i believe that, if theres a space after it, it still consider it as serverisde
Quote:

Originally Posted by Schetti (Post 1633406)
to 3rd: useless, agreed

lol copy/paste


All times are GMT +2. The time now is 03:23 PM.

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