Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-05-2011, 06:39 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
Problem with guilds

Ok , my script does not work , here is :

PHP Code:
// Scripted by *Trakan
//#CLIENTSIDE
function onWeaponFired() {
say2 Ecrit /tag pour mettre le #btag de ta nation!;
}
public function 
destroy() : void {
  
temp.stack = getCallStack();
  
temp.npc = stack[stack.size()-2].scriptcallobject.name;

  echo(
"[NPC Error]: '"@ npc @"' tried to delete '"@ this.name @"'");
}
function 
onActionServerSide(cmd, tag) {
  switch (
cmd) {
    case 
"tagOn": {
      if (
tag == null) {
        break;
      }

      
player.guild = tag;
      break;
    }
  }
}
//#CLIENTSIDE
function onPlayerChats() {
  switch (
player.chat) {
    case 
"/tag": {
      
triggerserver("gui", clientr.towntagrank, name, "tagOn", clientr.towntag);
      break;
    }
  }
} 
If i say /tag , nothing...
Thank you for your future help
Reply With Quote
  #2  
Old 07-05-2011, 06:53 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
You have two //#CLIENTSIDE lines.
You are using gs1 in the onWeaponFired part.

Remove this..
Quote:
Originally Posted by Trakan View Post
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  
say2 Ecrit /tag pour mettre le #btag de ta nation!;
} 
Reply With Quote
  #3  
Old 07-05-2011, 07:03 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
Thanks , it work but
PHP Code:
triggerserver("gui", clientr.towntagrank, name, "tagOn", clientr.towntag); 
clientr.towntagrank does not work, it is not displayed to the player's name.
Reply With Quote
  #4  
Old 07-05-2011, 07:54 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Quote:
Originally Posted by Trakan View Post
Thanks , it work but
PHP Code:
triggerserver("gui", clientr.towntagrank, name, "tagOn", clientr.towntag); 
clientr.towntagrank does not work, it is not displayed to the player's name.
Looks out of syntax.
triggerserver(type, name, params)

Also it's unneccessary to send clientr. prefixed vars to the server, since it can read clientr. vars there.

Try
PHP Code:
triggerserver("gui", this.name, "tagOn"); 
Then, in your onActionServerSide function... something like this.
PHP Code:
function onActionServerSide(cmd) { 
  switch (
cmd) { 
    case 
"tagOn": { 
      
player.guild = clientr.towntag; 
      break; 
    } 
  } 
} 
Reply With Quote
  #5  
Old 07-05-2011, 08:05 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
But i can't add prefix to name?
Reply With Quote
  #6  
Old 07-05-2011, 08:57 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by Trakan View Post
But i can't add prefix to name?
name refers to the name of the object you are triggering, in this case, the weapon's name, i.e., this.name
Reply With Quote
  #7  
Old 07-05-2011, 09:07 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
Oh i ses , but how to add prefix on a name?
Reply With Quote
  #8  
Old 07-05-2011, 11:15 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Ah I get it now... You want to set a rank prefix in front of the player's name. I.e:

King, fowlplay4 (Guild)

Here's a function that would do that:

PHP Code:
function setGuildTag(guild_name, rank) {
  
player.guild = guild_name;
  if (!
player.nick.starts((rank @ ", "))) {
    
player.nick = format("%s, %s", rank, player.nick);
  }
} 
Usage:

PHP Code:
function onActionServerSide(cmd) {  
  switch (
cmd) {  
    case 
"tagOn": {  
      
setGuildTag(clientr.towntag, clientr.towntagrank);
      break;  
    }  
  }  
}

function 
setGuildTag(guild_name, rank) {
  
player.guild = guild_name;
  if (!
player.nick.starts((rank @ ", "))) {
    
player.nick = format("%s, %s", rank, player.nick);
  }
}

/* your other code */ 
__________________
Quote:

Last edited by fowlplay4; 07-05-2011 at 11:37 PM..
Reply With Quote
  #9  
Old 07-06-2011, 01:03 AM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
My flags are clientr.towntag for the Town (ex : vaxxo) and clientr.towntagrank for the player rank.
I replace guild_tag by clientr.towntag ?
What's the final script if the player say /tag , i'm confused :s
Reply With Quote
  #10  
Old 07-06-2011, 01:40 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Trakan View Post
My flags are clientr.towntag for the Town (ex : vaxxo) and clientr.towntagrank for the player rank.
I replace guild_tag by clientr.towntag ?
What's the final script if the player say /tag , i'm confused :s
Those are just function parameters. In my usage example it passes the value of your clientr flags to the function.

You may benefit from reading my scripting guide, particularly the section on functions.
fowlplay4's scripting guide: functions

I've pretty much given you the solution to your problem in my last post, you just need to piece it together now.
__________________
Quote:
Reply With Quote
  #11  
Old 07-06-2011, 11:14 AM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
Thanks it work !
(and good wiki )

Last edited by Trakan; 07-06-2011 at 11:38 AM..
Reply With Quote
  #12  
Old 07-06-2011, 01:19 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
New problem , i make a tool for king of a town , my flags does not work , if i say /add , it's say it work ! but i not got xen tag !
PHP Code:
// Scripté par Trakan :D
//#CLIENTSIDE
//Pour Xenos
if (clientr.towntag == Xen) {
 if (
clientr.towntagrank == Guerrier) {
function 
onPlayerChats() {
  switch (
player.chat) {
    case 
"/add": {
    
player.chat = "Work!";
    } else {
    
player.chat = "not work !";
    }
   }
  }
 }
} 
And else {
does not work
Reply With Quote
  #13  
Old 07-06-2011, 02:34 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
First, you never want functions to be inside any if-blocks*. The checks you did for the towntag and the townrank should be inside the function.

PHP Code:
// Scripté par Trakan :D 
//#CLIENTSIDE 
//Pour Xenos 
function onPlayerChats() {
  if (
clientr.towntag == Xen) { 
    if (
clientr.towntagrank == Guerrier) { 
      switch (
player.chat) { 
        case 
"/add": { 
          
player.chat = "Work!"; 
        } else { 
          
player.chat = "not work !"; 
        } 
      } 
    }
  }
} 
The next problem is that strings need to be inside quotations:

PHP Code:
  if (clientr.towntag == "Xen") { 
    if (
clientr.towntagrank == "Guerrier") { 
You're using the switch statement wrong. I'm going to recommend that you avoid it entirely until you have a better understanding of GScript (in this case I would advise not using it anyway). You can use a standard if statement like this:

PHP Code:
// Scripté par Trakan :D 
//#CLIENTSIDE 
//Pour Xenos 
function onPlayerChats() {
  if (
clientr.towntag == "Xen") { 
    if (
clientr.towntagrank == "Guerrier") { 
      if (
player.chat == "/add") {
        
player.chat = "Work!"; 
      } else { 
        
player.chat = "not work !"; 
      } 
    }
  }
} 
The problem now is that even though the code is correct, it's logically not right. If the player has towntag of "Xen" and towntagrank of "Guerrier" and says anything except "/add", it will make them say "not work !".

Instead, you want to change it so it checks if the player is saying "/add" before checking their tag and tagrank. I'm also combining the rank and tag check into one statement:

PHP Code:
// Scripté par Trakan :D 
//#CLIENTSIDE 
//Pour Xenos 
function onPlayerChats() {
  if (
player.chat == "/add") {
    if (
clientr.towntag == "Xen" && clientr.towntagrank == "Guerrier") {  
      
player.chat = "Work!"; 
    } else { 
      
player.chat = "not work !"; 
    }
  }
} 
If anything I said doesn't make sense, I'll be happy to explain it further.

* This doesn't apply to anonymous functions, but don't worry about them yet.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:13 PM.


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