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.