View Single Post
  #2  
Old 04-21-2009, 12:44 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
PHP Code:
//#CLIENTSIDE
    
function onCreated() {
               
this.sparAreaX 0;
      
this.sparAreaY 0;

      
this.sparAreaWidth 10;
      
this.sparAreaHeight 10
               setTimer
(0.05);
    } 
Instead of constantly setting the Coordinates in a .05 TimeOut, you do better using this.vars and setting them once in the onCreated() Event.
PHP Code:
function onPlayerChats() {
      if (
player.chat == "start") {
        if (
this.sparring.size() == && player.account in this.sparring) {
                   
putbomb(03135);
                 }
      }
  elseif (
player.chat == "join" && !(player.account in this.sparring)) {
        if (
this.sparring.size() < 3) {
player.30;
    
player.30;
    }
      }
    } 
You forgot two checks here. When the player says start, you have to check if the Player is one of the two sparrers, otherwise everybody in the Level can start the Spar, which is pretty dumb. Also when someone attemps to join, he can't be one of the two sparrers :o.
You also forgot a .size() here.
PHP Code:
function onTimeout() {
  if (
player.x in |this.sparAreaXthis.sparAreaX this.sparAreaWidth|
          && 
player.y in |this.sparAreaYthis.sparAreaY this.sparAreaHeight|) {
  
enableweapons();
           if (!(
player.account in this.sparring)) {
             if (
this.sparring.size() < 3) {
            
this.sparring.add(player.account);
             }

     else {
       
player.30;
       
player.30;
     }
       }
      }

      else {
                 
disableweapons();
    if (
player.account in this.sparringthis.sparring.remove(player.account);
      }
  
setTimer(0.05);
    } 
Here, I just added enableweapons() if the player is in the Spar Area and disableweapons() if not, so outside can't be pked. Oh and of course the temp.vars were replaced with the this.vars.

Sorry if I forgot something, but try to style your scripts more in the future :o

Last edited by fragman85; 04-21-2009 at 12:59 PM..
Reply With Quote