Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Joining classes first (https://forums.graalonline.com/forums/showthread.php?t=85604)

cbk1994 05-17-2009 02:36 AM

Joining classes first
 
There's an annoying delay between the time the onActionPlayerOnline function in the Control-NPC is called and when the classes are joined. That, or the level NPCs are called first (onPlayerEnters).

The problem is that this kind of thing happens in level NPCs that have an onPlayerEnters() function:

Quote:

Originally Posted by NC
Script: Function cbk1994.onStaffTag not found at line 7 of jail_level in script of npcs[16] (in level era_jail.nw at pos (29, 36))
Script: Function cbk1994.isStaff not found at line 7 of jail_level in script of npcs[16] (in level era_jail.nw at pos (29, 36))
Script: Function cbk1994.unstick not found at line 8 of jail_level in script of npcs[16] (in level era_jail.nw at pos (29, 36))

This is the onActionPlayerOnline function.

PHP Code:

function onActionPlayerOnline() {
  if (! (
player.account in serveroptions.staff.tokenize(","))) {
    
player.addWeapon("Temp/Server Warp");
    return; 
// goodbye, global news team
  
}
  
  
clientr.serversideReady false;
  
  
player.join("player_itemfunctions");
  
player.join("player");
  
player.join("player_staff");
  
player.join("player_hpfunctions");
  
  
player.loadPlayer();


As you can see, the player class is being joined almost at once.

I think that the server should wait up to five seconds for onActionPlayerOnline to complete and for all of the classes to join, and then trigger onPlayerEnters to level NPCs. This could also be extended to weapons so that they are not called before their items and such have been loaded.

DustyPorViva 05-17-2009 04:18 AM

Also clientside callstack, please?

cbk1994 06-21-2009 12:15 PM

Bump because I can't stress how important this is.

xXziroXx 06-21-2009 01:19 PM

I added something like this on Maloria a while back, since I too was annoyed by it, and thought this might solve it. Note that it didn't.

PHP Code:

function onActionPlayerOnline()
{
  
// --- JOINING OF CLASSES
  
temp.class_list = {
    
"functions_misc",
    
"functions_stats",
    
"functions_skills",
    
"functions_items",
    
"functions_combat",
    
"functions_nations",
    
"player_system",
    
"player_initialize",
    
"quest_log"
  
};
  while (!
temp.isJoined) {
    
temp.isJoined true;
    
temp.attempts ++;
    
    for (
temp.class: temp.class_list) {
      
player.join(temp.class);
      if (!(
temp.class in player.joinedclasses))
        
temp.isJoined false;
    }
  }
  if (
temp.attempts 1)
    echo(
"[" player.account "] All classes joined after" SPC temp.attempts SPC "attempts!");


I still get errors whenever the client enters a level that might use a function that's supposed to be joined to a player.

Admins 06-21-2009 04:24 PM

Hmmm it could be possible to force the onActionPlayerOnline to execute immediatelly at login, need to check this.

cbk1994 06-21-2009 04:39 PM

Quote:

Originally Posted by Stefan (Post 1500734)
Hmmm it could be possible to force the onActionPlayerOnline to execute immediatelly at login, need to check this.

That would be absolutely wonderful.


http://img170.imageshack.us/img170/5383/sorrystefan.png

:( sorry stefan

xXziroXx 06-22-2009 12:34 PM

Quote:

Originally Posted by Stefan (Post 1500734)
Hmmm it could be possible to force the onActionPlayerOnline to execute immediatelly at login, need to check this.

Would be very awesome.

Admins 07-20-2009 01:24 AM

Has Classic staff already tested if it's working fine?

ffcmike 07-20-2009 06:18 PM

Quote:

Originally Posted by Stefan (Post 1508699)
Has Classic staff already tested if it's working fine?

Just tested now,
a player class function is definately working straight after player.join("class"); in ActionPlayerOnline, and not before it (if I remember correctly player classes are no longer joined to the player object once they log out),
levels with scripts that call a player class function on entry aren't causing errors after logging in,
so I believe this is working.

Skyld 07-20-2009 06:25 PM

Quote:

Originally Posted by cbk1994 (Post 1491892)
There's an annoying delay between the time the onActionPlayerOnline function in the Control-NPC is called and when the classes are joined. That, or the level NPCs are called first (onPlayerEnters).

The problem is that this kind of thing happens in level NPCs that have an onPlayerEnters() function:



This is the onActionPlayerOnline function.

PHP Code:

function onActionPlayerOnline() {
  if (! (
player.account in serveroptions.staff.tokenize(","))) {
    
player.addWeapon("Temp/Server Warp");
    return; 
// goodbye, global news team
  
}
  
  
clientr.serversideReady false;
  
  
player.join("player_itemfunctions");
  
player.join("player");
  
player.join("player_staff");
  
player.join("player_hpfunctions");
  
  
player.loadPlayer();


As you can see, the player class is being joined almost at once.

I think that the server should wait up to five seconds for onActionPlayerOnline to complete and for all of the classes to join, and then trigger onPlayerEnters to level NPCs. This could also be extended to weapons so that they are not called before their items and such have been loaded.

Hmm you can't put the loadPlayer() stuff in the onCreated() class of the last joined class? I do this on Rudora and it works fine, since onCreated() is called in the class when it is joined to the player.

cbk1994 07-20-2009 09:31 PM

Quote:

Originally Posted by Skyld (Post 1508810)
Hmm you can't put the loadPlayer() stuff in the onCreated() class of the last joined class? I do this on Rudora and it works fine, since onCreated() is called in the class when it is joined to the player.

I'm sure that would work just as well, but there is no advantage to it, and it would not solve this problem; loadPlayer() is only loading their items, not adding any functions.


Glad to hear that this is working on Classic, hopefully this can be enabled soon for other servers.

cbk1994 08-09-2009 05:42 PM

Any ETA for other servers? I haven't noticed this in a while, though, so perhaps it's already been done?

Admins 08-10-2009 03:21 PM

It has not been enabled yet on other servers but can be done soon.

xXziroXx 08-10-2009 05:40 PM

Quote:

Originally Posted by Stefan (Post 1514034)
It has not been enabled yet on other servers but can be done soon.

I beg of you, hurry!:cry:

ffcmike 09-19-2009 02:28 AM

I'm getting a similar issue except with classes that are joined to the player clientside, it had been working fine for myself, but then I realised there was a large delay involved before the player functions could be called by players with a slow connection/high ping, which is understandable, but something which could cause alot of problems.

Any possibility this could be rectified in the next client version?

cbk1994 09-19-2009 02:31 AM

Quote:

Originally Posted by ffcmike (Post 1523846)
I'm getting a similar issue except with classes that are joined to the player clientside, it had been working fine for myself, but then I realised there was a large delay involved before the player functions could be called by players with a slow connection/high ping, which is understandable, but something which could cause alot of problems.

Any possibility this could be rectified in the next client version?

There's really no way to fix this. I'd recommend having some kind of "player.isReady" variable (clientside), and set that to true once the class is loaded.

ffcmike 09-19-2009 03:23 AM

I've done some experimenting with the joinedclasses variable, seems the class names immediately get added before the class has actually loaded, and I can't seem to get any type of success with the onClassLoaded function, whether it be within a weapon or the class script itself, same for onCreated within the clientside class script, they just don't seem to occur, otherwise that's probably what I would do.

cbk1994 09-19-2009 05:40 PM

Quote:

Originally Posted by ffcmike (Post 1523850)
I've done some experimenting with the joinedclasses variable, seems the class names immediately get added before the class has actually loaded, and I can't seem to get any type of success with the onClassLoaded function, whether it be within a weapon or the class script itself, same for onCreated within the clientside class script, they just don't seem to occur, otherwise that's probably what I would do.

An onCreated() event in the class clientside should be okay.

ffcmike 09-20-2009 06:27 AM

Quote:

Originally Posted by cbk1994 (Post 1523914)
An onCreated() event in the class clientside should be okay.

I've read that it should work before, but it doesn't, not sure if this is something specific to Classic or having the same class joined to the player serverside affects it.

Totally forgot I could just do player.hasfunction(""); though.


All times are GMT +2. The time now is 10:19 PM.

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