Thread: onActionGrab
View Single Post
  #8  
Old 08-25-2006, 10:34 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by KuJi
I mean over the ENTIRE script he didnt need to trigger the server to join it x.x
Perhaps he is using a state-approach, where he joins a class in one state, and another class in another.

Example:

PHP Code:
// CLASSES/State1
function DoSomething() {
  echo(
"Currently in State 1.");
}

function 
LeavingState() {
  echo(
"Leaving State 1");
}

function 
JoiningState() {
  echo(
"Joining State 1");

PHP Code:
// CLASSES/State2
function DoSomething() {
  echo(
"Currently in State 2.");
}

function 
LeavingState() {
  echo(
"Leaving State 2");
}

function 
JoiningState() {
  echo(
"Joining State 2");

PHP Code:
// Some Object
function onCreated() {
  
SetState(1);
}

function 
onPlayerChats() {
  if(
player.chat.starts("/changestate")) {
    
temp.state = (temp.state == 1);
    
SetState(temp.state);
  } else if(
player.chat.starts("/dosomething")) {
    
this.DoSomething();
  }
}

function 
SetState(stateNum) {
  if(
this.state in |1,2|) {
    
temp.oldstate this.state;
    
this.LeavingState();
    
this.leave("State" temp.oldstate);
  }

  
this.state stateNum;
  
this.join("State" this.state);
  
this.JoiningState();

__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote