Thread: Spar Script
View Single Post
  #1  
Old 09-19-2009, 10:01 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Spar Script

DB NPC
PHP Code:
public function onCreated(){
  
this.waitarray = {};
  
this.spararray = {};
  
this.sparring false;
}
public function 
onAddPlayerSpar(){
  if (
player.account in this.waitarray){
    
player.chat "Already in line.";
  }else{
    
this.waitarray.add(player.account);
  }
}
public function 
onWarpSpar(){
  if (
onCheckNext()){
    
this.waitarray.remove(player.account);
    
this.spararray.add(player.account);
    
player.30.5;
    
player.25;
  }
}
public function 
onPlayerStartSpar(){
  if (
onCheckSparring()){
    
this.sparring true;
    
disablepause();
    
enableweapons();
  }
}
public function 
onCheckNext(){
  if (
this.spararray[0] == "" || this.spararray[1] == ""){
    return (
player.account == this.waitarray[0]);
  }
}
public function 
onCheckSparring(){
  return (
player.account in this.spararray);
}
public function 
onPlayersEndingSpar(){
  if (
onCheckSparring()){
    
enablepause();
    
disableweapons();
    
this.sparring false;
    
player.30.5;
    
player.47;
  }

Level NPC
PHP Code:
function onCreated() {
  
this.setshape(13232);
  
this.db findnpc("db_mainspar");
  
setTimer(1);
}
function 
onTimeout() {
  
this.chat "Line: " @this.db.waitarray;
  
this.db.onWarpSpar();
  
setTimer(1);
}
function 
onPlayerChats(){
  if (
player.chat=="next spar"){
    
this.db.onAddPlayerSpar();
  }
  if (
player.chat=="start"){
    if (
player.x in |17,47| && player.y in |16,37|){
      
this.db.onPlayerStartSpar();
    }
  }
  if (
player.chat=="end spar"){
    
this.db.onPlayerEndSpar();
  }
  if (
player.chat=="heal"){
    
player.hearts player.fullhearts;
  }
  if (
player.chat=="view line"){
    
player.chat this.db.waitarray;
  }
  
setTimer(1);
}
//#CLIENTSIDE
function onCreated(){

}
function 
onPlayerDies(){
  
player.30.5;
  
player.47;
}
function 
onPlayerEnters(){
  
enablepause();
  
disableweapons();
}
function 
onPlayerLeaves(){
  
enablepause();
  
enableweapons();
}
function 
onPlayerChats(){
  if (
player.chat == "focus on"){
    
setfocus(31,23);
  }
  if (
player.chat == "focus off"){
    
resetfocus();
  }

It sets the waiting line, but will not warp the first person in waiting into the spar, really it wont warp anyone. Also if i set the flags manually in the db npc, it wont warp out when saying "end spar" either. Dont know why. I've tried a tiggeraction, maybe i set it up wrong. If someone could show me my error please.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 09-20-2009 at 06:08 AM..
Reply With Quote