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 02-12-2005, 06:56 AM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
GScript2 Questions

1. I can't do this for some reason
PHP Code:
colors player.colors
both are arrays
i can do this, however
PHP Code:
this.array = colors
the array of NPC colors is copied to this.array

2. hasweapon, it does not work for me (using old gscript serverside)
and i can't figure out what the correct substitution is for this

3. addstring, I can't get this to work with gscript2
PHP Code:
addstring(this.list,"test");
message(this.list); 
the message shows 0

4. could someone explain getstring()?
edit: nevermind this one
__________________


Last edited by Evil_Trunks; 02-12-2005 at 06:43 PM..
Reply With Quote
  #2  
Old 02-12-2005, 09:39 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Evil_Trunks
1. I can't do this for some reason
PHP Code:
colors player.colors
perhaps something like:
NPC Code:
for(i=0;i<player.colors.size();i++) {
colors[i] = player.colors[i];
}


or something might work


Quote:
Originally Posted by Evil_Trunks
3. addstring, I can't get this to work with gscript2
PHP Code:
addstring(this.list,"test");
message(this.list); 
the message shows 0
the correct syntax is:
NPC Code:
this.list.add("test");
message(this.list);

__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 02-12-2005, 10:09 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by ApothiX
perhaps something like:
NPC Code:
for(i=0;i<player.colors.size();i++) {
colors[i] = player.colors[i];
}


or something might work
You don't need to calculate the size each pass through the loop, you know.
Reply With Quote
  #4  
Old 02-12-2005, 10:20 AM
Arkan1k Arkan1k is offline
Delph
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 35
Arkan1k is on a distinguished road
Send a message via AIM to Arkan1k Send a message via MSN to Arkan1k
You could probably just do this:
NPC Code:
i = 0;
for (colour: player.colors) {
colours[i] = colour;
i++;
}

__________________
[ Delph ]
Reply With Quote
  #5  
Old 02-12-2005, 07:09 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Lance
You don't need to calculate the size each pass through the loop, you know.
It was an example, I wasn't going for efficiency as much as method.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #6  
Old 02-13-2005, 03:50 PM
Malinko Malinko is offline
Unholy Nation
Join Date: Mar 2004
Location: Massachusetts, U.S.A.
Posts: 1,782
Malinko is on a distinguished road
Send a message via AIM to Malinko
Quote:
Originally Posted by ApothiX
It was an example, I wasn't going for efficiency as much as method.
I would figure you want to show someone an example in the most efficient way? You know, so they get the point in the better way.
Reply With Quote
  #7  
Old 02-13-2005, 08:56 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Malinko
I would figure you want to show someone an example in the most efficient way? You know, so they get the point in the better way.
I'm not here to write the best code for people. I gave them a method of doing it, if they want to improve it and make it more efficient, that's up to them.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #8  
Old 02-13-2005, 04:31 AM
ChibiChibiLuc ChibiChibiLuc is offline
Cookie Monster. :3
Join Date: Jan 2005
Location: Nova Scotia, Canada
Posts: 111
ChibiChibiLuc is on a distinguished road
Send a message via AIM to ChibiChibiLuc Send a message via MSN to ChibiChibiLuc
Quote:
Originally Posted by Evil_Trunks
2. hasweapon, it does not work for me (using old gscript serverside) and i can't figure out what the correct substitution is for this
There's no substitute for hasweapon. =(
Reply With Quote
  #9  
Old 02-13-2005, 05:39 AM
Arkan1k Arkan1k is offline
Delph
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 35
Arkan1k is on a distinguished road
Send a message via AIM to Arkan1k Send a message via MSN to Arkan1k
findweapon(str) - returns object

I'd presume you'd do something like:
NPC Code:
if (findweapon(weaponname) == true) {
doStuff();
}



I haven't had a play with it, but I'd say from the name of the command it would probably be the substitute, or close to, for hasweapon(str);
__________________
[ Delph ]
Reply With Quote
  #10  
Old 02-13-2005, 05:55 AM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
Quote:
Originally Posted by Arkan1k
findweapon(str) - returns object

I'd presume you'd do something like:
NPC Code:
if (findweapon(weaponname) == true) {
doStuff();
}



I haven't had a play with it, but I'd say from the name of the command it would probably be the substitute, or close to, for hasweapon(str);
That gives an object link to the weapon, but I think that you can get a link to a weapon you do not possess?


also, i am trying to do something like this:
something = "text" @ var;
but if var is 1, i dont want it to set to text1, i want it to give me the value of text1

if someone could help me out with that i'd appreciate it x.x
__________________


Last edited by Evil_Trunks; 02-13-2005 at 10:04 AM..
Reply With Quote
  #11  
Old 02-13-2005, 06:11 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
If you can't find a substitute for hasweapon(), you could always script your own.

This should work:
PHP Code:
function PlayerHasWeapon(weaponname) {
  for(
wweapons) {
    if(
w.name == weaponname) {
      return 
true;
    }
  }

  return 
false;

That might not be the best way to do it, but it will work. (I'm not sure, if you can use something like weapons.name.index(weaponname) or not)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #12  
Old 02-13-2005, 06:08 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
I don't have gscript2 on the server I work on, but I would try:

PHP Code:
if (findweapon(namein weapons){
  
// blah

Reply With Quote
  #13  
Old 02-13-2005, 10:03 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Am I correct in saying that instead of using something like:
NPC Code:
player.chat = "Account #s(this.string1) was kicked";


I would use:
NPC Code:
player.chat = "Account" @ this.string1 @ "was kicked";


I'm confused about that, because I want a deffinate way of identifying what the stringname is from the rest of the words.

I hope this makes sense.
__________________
Reply With Quote
  #14  
Old 02-13-2005, 10:17 PM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
Quote:
Originally Posted by Inverness
Am I correct in saying that instead of using something like:
NPC Code:
player.chat = "Account #s(this.string1) was kicked";


I would use:
NPC Code:
player.chat = "Account" @ this.string1 @ "was kicked";


I'm confused about that, because I want a deffinate way of identifying what the stringname is from the rest of the words.

I hope this makes sense.
you're definitely right
message codes are outdated and shouldnt be used anymore

although you forgot the space
NPC Code:
player.chat = "Account " @ this.string1 @ " was kicked";

__________________

Reply With Quote
  #15  
Old 02-13-2005, 10:40 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Hmm, So I would do:
NPC Code:
player.chat = "Account " @ this.string1 @ " was kicked";


instead of:
NPC Code:
player.chat = "Account "@this.string1@" was kicked";



because it appears to have to many spaces in the first one, why is that? >.<
__________________
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 10:38 AM.


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