Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Classes help -.- (https://forums.graalonline.com/forums/showthread.php?t=65473)

Seichi 04-18-2006 05:12 AM

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? :(

KuJi 04-18-2006 05:20 AM

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

Seichi 04-18-2006 05:25 AM

Yeah, I read that whole document and I tried it but it still didn't work...

napo_p2p 04-18-2006 05:43 AM

You need to use join serverside.

KuJi 04-18-2006 05:50 AM

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 :-)

Seichi 04-18-2006 05:51 AM

I tried that too, it doesn't seem to work.

napo_p2p 04-18-2006 06:07 AM

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.

Seichi 04-18-2006 06:15 AM

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.

napo_p2p 04-18-2006 06:32 AM

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.

Seichi 04-18-2006 06:41 AM

Thanks, I got the flags now. Yeah, I made sure that the classname is correct, it doesn't work.

Yen 04-18-2006 07:15 PM

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();



napo_p2p 04-18-2006 07:51 PM

For one reason or another, I was told that it is best to have join serverside, and not inside any kind of event block.

Yen 04-18-2006 07:52 PM

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.

Seichi 04-19-2006 04:19 AM

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.

Yen 04-19-2006 05:15 PM

>_<
I'll check it out when you get home.


All times are GMT +2. The time now is 11:40 AM.

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