Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 09-24-2006, 07:16 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
XD Awesome Yen.
__________________
Deep into the Darkness peering...
Reply With Quote
  #3  
Old 09-28-2006, 07:03 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Shouldn't the no level checks all be done serverside? =S
Reply With Quote
  #4  
Old 09-28-2006, 02:31 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
It could be, but there's not much reason.
You don't expect your staff to be hacking, so if they do hack their way past the clientside check you may as well fire them.

Come to think of it, I could also do the 'warpto player' level check clientside..
Reply With Quote
  #5  
Old 09-29-2006, 02:51 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Might be better if you passed the tokens as a param to WarpType instead of relying on them to be parsed before you call the function (and hope nothing else parses them in between)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
Reply


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 06:47 PM.


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