Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-23-2010, 10:55 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 Awarding Dead player

This spar script im doing works completely, until you get to where it keeps track of the streak for the player that wins. It does set a number each time someone dies and the spar is over, but it awards the player that lost/dies with the streak and puts not just 1 win up per spar, but as many of a # that is in the level instead. So if there are 4 people in the level, and someone loses a spar, it says they have won 4 spars, per that one spar. Dunno why, i know im missing something stupid.

PHP Code:
//have to change player.level.name to the spar arena level name
function onCreated(){
//serverr.sparring.remove("sssssssssss");
}
function 
onActionServerSide() {
  if (
params[0] == "addtospar") {
    
serverr.sparline.add(params[1]);
  }
  if (
params[0] == "remfromspar") {
    
serverr.sparline.remove(params[1]);
  }
  if (
params[0] == "getSparrers") {
    if (
serverr.sparring.size() <= 1) {
      if (
serverr.sparline.size() > 0) {
        if (
player.account == serverr.sparline[0]) {
          
serverr.sparring.add(serverr.sparline[0]);
          
serverr.sparline.remove(serverr.sparline[0]);
          
serverr.sparring.remove("");
          
setlevel2(player.level.name,28,50);
          
triggerClient("gui"nameNULL);
        }
      }
    }
  }
  if (
params[0] == "startSpar") {
    if (
serverr.sparring.size() == 2) {
     for (
pl:players) {
       
pl.hearts=20;
       
pl.addWeapon("*SwordOnly");
       if (
params[2]==1) {
         
putbomb(1,25,49);
         
triggerClient("gui"name"sparStarted");
       }
     }
    }
  }
  if (
params[0] == "endSpar") {
    if (
serverr.sparring.size() == 2) {
     for (
pl:players) {
       
pl.hearts=20;
       
pl.removeWeapon("*SwordOnly");
       
triggerClient("gui"nameNULL);
     }
    }
  }
  if (
params[0] == "leaveSpar") {
    if (
serverr.sparring.size() <= 2) {
      
player.hearts=20;
      
player.removeWeapon("*SwordOnly");
      
serverr.sparring.remove(params[1]);
      
setlevel2(player.level.name,23,60);
      
triggerClient("gui"name"leaveSpar");
    }
  }
  if (
params[0] == "playerDie") {
   for (
pl:players) {
     
pl.hearts=20;
     
pl.removeWeapon("*SwordOnly");
     if (
params[2]==1) {
       
setlevel2(player.level.name,23,60);
       
serverr.sparring.remove(params[1]);
       
triggerClient("gui"name"sparEnded");
     }
   }
  }
  if (
params[0] == "addStreak") {
  
player.chat="addStreakBegin";
    
//for (pl:players) {
      //if (params[1] == pl.account) {
      
player.chat=params[1];
        if (
serverr.win_streak_acc == params[1]) {
          
serverr.win_streak_num+=1;
          
player.chat="addStreak1";
          
triggerClient("gui"nameNULL);
        } else {
          
serverr.win_streak_acc params[1];
          
serverr.win_streak_num 1;
          
player.chat="addStreak2";
          
triggerClient("gui"nameNULL);
        }
      
//}
    //}
  
}
}
//#CLIENTSIDE
function onActionClientSide() {
  if (
params[0] == "sparStarted") {
    for (
pl:players) {
      if (
InSpar(pl)) {
        
this.sparring true;
      }
    }
  }
  if (
params[0] == "sparEnded") {
    for (
pl:players) {
      
this.sparring false;
      
this.inspar false;
      if (
pl.account != this.dead && InSpar(pl)) {
       
player.chat="sparEnded2";
        
temp.good player.account;
        
triggerServer("gui"name"addStreak",temp.good);
      }
    }
  }
  if (
params[0] == "leaveSpar") {
    
this.inspar=false;
  }
  
setTimer(0.05);
}
function 
onCreated() {
  
setTimer(0.05);
  
this.sparlevelarray = {
  
"testtourny2.nw","testtourny.nw"
  
};
  
//x1,x2,y1,y2 for the level where spar arena is
  
this.sparxyarray = {
  {
16,34,41,58},{0,0,0,0}
  };
  
this.sparring=false;
  
this.inspar=false;
}

function 
onPlayerChats() {
  if (
player.chat=="join spar") {
    if (!(
player.account in serverr.sparline)) {
      if (!(
player.account in serverr.sparring)) {
        
player.chat="Added to spar line!";
        
triggerServer("gui"name"addtospar"player.account);
      } else 
player.chat="You are already in a spar!";
    } else 
player.chat="You are already in the spar line!";
  }
  if (
player.chat=="cancel spar") {
    if (
player.account in serverr.sparline) {
      if (!(
player.account in serverr.sparring)) {
       
player.chat="Removed from spar line!";
       
triggerServer("gui"name"remfromspar"player.account);
      } else 
player.chat="You are already in a spar!";
    } else 
player.chat="You are not in the spar line!";
  }
  if (
player.chat=="start") {
    if (
this.inspar) {
      if (
serverr.sparring.size() == 2) {
        for (
pl:players) {
          if (
pl.account !=player.account && InSpar(pl)) {
            if (
pl.chat=="start") {
              
triggerServer("gui"name"startSpar",player.account,this.inspar);
            }
          }
        }
      }
    }
  }
  if (
player.chat=="end spar") {
    if (
this.inspar) {
      if (
serverr.sparring.size() == 2) {
        for (
pl:players) {
          if (
pl.account != player.account && InSpar(pl)) {
            if (
pl.chat=="end spar") {
              
this.sparring=false;
              
player.chat="Spar Stopped!";
              
triggerServer("gui"name"endSpar");
            }
          }
        }
      }
    }
  }
  if (
player.chat=="leave spar") {
   for (
pl:players) {
    if (
this.inspar) {
      if (
serverr.sparring.size() <= 2) {
        if (
this.sparring != true) {
          if (
InSpar(pl)) {
            
triggerServer("gui"name"leaveSpar"player.account);
          }
        }
      }
    }
   }
  }              
}
function 
onTimeout() {
  if (
serverr.sparring.size() <= 1) {
    if (
serverr.sparline.size() > 0) {
      
triggerServer("gui"name"getSparrers");
    }
  }
  if (
player.level.name in this.sparlevelarray) {
    if (
player.x in |this.sparxyarray[0][0],this.sparxyarray[0][1]| && player.y in |this.sparxyarray[0][2],this.sparxyarray[0][3]|) {
      
this.inspar=true;
    } else 
this.inspar=false;
  }
setTimer(0.05);
}
function 
onPlayerDies() {
  if (
player.hearts == 0) {
    
this.dead=player.account;
    
triggerServer("gui"name"playerDie"player.accountthis.inspar);
  }
}
function 
InSpar(pl) {
  if (
pl.x in |this.sparxyarray[0][0],this.sparxyarray[0][1]| && pl.y in |this.sparxyarray[0][2],this.sparxyarray[0][3]|) {
    
this.inspar=true;
    return 
true;
  } else {
    
this.inspar=false;
    return 
false;
  }

__________________
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...


Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:06 AM.


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