Thread: Weapon -> Class
View Single Post
  #3  
Old 01-24-2010, 07:27 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
This is because classes don't join immediately when you log on, but the script continues. This is highly annoying, as scripts that rely on a class will break on initiation.

You might be able to do something like this:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.join("gui_design");
  while (!
isinclass("gui_design")) sleep(0.05);
  
this.on false;
  
createGUI();
  
toggle(this.on);
}

function 
onWeaponFired() {
  
this.on = !this.on;
  
player.chat = (this.on) ? "On":"Off";
  
toggle(this.on);

I was going to suggest somehow using waitfor() to make the script wait until the class is successfully joined, but I'm not entirely sure how waitfor() is used, and if it can capture when a class joins a script.

I'm not even sure if what I suggested will work, because the class may never join if it is waiting for the next 'frame'. In that case this MIGHT work:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  while (!
isinclass("gui_design")) {
    
this.join("gui_design");
    
sleep(0.05);
  }
  
this.on false;
  
createGUI();
  
toggle(this.on);
}

function 
onWeaponFired() {
  
this.on = !this.on;
  
player.chat = (this.on) ? "On":"Off";
  
toggle(this.on);

Might need to wait for someone more experience dealing with catching/waiting for functions to deal with this, however.

Last edited by DustyPorViva; 01-24-2010 at 07:50 PM..
Reply With Quote