Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Not adding or removing from guild (https://forums.graalonline.com/forums/showthread.php?t=134256497)

sssssssssss 10-15-2009 08:52 PM

Not adding or removing from guild
 
So, im trying to make it where you can add staffs clientr.var, wep, and tag all in one move, like many have done before. Dont quit see what im doing wrong. Please. :)

PHP Code:

function onActionServerSide(params) {
  
// Summons Player to You
  
if (params[0] == "summon") {
    
// Adjusts the Players Level, X, Y
    
findplayer(params[1]).setlevel2(player.levelplayer.xplayer.y);
    
// Adjusts Players Chat 
    
findplayer(params[1]).chat "Summoned by" SPC player.account;
  } 
  if (
params[0] == "addstaff") {
    
//sets the clientr.staff to yes
    
findplayer(params[1]).clientr.staff "yes";
    
//gives the staff weapon
    
findplayer(params[1]).addWeapon("StaffTool");
    
//puts them in the staff guild
    
addguildmember(params[2], params[1], params[3]);
  }
  if (
params[0] == "removestaff") {
    
//sets the clientr.staff to no
    
findplayer(params[1]).clientr.staff "no";
    
//removes the staff weapon
    
findplayer(params[1]).removeWeapon("StaffTool");
    
//takes them out of the staff guild
    
removeguildmember(params[2], params[1]);
  }
  if (
params[0] == "settag"){
    
getguildnick(params[1], player.account);
  }
   
}

//Custom staff boots system
//By: Gambet
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onPlayerChats() {
// say /addstaff accountname position nickname
  
if (player.chat.starts("/addstaff")){
   if (
player.account == "sssssssssss" || player.account == "Decus_Arillias"){
    
// Gets acct from "/addstaff acct"
    
temp.toAdd player.chat.substring("/addstaff ".length());
    
// Sends Trigger to Server
    
triggerserver("gui"this.name"addstaff"temp.toAdd);
    }
   }
//say /removestaff accountname position
  
if (player.chat.starts("/removestaff")){
   if (
player.account == "sssssssssss" || player.account == "Decus_Arillias"){
    
// Gets acct from "/removestaff acct"
    
temp.toRem player.chat.substring("/removestaff ".length());
    
// Sends Trigger to Server
    
triggerserver("gui"this.name"removestaff"temp.toRem);
    }
   }
  if (
player.chat.starts("/summon")) {
   if (
clientr.staff == "yes"){
    
// Gets acct from "/summon acct"
    
temp.toSummon player.chat.substring("/summon ".length());
    
// Sends Trigger to Server
    
triggerserver("gui"this.name"summon"toSummon);
   }
  }
//say /settag position
  
if (player.chat == "/settag"){
   if (
clientr.staff == "yes"){
     
triggerserver("gui"this.name"settag"toTag);
    
   }
  }

function 
onKeyPressed(code,key)
{
if (
clientr.staff == "yes"){
 if (
key == "z")
  {
   if (
this.staff_boots == "on")
    {
      
this.staff_boots this.speed "";
      
player.chat "Staff Boots -Off-";
      
setTimer(0);
    } else
     {
       
this.staff_boots "on";
       
player.chat "Staff Boots -On-";
       
setTimer(0.05);
     }
  }
 if (
code == 187)
  {
   if (
this.speed+<= 10)
    {
     
this.speed+=1;
     
player.chat "Speed: " this.speed;
    }
  } else if (
code == 189)
   {
    if (
this.speed->= 0)
     {
      
this.speed-=1;
      
player.chat "Speed: " this.speed;
     }
   }
 }
}

function 
onTimeOut()
{
 if (
this.staff_boots == "on")
  {
   for (
a=0a<4a++)
    {
     if (
keydown(a))
      {
       switch(
a)
        {
          case 
"0":
           
player.y-=this.speed;
           break;
          case 
"1":
           
player.x-=this.speed;
           break;
          case 
"2":
           
player.y+=this.speed;
           break;
          case 
"3":
           
player.x+=this.speed;
           break;
        }
      }
    }
  }
 
setTimer(0.05);



Deas_Voice 10-15-2009 09:06 PM

function onActionServerSide(params) {
ex: triggerserver("gui",name,{foo,bar,leb }, baroo);

so, params[0] is the first in a array, would be foo.
params[1] would be bar, not baroo.

(this is just thoughts, i haven't tested it,)

Pelikano 10-15-2009 09:17 PM

PHP Code:

addguildmember(params[2], params[1], params[3]); 


params[2] and params[3] don't even exist, do they? Since you're only sending:

PHP Code:

triggerserver("gui"this.name"addstaff"temp.toAdd); 


Crow 10-15-2009 09:35 PM

An off-topic suggestion, if you feel the need to add a comment for almost every line of code, you should put the comment behind the line, not above it. Increases readability.

sssssssssss 10-15-2009 09:46 PM

i put {"addstaff", temp.toAdd}

but still nothing. Trying to send everything said after the /addstaff, because of the way it sets.

Sage_Shadowbane 10-15-2009 10:02 PM

How do you expect it to add/remove when you're using undefined parameters? You haven't defined params[2/3] within your add/remove functions, only params[1].

sssssssssss 10-15-2009 10:04 PM

Ok, i just did
PHP Code:

 if (player.account == "sssssssssss" || player.account == "Decus_Arillias"){ 
  if (
player.chat.starts("/addstaff")){
     
// Gets acct from "/addstaff acct"
    
temp.toAdd player.chat.substring("/addstaff ".length());
    
temp.acctgo player.chat.tokenize()[1];
    
temp.postgo player.chat.tokenize()[2];
    
temp.nickgo player.chat.tokenize()[3];
    
// Sends Trigger to Server
    
triggerserver("gui"this.name"addstaff"acctgopostgonickgo);
  } 
 } 

instead, now setting the tag, i have this

PHP Code:

  if (player.chat == "/settag"){
   if (
clientr.staff == "yes"){
     
triggerserver("gui"this.name"settag"player.account);
    
   }
  } 

and serverside is

PHP Code:

  if (params[0] == "settag"){
    
getguildnick(params[1], player.account);
  } 

thats not working either.

Switch 10-16-2009 01:24 AM

No point making param[0] into params (which does not make the other params as params[#]). Get rid of the s in params, it's param.
Quote:

Originally Posted by Sage_Shadowbane (Post 1530693)
How do you expect it to add/remove when you're using undefined parameters? You haven't defined params[2/3] within your add/remove functions, only params[1].

[0]

Pelikano 10-16-2009 03:20 PM

Quote:

Originally Posted by Switch (Post 1530746)
No point making param[0] into params (which does not make the other params as params[#]). Get rid of the s in params, it's param.

[0]

If he likes it that way.... ;)

Sage_Shadowbane 10-16-2009 08:49 PM

Quote:

Originally Posted by Switch (Post 1530746)
No point making param[0] into params (which does not make the other params as params[#]). Get rid of the s in params, it's param.

[0]

Actually there isn't really any difference, they both work. I actually prefer to use params as its defining parameter"s" (Meaning more than one?) And uhh, what about [0]?

Deas_Voice 10-16-2009 08:54 PM

you should rename the "params" to something else, due there is a default thing called "params" (or was it "param" :oo:)
i'm not sure it's the problem but it's worth a shot, right?

Pelikano 10-16-2009 08:56 PM

That's not the problem.

sssssssssss 10-16-2009 11:18 PM

No its not the problem, and I do prefer it the way it is. I have it working for the /addstaff and /removestaff now. Like i said, its only the /settag part that isnt working.

Crow 10-16-2009 11:37 PM

Well, on the serverside, you got:
PHP Code:

if (params[0] == "settag"){ 
  
getguildnick(params[1], player.account); 


I suppose getguildnick() takes the guild and the account as arguments (can't look it up, wiki's down >_<), but you currently pass the account to it twice, since in the case of /settag, params[1] is the account (you are passing it to the serverside in your trigger). Also, the function does not set the nick of the player, I'm quite sure about that. So you will have to do something like this:
PHP Code:

temp.nick getguildnick(temp.guildplayer.account);
findPlayer(player.account).nick temp.nick SPC "(" temp.guild ")"


sssssssssss 10-17-2009 12:07 AM

I got it to set to (StaffTag), but no nick in there with:

serverside in the trigger
PHP Code:

  if (params[0] == "settag"){
    
temp.post clientr.spost;
    
temp.getnick getguildnick(params[1], player.account);
    
findPlayer(player.account).nick temp.getnick SPC "(" temp.post ")";  
  } 

clientside
PHP Code:

  if (player.chat == "/settag"){
   if (
clientr.staff == "yes"){
     
triggerserver("gui"this.name"settag");
    
   }
  } 

so its pulling the guild and account but not setting the nick in the guild that is set in there.

also, since graal.net is down, what is SPC exactly, what's it mean, and what's it used for?

also, any ideas on how to add the nick in?

Pelikano 10-17-2009 12:16 AM

PHP Code:

" " 

is the same as

PHP Code:

SPC 


Crow 10-17-2009 12:27 AM

Quote:

Originally Posted by Pelikano (Post 1531066)
PHP Code:

" " 

is the same as

PHP Code:

SPC 


Or:
SPC is, just like @, a concatenation operator. Instead of just appending the preceding string to the following string though, it adds a space inbetween.

Pelikano 10-17-2009 12:28 AM

Quote:

Originally Posted by Crow (Post 1531068)
Or:
SPC is, just like @, a concatenation operator. Instead of just appending the preceding string to the following string though, it adds a space inbetween.

GS2 > English

:D

sssssssssss 10-17-2009 12:32 AM

oh, makes sense. TY.

Any idea on the reason the code isn't pulling the name out of the guild.txt, and only setting the tag?

Crow 10-17-2009 12:36 AM

Quote:

Originally Posted by sssssssssss (Post 1531071)
oh, makes sense. TY.

Any idea on the reason the code isn't pulling the name out of the guild.txt, and only setting the tag?

Because, as far as I can see it, params[1] still doesn't contain the name of the guild.

sssssssssss 10-17-2009 12:54 AM

I forgot to change it, my bad. Thanks lol!


All times are GMT +2. The time now is 08:01 AM.

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