Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-18-2006, 05:12 AM
Seichi Seichi is offline
Registered User
Seichi's Avatar
Join Date: Jul 2003
Location: In a house.
Posts: 7
Seichi is on a distinguished road
Classes help -.-

I dunno why, but they won't work for me. ;o For example, I create a class test. Inside test, I have:
//#CLIENTSIDE
public function sayHi() {
player.chat = "hi!";
}

And in a weapon testweapon I have:

//#CLIENTSIDE
function onCreated() {
join("test");
}
function onWeaponFired() {
sayHi();
}

What am I doing wrong?
__________________
i ned halp plx ;3
Reply With Quote
  #2  
Old 04-18-2006, 05:20 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
I think you need to join the class directly to the player via:
player.join("test");

and then run it via player.sayHi();

That should work.

http://wiki.graal.us/Using_Classes_Effectively
Reply With Quote
  #3  
Old 04-18-2006, 05:25 AM
Seichi Seichi is offline
Registered User
Seichi's Avatar
Join Date: Jul 2003
Location: In a house.
Posts: 7
Seichi is on a distinguished road
Yeah, I read that whole document and I tried it but it still didn't work...
__________________
i ned halp plx ;3
Reply With Quote
  #4  
Old 04-18-2006, 05:43 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
You need to use join serverside.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 04-18-2006, 05:50 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Ahh, yeah, you can only join to a player via serverside. I usually make 1 class called playerfunctions, then join it to the player on the server start, and it all works fine, and perfect, and saves me a ton of time and lines in my code :-)
Reply With Quote
  #6  
Old 04-18-2006, 05:51 AM
Seichi Seichi is offline
Registered User
Seichi's Avatar
Join Date: Jul 2003
Location: In a house.
Posts: 7
Seichi is on a distinguished road
I tried that too, it doesn't seem to work.
__________________
i ned halp plx ;3
Reply With Quote
  #7  
Old 04-18-2006, 06:07 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Seichi
I tried that too, it doesn't seem to work.
Class: test
PHP Code:
//#CLIENTSIDE
function sayHi() {
  
player.chat "Hi";

Weapon:
PHP Code:
join("test");
//#CLIENTSIDE
function onWeaponFired() {
  
sayHi();


This should work. If you want an example using a player joined class, feel free to ask.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #8  
Old 04-18-2006, 06:15 AM
Seichi Seichi is offline
Registered User
Seichi's Avatar
Join Date: Jul 2003
Location: In a house.
Posts: 7
Seichi is on a distinguished road
Didn't work....but I don't think you can just have join(); floating out there, can you? :P I guess now would be a good time to ask for an example....but I'm trying to use a class with a weapon. Off topic a bit, but how do I set flags in GS2? I noticed that there are flags when you look in the /open account name, like clientr.whatever = whatever; In my scripts I use clientr, but they never appear in the script flags underp player attributes.
__________________
i ned halp plx ;3
Reply With Quote
  #9  
Old 04-18-2006, 06:32 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Seichi
Didn't work....but I don't think you can just have join(); floating out there, can you? :P I guess now would be a good time to ask for an example....but I'm trying to use a class with a weapon. Off topic a bit, but how do I set flags in GS2? I noticed that there are flags when you look in the /open account name, like clientr.whatever = whatever; In my scripts I use clientr, but they never appear in the script flags underp player attributes.
The classe example should be working... Just tested it to make sure. Are you sure that in the join part, you have the name of the right class there?

And for your next question, clientr. flags should be set serverside.

FYI:
client. flags can be set and read both serverside and clientside.
-If it doesn't need to be secure, then it's OK to make it a client. flag.

clientr. flags can only be set serverside, but read both serverside and clientside.
-If it needs to be secure, only use a clientr. flag.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #10  
Old 04-18-2006, 06:41 AM
Seichi Seichi is offline
Registered User
Seichi's Avatar
Join Date: Jul 2003
Location: In a house.
Posts: 7
Seichi is on a distinguished road
Thanks, I got the flags now. Yeah, I made sure that the classname is correct, it doesn't work.
__________________
i ned halp plx ;3
Reply With Quote
  #11  
Old 04-18-2006, 07:15 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Zzz.. Look at some of my scripts, you silly goose.

You're joining them to a weapon, so you don't want to be using public functions.

To the people above, you can join classes to NPCweapons in the clientside.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("test");
}

function 
onWeaponFired() {
  
sayHi();

Reply With Quote
  #12  
Old 04-18-2006, 07:51 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
For one reason or another, I was told that it is best to have join serverside, and not inside any kind of event block.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #13  
Old 04-18-2006, 07:52 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by napo_p2p
For one reason or another, I was told that it is best to have join serverside, and not inside any kind of event block.
O-o
I don't see why.. I've had no problems.
Reply With Quote
  #14  
Old 04-19-2006, 04:19 AM
Seichi Seichi is offline
Registered User
Seichi's Avatar
Join Date: Jul 2003
Location: In a house.
Posts: 7
Seichi is on a distinguished road
I did look at your scripts Yen, and I did everything you did but it didn't work. It works when I create a new class and NPC, but when I do the same thing with a real weapon and a real class, it doesn't work, telling me it can't find the function in the weapon.
__________________
i ned halp plx ;3

Last edited by Seichi; 04-19-2006 at 06:41 AM..
Reply With Quote
  #15  
Old 04-19-2006, 05:15 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen

I'll check it out when you get home.
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 10:51 PM.


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