Thread: Warp Limiter
View Single Post
  #1  
Old 09-24-2006, 06:58 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Warp Limiter

I felt I should contribute something.
This is just a quick NPC that limits warpto rights.
For example, if you don't want those pesky LATs warping to test levels, quests, dungeons, ect. you can prevent it with this sytem.

PHP Code:
function onActionServerside() {
  switch (
params[0]) {
    case 
"toplayer":
      
this.nolevelwarp params[2];
      for (
temp.checkwarpthis.nolevelwarp) {
        if (
temp.checkwarp.starts("*")) {
          if (
findplayer(params[1]).level.pos(temp.checkwarp.substring(1)) >= 0) {
            
player.chat "Warping to this level is prohibited.";
            
setlevel2(params[3],params[4],params[5]);
            break;
          }
        }
        else {
          if (
findplayer(params[1]).level == temp.checkwarp) {
            
player.chat "Warping to this level is prohibited.";
            
setlevel2(params[3],params[4],params[5]);
            break;
          }
        }
      }
    break;
    case 
"returnfrom":
      
setlevel2(params[1],params[2],params[3]);
    break;
  }
}
//#CLIENTSIDE
function onCreated() {
  
/* Set limits here.
    this.nolevelwarp = {"level1.nw","*level",};
      prevents warping to these levels
    this.nopositionwarp = {"level1.nw","*level"};
      prevents warping to x/y in these levels
    this.includeplayers = true/false;
      if true, disables warping to other players in limited levels

      entries beginning with * will limit warping to any level with that word in it's name.
       (i.e. "*overworld" disables warping to any level that contains 'overworld' in it's name)
      all other entries will look for the exact level
       (i.e. "stafflevel.nw" disables warping to the level 'stafflevel.nw')
  */ 
  
this.nolevelwarp = {"*dungeon","yenarea.nw"};
  
this.nopositionwarp = {"*dungeon"};
  
this.includeplayers true;
  
/* Don't change anything below this line. */
}

function 
onPlayerChats() {
  if (
player.chat.starts("warpto")) {
    
this.lastx player.x;
    
this.lasty player.y;
    
this.lastlevel player.level;
    
this.tokens player.chat.tokenize();
    switch (
WarpType()) {
      case 
"toplayer":
        if (
this.includeplayerstriggerserver("gui",name,"toplayer",player.chat.substring(7),this.nolevelwarp,this.lastlevel,this.lastx,this.lasty);
      break;
      case 
"tolevel":
        for (
temp.checkwarpthis.nolevelwarp) {
          if (
temp.checkwarp.starts("*")) {
            if (
this.tokens[3].pos(temp.checkwarp.substring(1)) >= 0) {
              
player.chat "Warping to this level is prohibited.";
              
scheduleevent(.1,"ReturnLevel",this.lastx,this.lasty,this.lastlevel);
              break;
            }
          }
          else {
            if (
this.tokens[3] == temp.checkwarp) {
              
player.chat "Warping to this level is prohibited.";
              
scheduleevent(.1,"ReturnLevel",this.lastx,this.lasty,this.lastlevel);
              break;
            }
          }
        }
      break;
      case 
"toposition":
        for (
temp.checkwarpthis.nopositionwarp) {
          if (
temp.checkwarp.starts("*")) {
            if (
player.level.pos(temp.checkwarp.substring(1)) >= 0) {
              
player.chat "Warping in this level is prohibited.";
              
scheduleevent(.1,"ReturnPos",this.lastx,this.lasty);
              break;
            }
          }
          else {
            if (
player.level == temp.checkwarp) {
              
player.chat "Warping in this level is prohibited.";
              
scheduleevent(.1,"ReturnPos",this.lastx,this.lasty);
              break;
            }
          }
        }
      break;
    }
  }
}

function 
onReturnPos(rx,ry) {
  
player.rx;
  
player.ry;
}

function 
onReturnLevel(rx,ry,rl) {
  
triggerserver("gui",name,"returnfrom",rl,rx,ry);
}

function 
WarpType() {
  switch (
this.tokens.size()) {
    case 
4:
      if (
this.tokens[1] >= && this.tokens[2] >= && this.tokens[3].pos(".nw") >= 0) return "tolevel";
    case 
3:
      if (
this.tokens[1] >= && this.tokens[2] >= 0) return "toposition";
    case 
2:
      return 
"toplayer";
  }


Last edited by Yen; 09-24-2006 at 07:25 PM.. Reason: Forgot breaks
Reply With Quote