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.x = 30.5;
player.y = 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.x = 30.5;
player.y = 47;
}
}
Level NPC
PHP Code:
function onCreated() {
this.setshape(1, 32, 32);
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.x = 30.5;
player.y = 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.
