Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Spar Script (https://forums.graalonline.com/forums/showthread.php?t=134256130)

sssssssssss 09-19-2009 10:01 PM

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. :(

sssssssssss 09-21-2009 04:42 PM

I was thinking too hard, got help, never mind. DB, Im an idiot


All times are GMT +2. The time now is 12:24 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.