Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-14-2010, 02:08 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Serverside Joining of Clientside Player Functions

Joining classes to the Player Clientside is a useful feature that cuts down on replicate coding and makes important actions/data retrieving more easily accessible, however you have to use player.join("classname"); Clientside rather than whatever Clientside parts of the class script loading when joined Serverside and it seems as if your client has to retrieve the class script from the server before loading on the client, this causes a delay in the script being accessable which while possible to work around can be frustrating.

Would it be possible for Serverside player.join(""); (if not a seperate function) to also join Clientside functions to the player object, and as a result enabling these functions to be accessable as soon as the player logs in?

On a side note, it's annoying that you have to completely restart your client whenever a Clientside player class script is updated in order for it to kick in, this seems to be the case even if you unjoin and re-join the class to the player after updating.
Reply With Quote
  #2  
Old 06-14-2010, 06:06 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I agree at the annoyance of restarting the client. It'd be nice if the delay was fixed as well. On Era we do:

PHP Code:
function onActionServerSide(cmd) {
  if (
cmd "requestReady") {
    
player.triggerClient("gui"this.name"clientsideReady");
  }
}
//#CLIENTSIDE
function onCreated() {
  
player.join("player");
  
player.triggerServer("gui"name"requestReady");
}

function 
onActionClientSide(cmd) {
  if (
cmd == "clientsideReady") {
    for (
temp.weapon player.weapons) {
       
weapon.trigger("playerReady"null);
    }
  }

And then any scripts that call player functions can use the event onPlayerReady instead of onCreated. Hope that helps someone with this problem.
__________________
Reply With Quote
  #3  
Old 06-14-2010, 08:56 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
I agree at the annoyance of restarting the client. It'd be nice if the delay was fixed as well. On Era we do:

PHP Code:
function onActionServerSide(cmd) {
  if (
cmd "requestReady") {
    
player.triggerClient("gui"this.name"clientsideReady");
  }
}
//#CLIENTSIDE
function onCreated() {
  
player.join("player");
  
player.triggerServer("gui"name"requestReady");
}

function 
onActionClientSide(cmd) {
  if (
cmd == "clientsideReady") {
    for (
temp.weapon player.weapons) {
       
weapon.trigger("playerReady"null);
    }
  }

And then any scripts that call player functions can use the event onPlayerReady instead of onCreated. Hope that helps someone with this problem.
I find that some classes actually take longer to load than others (presumably down to their amount of characters), so I use an initialization class that waits until the function exists.
Reply With Quote
  #4  
Old 06-14-2010, 09:46 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by ffcmike View Post
I find that some classes actually take longer to load than others (presumably down to their amount of characters), so I use an initialization class that waits until the function exists.
Probably not a bad idea. Something like

PHP Code:
while (! ("myfunction" in player.getFunctions())) {
  
sleep(0.05);

?
__________________
Reply With Quote
  #5  
Old 06-14-2010, 09:02 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
Probably not a bad idea. Something like

PHP Code:
while (! ("myfunction" in player.getFunctions())) {
  
sleep(0.05);

?
More like:

Weapon/NPC -

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
this.onAttemptInitialize();
}

function 
canInitialize(){
  return 
player.hasFunction("myFunction");
}

function 
initialize(){
  
player.myFunction();

Class -
PHP Code:
//#CLIENTSIDE
function onAttemptInitialize(){
  if(
this.canInitialize()){
    
this.initialize();
  }
  else{
    
this.scheduleEvent(0.05"AttemptInitialize"NULL);
  }

Reply With Quote
  #6  
Old 05-14-2011, 08:24 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Bump.
Reply With Quote
  #7  
Old 05-14-2011, 03:17 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
What about...

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
loadclass("player");
  
player.join("player");

Don't know if it's async or not though. If it is I guess it won't really help much.
__________________
Quote:
Reply With Quote
  #8  
Old 05-14-2011, 03:51 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by fowlplay4 View Post
What about...

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
loadclass("player");
  
player.join("player");

Don't know if it's async or not though. If it is I guess it won't really help much.
Tested it, didn't work .
__________________
Reply With Quote
  #9  
Old 05-16-2011, 12:16 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Eventually use onClassDownloaded(classname), or after joining you call a function, which will automatically wait until the classes are downloaded and then call the function.
Reply With Quote
  #10  
Old 05-16-2011, 01:01 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Stefan View Post
or after joining you call a function, which will automatically wait until the classes are downloaded and then call the function.
Would this not still cause "function myFunction not found in script of npc" when logging into a level containing clientside NPCs that use a player function?
Reply With Quote
  #11  
Old 05-16-2011, 01:20 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
This seemed to work for me:

wNPC A:

PHP Code:
function onCreated() {
  
this.join("test");
}

//#CLIENTSIDE

function onCreated() {
  
this.leave("test"); // Not really necessary, just prevents function overwriting issues.
  
player.join("test");

wNPC B:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
player.hello();

Class: test

PHP Code:
//#CLIENTSIDE
public function hello() {
  
player.chat "world.";

Looks like it also resolves the 'have to restart client to update' issue as well. Just make sure A loads first, which should be as easy as placing it first in weaponsorder in server options.

Last edited by fowlplay4; 05-16-2011 at 01:36 AM.. Reason: Further testing...
Reply With Quote
  #12  
Old 05-16-2011, 01:38 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by fowlplay4 View Post
This seemed to work for me:

wNPC A:

PHP Code:
function onCreated() {
  
this.join("test");
}

//#CLIENTSIDE

function onCreated() {
  
this.leave("test"); // Not really necessary.
  
player.join("test");

wNPC B:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
player.hello();

Class: test

PHP Code:
//#CLIENTSIDE
public function hello() {
  
player.chat "world.";

Looks like it also resolves the 'have to restart client to update' issue as well. Just make sure A loads first, which should be as easy as placing it first in weaponsorder in server options.
Funnily enough before deciding to test this I tested the normal situation of logging in having restarted the client while containing a player.function clientside within weapon + NPC scripts onCreated, and the function happened to work each time, so I think this is only really a problem when lag is involved.
Reply With Quote
  #13  
Old 05-16-2011, 02:51 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by ffcmike View Post
Funnily enough before deciding to test this I tested the normal situation of logging in having restarted the client while containing a player.function clientside within weapon + NPC scripts onCreated, and the function happened to work each time, so I think this is only really a problem when lag is involved.
Joining it to a weapon should force it to pre-load on the client-side though, no?
Reply With Quote
  #14  
Old 05-16-2011, 02:56 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by fowlplay4 View Post
Joining it to a weapon should force it to pre-load on the client-side though, no?
I'm not so sure this is the case with player objects, I have a class which is handling level types (nopk, quest, pk, spar etc) which is joined to players and a clientside wall checking script within a weapon, the problem can still occur when using these functions.
Reply With Quote
  #15  
Old 05-16-2011, 03:22 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
What he means is that you do one weapon which is using all needed classes, since it's preloading the classes for weapons.
Reply With Quote
Reply


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 02:43 PM.


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