Jump to content
  • 0

Warping player(s) from a map after a set time


Gimj

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  01/29/13
  • Last Seen:  

Like the title says, I'm trying to figure out how to warp players off of a map after a time limit is reached. I can't seem to figure it out, here's the focal point of my script. I just need to know how to do one npc (Alpha MVP), then I can just copy paste the rest. Thanks in advance.

//===== rAthena Script =======================================
//= MVP Arena
//===== By: ==================================================
//= Darkchild
//===== Current Version: =====================================
//= 1.4
//===== Compatible With: =====================================
//= rAthena SVN
//===== Description: =========================================
//= Rooms containing 16 different MVPs
//===== Additional Comments: =================================
//= 1.0 - First version of script
//= 1.1 - Optimised The MVP arena [massdriller]
//= 1.2 - NPC in prontera [silent]
//= 1.3 - Removed Duplicates
//= 1.4 - Optimized, text edited [Euphy]
//============================================================
// Entrance
izlude,98,137,3 script MVP Warper 768,{
mes "[ ^0065DFMVP Warper^000000 ]";
mes "Would you like to enter";
mes "the MVP Arena?";
mes "I require an ^FF0000Event Tablet^000000 and ^FF000010,000,000^000000 Zeny for my services, however.";
if (select("Yes!","No thanks.") == 2) close;
if (countitem(25048)<1) goto NEPC;
if(Zeny < 10000000) goto NEPC;
delitem 25048,1;
set Zeny, Zeny - 10000000;
warp "quiz_00",50,24;
close;

NEPC:
mes @npc$;
mes "You don't have what I require.";
close;
}
// Information
quiz_00,49,31,4 script MVP Arena Guide 778,{
mes "[ ^0065DFMVP Arena Guide^000000 ]";
mes "Welcome and behold this sacred place. Here you will find out if you truly have what it takes to call yourself a warrior.";
next;
switch(select("Information","Heal me!","Return to Izlude","Cancel")) {
case 1:
 mes "[ ^0065DFMVP Arena Guide^000000 ]";
 mes "There are four Keepers, and each has the same MVPs.";
 mes "Each Keeper can take you to a seperate room with only one player per room.";
 mes "These rooms have 40 MVPs in each of them. If you die, you will be warped out.";
 close;
case 2:
 specialeffect2 313;
 percentheal 100,100;
 close;
case 3:
 warp "izlude",128,146;
 close;
case 4:
 close;
}
}
// Alpha NPC script
quiz_00,56,31,4 script Alpha MVP 770,{

mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Would you like to enter";
mes "Room 1?";
if(select("Yes","No") == 2) {
mes "[Alpha MVP]";
mes "Ok, good bye then.";
close;

}
if(TimeUsed > gettimetick(2)) {
mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Sorry, a player has recently used this room.";
mes "Come back later or try another room, we are currently revitalizing Room 1. ";
close;

}
mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Ok, here goes!";
close2;
warp "bossnia_01",180,75;
set TimeUsed, gettimetick(2) + 5; // 86400 is one day in seconds.
dispbottom "Alpha MVP : Please note that you cannot return for 8 hours.";
end;

}

OnTimeLimit:
message strcharinfo(0),"Time's Up.";
sleep2 5;
warp "new_zone04",60,179;
end;

}
// Beta NPC script
quiz_00,58,31,4 script Beta MVP 773,{

mes "[ ^0065DFBeta MVP^000000 ]";
mes "Would you like to enter";
mes "Room 2?";
if (select("Yes.","No thanks.") == 2) close;
warp "bossnia_02",180,75;
close;

}
// Theta NPC script
quiz_00,60,31,4 script Theta MVP 774,{

mes "[ ^0065DFTheta MVP^000000 ]";
mes "Would you like to enter";
mes "Room 3?";
if (select("Yes.","No thanks.") == 2) close;
warp "bossnia_03",180,75;
close;

}
// Epsilon NPC script
quiz_00,62,31,4 script Epsilon MVP 776,{

mes "[ ^0065DFEpsilon MVP^000000 ]";
mes "Would you like to enter";
mes "Room 4?";
if (select("Yes.","No thanks.") == 2) close;
warp "bossnia_04",180,75;
close;

}
// Protectors
function script Protector {
switch(select(""+((getarg(0)=="")?"":"Harder Monsters")+":Heal:Exit")) {
case 1:
 warp getarg(0),102,102;
 close;
case 2:
 specialeffect2 313;
 percentheal 100,100;
 close;
case 3:
 warp "prontera",156,179;
 close;
}
}

Edited by Mysterious
Please use [codebox] for long content.
Link to comment
Share on other sites

11 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

you should know that @timeused is a temporary player variable, its only meant for testing

if you want to do this on live server, use a permanent player variable

alpha script, use timeused1, beta script use timeused2 ... separate the variable out from each npc


this is how I do this

//    mvp room summoner
-    script    Main_MVP_warper    -1,{
   .@id = atoi( strnpcinfo(2) );
   mes "[ ^0065DF"+ strnpcinfo(1) +"^000000 ]";
   mes "Would you like to enter Room "+ .@id +" ?";
   next;
   if ( select ( "Yes", "No" ) == 2 ) {
       mes "Good bye then.";
       close;
   }
   if ( getd( "timeused"+ .@id ) + 180000 > gettimetick(2) ) { // 180,000 seconds delay (5 hours)
       mes "We are revitalizing Room "+ .@id +", come back later.";
       close;
   }
   if ( getmapusers( "bossnia_0"+ .@id ) ) {
       mes "Sorry, a player is in the room.";
       close;
   }
   warp "bossnia_0"+ .@id, 180,71;
   deltimer strnpcinfo(0) +"::OnKick";
   addtimer 600000, strnpcinfo(0) +"::OnKick"; // 600,000 seconds warp out (10 minutes)
   setd "timeused"+ .@id, gettimetick(2);
   end;
OnKick:
   if ( strcharinfo(3) == "bossnia_0"+ .@id )
       warp "SavePoint", 0,0;
   end;
}
quiz_00,56,31,4    duplicate(Main_MVP_warper)    Alpha MVP#1    770
quiz_00,58,31,4    duplicate(Main_MVP_warper)    Beta MVP#2    773
quiz_00,60,31,4    duplicate(Main_MVP_warper)    Theta MVP#3    774
quiz_00,62,31,4    duplicate(Main_MVP_warper)    Epsilon MVP#4    776

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

You mean to only allow one player on the map, correct? TimeUsed is a player variable, so it won't block other players from entering. Use either an NPC variable (.TimeUsed, non-permanent) or permanent global variable ($TimeUsed1, but avoid using too many of these).

Then use an NPC timer to kick all players from the map when time is up (note that this is not permanent; if you want it persistent to reloads, you'll need to perform tricky calculations to manipulate the timer based on your time variable OnInit).

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

set TimeUsed, gettimetick(2) + 5; // 86400 is one day in seconds.

this is just deny usage

to warp them out after a set of time, use addtimer

http://rathena.org/board/topic/73649-warp-in-warp-out/#entry153373

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  01/29/13
  • Last Seen:  

I've seen that thread Annie, and I've tried to combine it with my deny usage script...but I've failed every time. Everytime I do it, I either can't deny usage or I can deny usage but it won't warp them out.

I've separated each of the scripts onto two seperate npcs, which work fine on each.

// Alpha NPC script
quiz_00,56,31,4	script	Alpha MVP	770,{

mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Would you like to enter";
mes "Room 1?";
if(select("Yes","No") == 2) {
mes "[Alpha MVP]";
mes "Ok, good bye then.";
close;

}
if($TimeUsed1 > gettimetick(2)) {
mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Sorry, a player has recently used this room.";
mes "Come back later or try another room, we are currently revitalizing Room 1. ";
close;

}	
mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Ok, here goes!";
close2;
warp "bossnia_01",180,75;
set $TimeUsed1, gettimetick(2) + 5; // 86400 is one day in seconds.
dispbottom "Alpha MVP : Please note that you cannot return for 8 hours.";
end;
}




// Beta NPC script
quiz_00,58,31,4	script	Beta MVP	773,{

mes "[ ^0065DFBeta MVP^000000 ]";
mes "Would you like to enter";
mes "Room 2?";
if (select("Yes","No") == 1) {
deltimer strnpcinfo(0)+"::OnKick";
addtimer ( 1 * 5000 ),strnpcinfo(0)+"::OnKick";
warp .map$,0,0;
}
close;

OnKick:
if( strcharinfo(3) == .map$ )
warp "SavePoint",0,0;
end;

OnInit:
.map$ = "bossnia_02";
end;
}


I'm legitimately out of ideas on how to combine them. @_@

Edited by Gimj
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

prontera,154,187,5	script	kidhfksdhf	100,{
mes "would you like to enter Room 1 ?";
next;
if ( select ( "Yes", "No" ) == 2 ) {
	mes "good bye then";
	close;
}
if ( @timeused + 20 > gettimetick(2) ) { // 20 seconds delay
	mes "you can't go in back in just 20 seconds";
	close;
}
if ( getmapusers( "guild_vs2" ) ) {
	mes "sorry, a player is in the room";
	close;
}
warp "guild_vs2", 0,0;
deltimer strnpcinfo(0) +"::OnKick";
addtimer 10000, strnpcinfo(0) +"::OnKick"; // 10 seconds warp out
@timeused = gettimetick(2);
end;
OnKick:
if ( strcharinfo(3) == "guild_vs2" )
	warp "SavePoint", 0,0;
end;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  01/29/13
  • Last Seen:  

Thank you so much Annie! People like you make the world just a little better to live in. Appreciate it!

EDIT:

Sorry, just one problem. I'm using the maps bossnia_01-04 and if I use one NPC to go to any level, all the NPCs ban me from usage. Not sure why it would do that. It all looks seperate to me...

// Alpha NPC script
quiz_00,56,31,4	script	Alpha MVP	770,{

mes "[ ^0065DFAlpha MVP^000000 ]";
mes "Would you like to enter Room 1 ?";
next;
if ( select ( "Yes", "No" ) == 2 ) {
	mes "Good bye then.";
	close;
}
if ( @timeused + 180000 > gettimetick(2) ) { // 180,000 seconds delay (5 hours)
	mes "We are revitalizing Room 1, come back later.";
	close;
}
if ( getmapusers( "bossnia_01" ) ) {
	mes "Sorry, a player is in the room.";
	close;
}
warp "bossnia_01",180,71;
deltimer strnpcinfo(0) +"::OnKick";
addtimer 600000, strnpcinfo(0) +"::OnKick"; // 600,000 seconds warp out (10 minutes)
@timeused = gettimetick(2);
end;
OnKick:
if ( strcharinfo(3) == "bossnia_01" )
	warp "SavePoint", 0,0;
end;
}




// Beta NPC script
quiz_00,58,31,4	script	Beta MVP	773,{

mes "[ ^0065DFBeta MVP^000000 ]";
mes "Would you like to enter Room 2 ?";
next;
if ( select ( "Yes", "No" ) == 2 ) {
	mes "Good bye then.";
	close;
}
if ( @timeused + 180000 > gettimetick(2) ) { // 180,000 seconds delay (5 hours)
	mes "We are revitalizing Room 2, come back later.";
	close;
}
if ( getmapusers( "bossnia_02" ) ) {
	mes "Sorry, a player is in the room.";
	close;
}
warp "bossnia_02",180,71;
deltimer strnpcinfo(0) +"::OnKick";
addtimer 600000, strnpcinfo(0) +"::OnKick"; // 600,000 seconds warp out (10 minutes)
@timeused = gettimetick(2);
end;
OnKick:
if ( strcharinfo(3) == "bossnia_02" )
	warp "SavePoint", 0,0;
end;
}



// Theta NPC script
quiz_00,60,31,4	script	Theta MVP	774,{

mes "[ ^0065DFTheta MVP^000000 ]";
mes "Would you like to enter Room 3 ?";
next;
if ( select ( "Yes", "No" ) == 2 ) {
	mes "Good bye then.";
	close;
}
if ( @timeused + 180000 > gettimetick(2) ) { // 180,000 seconds delay (5 hours)
	mes "We are revitalizing Room 3, come back later.";
	close;
}
if ( getmapusers( "bossnia_03" ) ) {
	mes "Sorry, a player is in the room.";
	close;
}
warp "bossnia_03",180,71;
deltimer strnpcinfo(0) +"::OnKick";
addtimer 600000, strnpcinfo(0) +"::OnKick"; // 600,000 seconds warp out (10 minutes)
@timeused = gettimetick(2);
end;
OnKick:
if ( strcharinfo(3) == "bossnia_03" )
	warp "SavePoint", 0,0;
end;
}

// Epsilon NPC script
quiz_00,62,31,4	script	Epsilon MVP	776,{

mes "[ ^0065DFEpsilon MVP^000000 ]";
mes "Would you like to enter Room 4 ?";
next;
if ( select ( "Yes", "No" ) == 2 ) {
	mes "Good bye then.";
	close;
}
if ( @timeused + 180000 > gettimetick(2) ) { // 180,000 seconds delay (5 hours)
	mes "We are revitalizing Room 4, come back later.";
	close;
}
if ( getmapusers( "bossnia_04" ) ) {
	mes "Sorry, a player is in the room.";
	close;
}
warp "bossnia_04",180,71;
deltimer strnpcinfo(0) +"::OnKick";
addtimer 600000, strnpcinfo(0) +"::OnKick"; // 600,000 seconds warp out (10 minutes)
@timeused = gettimetick(2);
end;
OnKick:
if ( strcharinfo(3) == "bossnia_04" )
	warp "SavePoint", 0,0;
end;
}

Edited by Gimj
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  01/29/13
  • Last Seen:  

Worked like a charm! I'll keep that in mind, I used $TimeUsed(1-4) on four NPCs; is that fine or? Euphy said I should avoid using too many but I see no immediate problems...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

I used $TimeUsed(1-4) on four NPCs; is that fine or? Euphy said I should avoid using too many but I see no immediate problems...

It's fine. You just don't want to be using thousands of them, or your server may start to lag (Annie made a nice post about it here).

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  01/29/13
  • Last Seen:  

Okay thanks a lot for both of your help!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

thousands is still ok, but not in millions xD

the blame is at

if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table)

inside src\map\mapreg_sql.c

if retrieving this over a 50,000 lines, server will simply die

that kind of lagging issue only happens after your server getting lots of players plus doing that for several months

that trick was quite popular in year 2006/2007, it was only later found out about this flaw about 2008

I don't think saving just 4 lines will affect anything

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  01/29/13
  • Last Seen:  

Noted. Thank you for all the extra information, helped me more than required. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...