View Single Post
  #7  
Old 08-23-2013, 07:19 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I have a similar approach on Maloria, although instead I make sure to load all the important classes upon login before proceeding with adding any weapons.

PHP Code:
function onActionServerSide(temp.command)
{
  if (
temp.command == "initialized") {
    
player.triggerAllWeapons("onPlayerInitialized");
    
    
player.removeWeapon(this.name);
  }
}

public function 
loadClasses()
{
  if (
player.classesLoaded)
    return echo(
format("[%s]: Classes already loaded for player %s, aborting..."this.nameplayer.communityName));
  
  
temp.classList = { // Array with the classes you want to preload
  
};
  
  for (
temp.classNametemp.classList)
    
player.join(temp.className);
  
  
player.classesLoaded true;
  
triggerClient("gui"this.name"loadClasses"temp.classList);
}

function 
onPlayerLogout(temp.playerObject)
  
temp.playerObject.classesLoaded false;

//#CLIENTSIDE
const DEBUG_MODE true;

function 
onActionClientSide(temp.command)
{
  
// Return if it's not the trigger sent from loadClasses()
  
if (temp.command != "loadClasses")
    return;
  
// Return if classes has already been loaded this session
  
if (player.classesLoaded)
    return;
  
  
temp.classList.copyFrom(params[1]);
  
  for (
temp.classNametemp.classList) {
    
// Load the class to the player
    
if (!player.isInClass(temp.className)) {
      
player.join(temp.className);
      
debug(format("[%s]: Joining class '%s'..."this.nametemp.className));
    }
    
    
// Maybe the class is loaded already?
    
if (isClassLoaded(temp.className)) {
      continue;
    }
    
    
loadClass(temp.className);
    
debug(format("[%s]: Class '%s' not loaded yet, loading..."this.nametemp.className));
    
    while (!
isClassLoaded(temp.className))
      
sleep(0.05);
  }
  
  
player.classesLoaded true;
  
debug(format("[%s]: All classes loaded!"this.name));
  
  
triggerServer("gui"this.name"initialized");
}




function 
debug(temp.text)
{
  if (
DEBUG_MODE)
    echo(
temp.text);

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote