Yen
09-24-2006, 07:58 PM
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.
function onActionServerside() {
switch (params[0]) {
case "toplayer":
this.nolevelwarp = params[2];
for (temp.checkwarp: this.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.includeplayers) triggerserver("gui",name,"toplayer",player.chat.substring(7),this.nolevelwarp,this.la stlevel,this.lastx,this.lasty);
break;
case "tolevel":
for (temp.checkwarp: this.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.checkwarp: this.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.x = rx;
player.y = 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] >= 0 && this.tokens[2] >= 0 && this.tokens[3].pos(".nw") >= 0) return "tolevel";
case 3:
if (this.tokens[1] >= 0 && this.tokens[2] >= 0) return "toposition";
case 2:
return "toplayer";
}
}
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.
function onActionServerside() {
switch (params[0]) {
case "toplayer":
this.nolevelwarp = params[2];
for (temp.checkwarp: this.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.includeplayers) triggerserver("gui",name,"toplayer",player.chat.substring(7),this.nolevelwarp,this.la stlevel,this.lastx,this.lasty);
break;
case "tolevel":
for (temp.checkwarp: this.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.checkwarp: this.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.x = rx;
player.y = 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] >= 0 && this.tokens[2] >= 0 && this.tokens[3].pos(".nw") >= 0) return "tolevel";
case 3:
if (this.tokens[1] >= 0 && this.tokens[2] >= 0) return "toposition";
case 2:
return "toplayer";
}
}