Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   GS2: Serverside player.weapon[s] (https://forums.graalonline.com/forums/showthread.php?t=58339)

Rick 03-30-2005 10:17 AM

GS2: Serverside player.weapon[s]
 
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

Quote:

Originally Posted by Velox Cruentus
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

Quote:

with command doesn't seem to work,
NPC Code:
with (object) {


it works for me...
Quote:

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

Quote:

Originally Posted by Evil_Trunks
char(x)
or ascii(x) to do the opposite


NPC Code:
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:
NPC Code:

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


;)

Rick 03-31-2005 04:26 PM

Quote:

Originally Posted by Velox Cruentus
\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

entao, quoi?
 
So what would be the equivalent of hasweapon() in GS2? Has it been fixed yet?

PHP Code:

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:

PHP Code:

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.


All times are GMT +2. The time now is 11:22 PM.

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