![]() |
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 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 |
Yeah, I read that whole document and I tried it but it still didn't work...
|
You need to use join serverside.
|
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 :-)
|
I tried that too, it doesn't seem to work.
|
Quote:
PHP Code:
PHP Code:
This should work. If you want an example using a player joined class, feel free to ask. |
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.
|
Quote:
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. |
Thanks, I got the flags now. Yeah, I made sure that the classname is correct, it doesn't work.
|
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:
|
For one reason or another, I was told that it is best to have join serverside, and not inside any kind of event block.
|
Quote:
I don't see why.. I've had no problems. |
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'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.