// .----------------------------------------------------------.
// . SoulBlaker Scripts Presents: .
// . ___________________ .
// . / _____/\______ \ .
// . \_____ \ | | _/ .
// . / \ | | \ .
// . /_______ / |______ / .
// . \/ \/ .
// . [ Cronus Advanced Scripts ] .
// . v1.1 .
// .----------------------------------------------------------.
// ; http://forum.cronus-emulator.com/user/20800-soulblaker ;
// .----------------------------------------------------------.
// . Script: .
// . Event Arena PvP .
// .----------------------------------------------------------.
// . By: SoulBlaker Compible: Cronus version: 1.0 .
// .----------------------------------------------------------.
// . Description: .
// . Ranking PvP .
// .----------------------------------------------------------.
// . Changelog of Version: .
// . * 1.0 [SoulBlaker] .
// . - Started NPC. .
// *----------------------------------------------------------*
/*
CREATE TABLE IF NOT EXISTS `roe_toppvp_players` (
`char_id` int(11) unsigned NOT NULL default '0',
`job` int(6) NOT NULL default '0',
`victory` int(11) NULL default '0',
`defeat` int(11) NOT NULL default '0',
`status` int(1) NOT NULL default '0',
PRIMARY KEY (`char_id`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `roe_toppvp_guilds` (
`guild_id` int(11) unsigned NOT NULL default'0',
`victory` int(11) NOT NULL default '0',
`defeat` int(11) NOT NULL default '0',
`status` int(1) NOT NULL default '0',
PRIMARY KEY (`guild_id`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `roe_toppvp_party` (
`party_id` int(11) unsigned NOT NULL default '0',
`victory` int(11) NOT NULL default '0',
`defeat` int(11) NOT NULL default '0',
`status` int(1) NOT NULL default '0',
PRIMARY KEY (`party_id`)
) ENGINE=MyISAM;
*/
prontera,146,186,5 script Battle Arena#ab_01::PvPArenaEvent 603,{
set .@admin_lvl, 99;
set .@m_1, 1;
while(.@m_1)
{
mes "^FF0000[Recepcionist]^000000";
mes "Welcome to ^0000FFPvP Arena^000000!";
if( $@pvp_flag == 1 ) mes "^0000FFThe PvP Event is open, you can gain points participating.^000000";
else if( $@pvp_flag == 2 ) mes "^FF0000The PvP is Running now, you can gain points participating.^000000";
mes "Want to join in a ^0000FFPvP Arena^000000?";
next;
switch( select((getgmlevel()>=.@admin_lvl?"^0000FF- Manage Events.^000000":""), ($@pvp_flag==1?"^0000FF- Enter in Player vs Player Event.^000000":""), ($@gvg_flag==1?"^0000FF- Enter in Guild vs Guild Event.^000000":""), "- Global Arenas.", "- Guild Arenas.", "^0000FF- Event Info.^000000", "^FF0000- Exit.^000000") )
{
case 1:
mes "^FF0000[Recepcionist]^000000";
mes "Wich operation you want to do?";
next;
switch( select(($@pvp_flag?"- Turn off Player vs Player Event.":"- Turn on Player vs Player Event."), ($@gvg_flag?"- Turn off Guild vs Guild Event.":"- Turn on Guild vs Guild Event."), "^FF0000- Back.^000000", "^FF0000- Exit.^000000") )
{
case 1:
if( $@pvp_flag )
{
mes "^FF0000[Recepcionist: Player vs Player Event]^000000";
mes "Wish to turn off the Player vs Player Event?";
next;
if( select("- Yes.", "- No.") == 1 )
{
donpcevent "PvPArenaEvent::OnEndArena2";
mes "^FF0000[Recepcionist: Player vs Player Event]^000000";
mes "The Event was Successfully Turned off!";
next;
}
}
else {
mes "^FF0000[Recepcionist: Player vs Player Event]^000000";
mes "Wish to turn on the ^0000FFPlayer vs Player Event^000000?";
next;
if( select("- Yes.", "- No.") == 1 )
{
donpcevent "PvPArenaEvent::OnStartArena2";
mes "^FF0000[Recepcionist: Player vs Player Event]^000000";
mes "The Event was Successfully Turned on!";
next;
}
}
break;
case 2:
if( $@gvg_flag )
{
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "Wish to turn off the ^0000FFGuild vs Guild Event^000000?";
next;
if( select("- Yes.", "- No.") == 1 )
{
donpcevent "GvGArenaEvent::OnEndArena2";
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "The Event was Successfully Turned off!";
next;
}
}
else {
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "Wish to turn on the ^0000FFGuild vs Guild Event^000000?";
next;
if( select("- Sim.", "- Não.") == 1 )
{
donpcevent "GvGArenaEvent::OnStartArena2";
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "The Event was Successfully Turned on!";
next;
}
}
break;
case 3:
break;
case 4:
set .@m_1, 0;
break;
}
break;
case 2:
if( $@pvp_flag != 1 )
{
mes "^FF0000[Recepcionist: Player vs Player Event]^000000";
mes "Sorry, but the arena is not open.";
mes "Come back Later!";
close;
}
mes "^FF0000[Recepcionist: Player vs Player Event]^000000";
mes "Very Well, I'll send you there!";
close2;
warp "pvp_n_1-5", 0, 0;
end;
case 3:
if( $@gvg_flag != 1 )
{
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "Sorry, but the arena is not open.";
mes "Come Back Later!";
close;
}
if( !getcharid(2) )
{
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "You need to join a ^0000FFGuild^000000 To participate of this ^0000FFEvent^000000!";
next;
break;
}
mes "^FF0000[Recepcionist: Guild vs Guild Event]^000000";
mes "Very Well, I will send you there!";
close2;
warp "guild_vs2", 0, 0;
end;
case 4:
set .@m_2, 1;
while(.@m_2)
{
mes "^FF0000[Recepcionist: Players Arena]^000000";
mes "Wich ^0000FFPlayers Arena^000000 you wish to enter?";
next;
switch( select("- 1ª Players Arena [^FF0000" + getmapusers("pvp_n_2-5") + "/30^000000] Players.", "- 2ª Players Arena [^FF0000" + getmapusers("pvp_n_2-3") + "/30^000000] Players.", "- 3ª Players Arena [^FF0000" + getmapusers("pvp_n_2-1") + "/30^000000] Players.", "^FF0000- Back.^000000", "^FF0000- Exit.^000000") )
{
case 1: callsub subWarp, "Players", 1, "pvp_n_2-5", 0, 0, 30; break;
case 2: callsub subWarp, "Players", 2, "pvp_n_2-3", 0, 0, 30; break;
case 3: callsub subWarp, "Players", 3, "pvp_n_2-1", 0, 0, 30; break;
case 4: set .@m_2, 0; break;
case 5: set .@m_1, 0; set .@m_2, 0; break;
}
}
break;
case 5:
set .@m_2, 1;
while(.@m_2)
{
if( !getcharid(2) )
{
mes "^FF0000[Recepcionist: Guilds Arena]^000000";
mes "You need to Join a ^0000FFGuild^000000 to participate of this ^0000FFArena^000000!";
next;
set .@m_2, 0;
break;
}
mes "^FF0000[Recepcionist: Guilds Arena]^000000";
mes "Wich ^0000FFGuilds Arena^000000 you wish to enter?";
next;
switch( select("- 1ª Guilds Arena [^FF0000" + getmapusers("guild_vs1") + "/30^000000] Players.", "- 2ª Guilds Arena [^FF0000" + getmapusers("guild_vs4") + "/30^000000] Players.", "- 3ª Guilds Arena [^FF0000" + getmapusers("guild_vs3") + "/30^000000] Players.", "^FF0000- Back.^000000", "^FF0000- Exit.^000000") )
{
case 1: set .@rand, rand(0,3); setarray .@gmapx[0], 51, 8, 50, 92; setarray .@gmapy[0], 91, 50, 7, 49; callsub subWarp, "Guilds", 1, "guild_vs1", .@gmapx[.@rand], .@gmapy[.@rand], 30; break;
case 2: set .@rand, rand(0,3); setarray .@gmapx[0], 51, 8, 50, 92; setarray .@gmapy[0], 91, 50, 7, 49; callsub subWarp, "Guilds", 2, "guild_vs4", .@gmapx[.@rand], .@gmapy[.@rand], 30; break;
case 3: set .@rand, rand(0,3); setarray .@gmapx[0], 17, 49, 83, 83; setarray .@gmapy[0], 51, 85, 51, 51; callsub subWarp, "Guilds", 3, "guild_vs3", .@gmapx[.@rand], .@gmapy[.@rand], 30; break;
case 4: set .@m_2, 0; break;
case 5: set .@m_1, 0; set .@m_2, 0; break;
}
}
break;
case 6:
break;
case 7:
set .@m_1, 0;
break;
}
}
mes "^FF0000[Recepcionist]^000000";
mes "Come back when you want to battle with other players!";
close;
subWarp:
if( getmapusers(getarg(2)) > getarg(5) )
{
mes "^0000FF[Recepcionist: " + getarg(0) + "]^000000";
mes "The ^0000FF " + getarg(1) + " Arena of " + getarg(0) + "^000000 is full, change another ^0000FFArena^000000!";
next;
return;
}
mes "^0000FF[Recepcionist: " + getarg(0) + "]^000000";
mes "Very well, I will send you to ^0000FF " + getarg(1) + " Arena " + getarg(0) + "^000000!";
close2;
if( getmapusers(getarg(2)) > getarg(5) )
dispbottom "You take much time to enter in the Arena " + getarg(1) + " Arena of " + getarg(0) + ", other player take your place!";
else
warp getarg(2), getarg(3), getarg(4);
end;
OnStartArena2:
OnMinute00:
if( !$@pvp_flag )
donpcevent "PvPArenaEvent::OnStartArena";
end;
OnStartArena:
announce "[Battle Arena]: The Player vs Player Event will start in 5 minutes, runto the arena!",bc_all,"0x00FF00";
waitingroom "Open Arena PvP Event.", 0;
removemapflag "pvp_n_1-5", mf_pvp;
set $@pvp_clock, 4;
set $@pvp_flag, 1;
initnpctimer;
end;
OnTimer60000:
// Starting the PvP Arena.
if( !$@pvp_clock )
{
if( getmapusers("pvp_n_1-5") > 1 )
{
announce "[Battles Arena]: The arena was closed, those who had no opportunity may try next time!", bc_all,"0x00FF00";
mapannounce "pvp_n_1-5", "[Battle Arena]: Good Fight Participants!",bc_all,"0x00FF00";
// MapFlags
setmapflag "pvp_n_1-5", mf_pvp;
setmapflag "pvp_n_1-5", mf_noteleport;
setmapflag "pvp_n_1-5", mf_nomemo;
setmapflag "pvp_n_1-5", mf_nosave;
setmapflag "pvp_n_1-5", mf_nowarp;
setmapflag "pvp_n_1-5", mf_nowarpto;
setmapflag "pvp_n_1-5", mf_loadevent;
delwaitingroom;
set $@pvp_flag, 2;
}
else {
announce "[Battles Arena]: The Player vs Player Event was canceled because there is no player in the arena!",bc_all,"0x00FF00";
set $@pvp_flag, 0;
}
stopnpctimer;
}
else {
announce "[Battle Arena]: The Player vs Player Event will start in " + $@pvp_clock + " minutes, Run to the Arena!",bc_all,"0x00FF00";
set $@pvp_clock, $@pvp_clock - 1;
setnpctimer 0;
}
end;
OnEndArena2:
announce "[Battles Arena]: The Player vs Player Event was canceled!",bc_all,"0x00FF00";
delwaitingroom;
if( $@pvp_flag == 1 ) stopnpctimer;
OnEndArena:
removemapflag "pvp_n_1-5", mf_pvp;
removemapflag "pvp_n_1-5", mf_noteleport;
removemapflag "pvp_n_1-5", mf_nomemo;
removemapflag "pvp_n_1-5", mf_nosave;
removemapflag "pvp_n_1-5", mf_nowarp;
removemapflag "pvp_n_1-5", mf_nowarpto;
removemapflag "pvp_n_1-5", mf_loadevent;
mapwarp "pvp_n_1-5", "prontera", 154, 175;
set $@pvp_flag, 0;
end;
OnPCKillEvent:
getmapxy .@map$, .@x, .@y, 0;
if( .@map$ == "pvp_n_2-1" || .@map$ == "pvp_n_2-3" || .@map$ == "pvp_n_2-5" || .@map$ == "pvp_n_1-5" )
callfunc "TopRakingPvP", 0, getcharid(0), Class, 0;
else if( .@map$ == "guild_vs1" || .@map$ == "guild_vs4" || .@map$ == "guild_vs3" || .@map$ == "guild_vs2" )
{
callfunc "TopRakingPvP", 0, getcharid(0), Class, 0;
callfunc "TopRakingPvP", 1, getcharid(2), 0;
}
if( $@pvp_flag == 2 && .@map$ == "pvp_n_1-5" ) {
sleep2(5000);
if( getmapusers("pvp_n_1-5") == 1 )
{
announce "[Battles Arena]: The Player vs Player Event end, The winner is [" + strcharinfo(0) + "]!",bc_all,"0x00FF00";
donpcevent "PvPArenaEvent::OnEndArena";
}
}
if( $@gvg_flag == 2 && .@map$ == "guild_vs2" ) {
sleep2(5000);
if( getmapusers("guild_vs2") == 1 )
{
announce "[Battles Arena]: The Guild vs Guild Event end, the winner Guild is [" + getguildname(getcharid(2)) + "]!",bc_all,"0x00FF00";
donpcevent "GvGArenaEvent::OnEndArena";
}
}
end;
OnPCDieEvent:
getmapxy .@map$, .@x, .@y, 0;
if( .@map$ == "pvp_n_2-1" || .@map$ == "pvp_n_2-3" || .@map$ == "pvp_n_2-5" || .@map$ == "pvp_n_1-5" )
callfunc "TopRakingPvP", 0, getcharid(0), Class, 1;
else if( .@map$ == "guild_vs1" || .@map$ == "guild_vs4" || .@map$ == "guild_vs3" || .@map$ == "guild_vs" )
{
callfunc "TopRakingPvP", 0, getcharid(0), Class, 1;
callfunc "TopRakingPvP", 1, getcharid(2), 1;
}
if( $@pvp_flag == 2 && .@map$ == "pvp_n_1-5" )
{
mapannounce "pvp_n_1-5", "[Battles Arena]: The Player [" + strcharinfo(0) + "] was defeated by [" + rid2name(killerrid) + "]!",bc_all,"0x00FF00";
sleep2(2000);
warp "prontera", 0, 0;
}
if( $@gvg_flag == 2 && .@map$ == "guild_vs2" )
{
mapannounce "guild_vs2", "[Battles Arena]: The Player [" + strcharinfo(0) + "] was defeated by [" + rid2name(killerrid) + "]!",bc_all,"0x00FF00";
sleep2(2000);
warp "prontera", 0, 0;
}
end;
OnPCLogoutEvent:
OnPCLoadMapEvent:
getmapxy .@map$, .@x, .@y, 0;
if( $@pvp_flag == 2 && .@map$ == "pvp_n_1-5" ) {
sleep2(2000);
if( !getmapusers("pvp_n_1-5") )
{
announce "[Battles Arena]: The Player vs Player Event has ended because all players leave the Arena!",bc_all,"0x00FF00";
donpcevent "PvPArenaEvent::OnEndArena";
}
}
if( $@gvg_flag == 2 && .@map$ == "guild_vs2" ) {
sleep2(2000);
if( !getmapusers("guild_vs2") )
{
announce "[Battles Arena]: The Guild vs Guild Event has ended because all players leave the Arena!",bc_all,"0x00FF00";
donpcevent "GvGArenaEvent::OnEndArena";
}
}
end;
// Event GvG
OnStartArenaGvG:
waitingroom "Open Arena GvG Event.", 0;
end;
OnEndArenaGvG:
delwaitingroom;
end;
}
// Expansion to Guild vs Guild event
- script Event GvG#main::GvGArenaEvent -1,{
end;
OnStartArena2:
OnMinute00:
if( !$@gvg_flag )
{
donpcevent "PvPArenaEvent::OnStartArenaGvG";
donpcevent "GvGArenaEvent::OnStartArena";
}
end;
OnStartArena:
announce "[Battles Arena]: The Guild vs Guild Event wil start in 5 minutes, run to the Arena!",bc_all,"0x00FF00";
removemapflag "guild_vs2", mf_gvg;
set $@gvg_clock, 4;
set $@gvg_flag, 1;
initnpctimer;
end;
OnTimer60000:
// Starting the Arena PVP Event.
if( !$@gvg_clock )
{
if( getmapusers("guild_vs2") > 1 )
{
announce "[Battles Arena]: The arena is now closed, those who had no opportunity may try next time!", bc_all,"0x00FF00";
mapannounce "guild_vs2", "[Battles Arena]: Good Fight Participants!",bc_all,"0x00FF00";
// MapFlags
setmapflag "guild_vs2", mf_gvg;
setmapflag "guild_vs2", mf_noteleport;
setmapflag "guild_vs2", mf_nomemo;
setmapflag "guild_vs2", mf_nosave;
setmapflag "guild_vs2", mf_nowarp;
setmapflag "guild_vs2", mf_nowarpto;
setmapflag "guild_vs2", mf_loadevent;
set $@gvg_flag, 2;
donpcevent "PvPArenaEvent::OnEndArenaGvG";
}
else {
announce "[Battles Arena]: The Guild vs Guild Event was canceled because there is no player in the Arena!",bc_all,"0x00FF00";
set $@gvg_flag, 0;
}
stopnpctimer;
}
else {
announce "[Battles Arena]: The Guild vs Guild Event will start in " + $@gvg_clock + " minutes, run to the Arena!",bc_all,"0x00FF00";
set $@gvg_clock, $@gvg_clock - 1;
setnpctimer 0;
}
end;
OnEndArena2:
announce "[Battles Arena]: The Guild vs Guild Event has canceled!",bc_all,"0x00FF00";
donpcevent "PvPArenaEvent::OnEndArenaGvG";
if( $@gvg_flag == 1 ) stopnpctimer;
OnEndArena:
removemapflag "guild_vs2", mf_gvg;
removemapflag "guild_vs2", mf_noteleport;
removemapflag "guild_vs2", mf_nomemo;
removemapflag "guild_vs2", mf_nosave;
removemapflag "guild_vs2", mf_nowarp;
removemapflag "guild_vs2", mf_nowarpto;
removemapflag "guild_vs2", mf_loadevent;
mapwarp "guild_vs2", "prontera", 154, 175;
set $@gvg_flag, 0;
end;
}
//======================================================
// Computation Function
//
// Types:
// 0: Update the Player Database.
// Arguments:
// 1: Player ID.
// 2: Player Class.
// 3: Type (0) for win and (1) for lose.
//
// 1: Update the Guild Database.
// Arguments:
// 1: Guild ID.
// 2: Type (0) for win and (1) for lose.
//
// 2: Update the Party Database.
// Arguments:
// 1: Guild ID.
// 2: Type (0) for win and (1) for lose.
//======================================================
function script TopRakingPvP {
if( getarg(0) == 0 )
{
//================================================
//= Top Players =
//================================================
// Query in the Database of Top Players
query_sql "SELECT `char_id` FROM `roe_toppvp_players` WHERE `char_id`='" + getarg(1) + "' AND `status`='1'", .@TP_P_ID;
if( !getarg(3) )
{
// Insert a Win to the Player.
if( .@TP_P_ID )
query_sql "UPDATE `roe_toppvp_players` SET `victory`=`victory`+'1', `job`='" + getarg(2) + "' WHERE `char_id`='" + getarg(1) + "'";
else // Insert the Char in Database.
query_sql "INSERT INTO `roe_toppvp_players` VALUES (" + getarg(1) + ", " + getarg(2) + ", 1, 0, 1)";
}
else {
// Insert a Lose to the Player.
if( .@TP_P_ID )
query_sql "UPDATE `roe_toppvp_players` SET `defeat`=`defeat`+'1', `job`='" + getarg(2) + "' WHERE `char_id`='" + getarg(1) + "'";
else // Insert the Char in Database.
query_sql "INSERT INTO `roe_toppvp_players` VALUES (" + getarg(1) + ", " + getarg(2) + ", 0, 1, 1)";
}
}
else
if( getarg(0) == 1 )
{
//================================================
//= Top Guilds =
//================================================
// Query in the Database of Top Players
query_sql "SELECT `guild_id` FROM `roe_toppvp_guilds` WHERE `guild_id`='" + getarg(1) + "' AND `status`='1'", .@TP_G_ID;
if( !getarg(2) )
{
// Insert a win to the Guild.
if( .@TP_G_ID )
query_sql "UPDATE `roe_toppvp_guilds` SET `victory`=`victory`+'1' WHERE `guild_id`='" + getarg(1) + "'";
else // Insert the Char in Database.
query_sql "INSERT INTO `roe_toppvp_guilds` VALUES (" + getarg(1) + ", 1, 0, 1)";
}
else {
// Insert a Lose to the Guild.
if( .@TP_G_ID )
query_sql "UPDATE `roe_toppvp_guilds` SET `defeat`=`defeat`+'1' WHERE `guild_id`='" + getarg(1) + "'";
else // Insert the Char in Database.
query_sql "INSERT INTO `roe_toppvp_guilds` VALUES (" + getarg(1) + ", 0, 1, 1)";
}
}
else
if( getarg(0) == 2 )
{
//================================================
//= Top Partys =
//================================================
// Query in the Database of Top Players
query_sql "SELECT `char_id` FROM `roe_toppvp_party` WHERE `party_id`='" + getarg(1) + "' AND `status`='1'", .@TP_G_ID;
if( !getarg(2) )
{
// Insert a Win to the Guild.
if( .@TP_G_ID )
query_sql "UPDATE `roe_toppvp_party` SET `victory`=`victory`+'1' WHERE `party_id`='" + getarg(1) + "'";
else // Insert the Char in Database.
query_sql "INSERT INTO `roe_toppvp_party` VALUES (" + getarg(1) + ", 1, 0, 1)";
}
else {
// Insert a Lose to the Guild.
if( .@TP_G_ID )
query_sql "UPDATE `roe_toppvp_party` SET `defeat`=`defeat`+'1' WHERE `party_id`='" + getarg(1) + "'";
else // Insert the Char in Database.
query_sql "INSERT INTO `roe_toppvp_party` VALUES (" + getarg(1) + ", 0, 1, 1)";
}
}
else return false;
return true;
}