PDA

View Full Version : GS2: Serverside player.weapon[s]


Rick
03-30-2005, 10:17 AM
For some reason in GScript2 serverside, you cannot access player.weapon or player.weapons, they are undefined. Yet they are defined clientside. Is there any reason for this?

Admins
03-30-2005, 01:17 PM
Yes need to map them, also need to fix hasweapon()

Rick
03-30-2005, 02:28 PM
I also see a problem with tokenize(). You can't tokenize by newlines. (str.tokenize("\n")).

Velox Cruentus
03-31-2005, 04:47 AM
\n basically tells the NPC that a newline is there, but I believe it simply replaces it with the appropiate character (To what I beleive). It is searching for the string "\n" and not the actual new line.

While we're at it -- I'm not too sure how to do #K(x) anymore.
with command doesn't seem to work, nor is npcscount/npcs[i]. I can't seem to call a command by npcs[i].function(); (The function was public, although isn't a weapon).

Hrm.. Other problems? I'll post back if I see any.

Evil_Trunks
03-31-2005, 05:21 AM
While we're at it -- I'm not too sure how to do #K(x) anymore.
char(x)
or ascii(x) to do the opposite

with command doesn't seem to work,
with (object) {
it works for me...
nor is npcscount
npcs.size()


i don't know about anything else though


edit: i think it's getascii, not ascii? i forget which one is for gs2

Velox Cruentus
03-31-2005, 05:54 AM
char(x)
or ascii(x) to do the opposite


with (object) {
it works for me...

npcs.size()


i don't know about anything else though
Thanks -- I was using an already used variable -- That's why it didn't work.

I ended up doing:

for (n: npcs){
n.chat := "Testing";
}

;)

Rick
03-31-2005, 04:26 PM
\n basically tells the NPC that a newline is there, but I believe it simply replaces it with the appropiate character (To what I beleive). It is searching for the string "\n" and not the actual new line.

While we're at it -- I'm not too sure how to do #K(x) anymore.
with command doesn't seem to work, nor is npcscount/npcs[i]. I can't seem to call a command by npcs[i].function(); (The function was public, although isn't a weapon).

Hrm.. Other problems? I'll post back if I see any.
In theory. The string parser should be escaping \n to an actual newline before it ever gets to the function. In order to actually search for \n you'd want \\n.

_Z3phyr_
06-13-2006, 12:07 AM
So what would be the equivalent of hasweapon() in GS2? Has it been fixed yet?


function onCreated() {
if (hasweapon(Weapon_name_here)) {
// algo comentario por aqui
}
}

Btw, from what I've been doing so far, I've only noticed that player.weapons is only readable on server-side.

Here's what I tried to do in GS2 to substitute for it:


function onCreated() {
this.weaponname = Weaponnamehere;
this.weaponlist = player.weapons;
}
//#CLIENTSIDE
function onPlayertouchsme() {
if (this.weaponname in this.weaponlist) {
message("true");
removeweapon(this.weaponname);
} else { message("false"); addweapon(this.weaponname); }
}


but this doesn't work for whatever reason... so how else can I translate hasweapon() into GS2?

Btw addweapon and removeweapon don't work on either clientside or serverside with me for some reason. Am I using it wrong? I've noticed that weapons shouldn't have quotes around them unless they include a symbol or space, so I didn't put any quotes around the actual weaponame.




EDIT -- I got an answer from a friend early:

hasweapon() can be translated to if (findweapon(weaponnamehere) != null) { ... }

Rick
06-13-2006, 01:57 AM
addweapon/removeweapon only work serverside.