I did this basic script, maybe it will help you.
CREATE TABLE IF NOT EXISTS `pvp_rank` (
`char_id` int(11) unsigned NOT NULL,
`kills` int(11) unsigned NOT NULL DEFAULT 0,
`deaths` int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`char_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
And here's the script.
prontera,196,142,5 script PVP Warper 100,{
mes "[ ^FF0000PVP Warper^000000 ]";
mes "Welcome, ^0000FF"+strcharinfo(0)+"^000000.";
mes "Please select a PVP room:";
next;
// Dynamic menu with player counts
.@menu$ = "";
for (.@i = 0; .@i < getarraysize(.pvp_map$); .@i++) {
.@users = getmapusers(.pvp_map$[.@i]);
.@menu$ += .pvp_name$[.@i]+" ["+.@users+"/"+.pvp_max[.@i]+"]:";
}
.@sel = select(.@menu$) - 1;
if (BaseLevel < .pvp_level[.@sel]) {
mes "[ ^FF0000PVP Warper^000000 ]";
mes "You must be at least level "+.pvp_level[.@sel]+" to enter this room.";
close;
}
if (getmapusers(.pvp_map$[.@sel]) >= .pvp_max[.@sel]) {
mes "[ ^FF0000PVP Warper^000000 ]";
mes "This room has reached its player limit ("+.pvp_max[.@sel]+").";
close;
}
warp .pvp_map$[.@sel],0,0;
end;
OnPCKillEvent:
// Validate if map is a valid PVP room
.@valid = 0;
for (.@i = 0; .@i < getarraysize(.pvp_map$); .@i++) {
if (strcharinfo(3) == .pvp_map$[.@i]) {
.@valid = 1;
break;
}
}
if (!.@valid) end;
// Get Killer and Victim Char IDs safely
.@killer_cid = getcharid(0);
.@victim_cid = getcharid(0, rid2name(killedrid));
if (!.@killer_cid || !.@victim_cid || .@killer_cid == .@victim_cid) end;
// Always register kills and deaths for all maps
query_sql("INSERT INTO pvp_rank (`char_id`, `kills`, `deaths`) VALUES ("+.@killer_cid+",1,0),("+.@victim_cid+",0,1) ON DUPLICATE KEY UPDATE `kills`=`kills`+VALUES(`kills`), `deaths`=`deaths`+VALUES(`deaths`)");
// Only grant special points in the GM-selected map
if (strcharinfo(3) != .points_map$) end;
// IP check validation (enabled or disabled by admin)
if (.ip_check_enabled) {
query_sql("SELECT last_ip FROM login WHERE account_id="+getcharid(3), .@killer_ip$);
query_sql("SELECT last_ip FROM login WHERE account_id="+killedrid, .@victim_ip$);
if (.@killer_ip$ == .@victim_ip$) {
dispbottom "[PVP Warper]: No points granted. Same IP detected.";
end;
}
}
// Kill cooldown validation
.@current_time = gettimetick(2);
.@cooldown = .kill_cooldown;
.@kill_cd_var$ = "kill_cd_"+.@killer_cid+"_"+.@victim_cid;
if (getd(.@kill_cd_var$) + .@cooldown > .@current_time) {
dispbottom "[PVP Warper]: You recently killed this player. Wait before earning more points.";
end;
}
setd .@kill_cd_var$, .@current_time;
// Add your special points reward code here.
// Example: set pvp_points, pvp_points + 1;
dispbottom "[PVP Warper]: You've earned special points for defeating a player.";
end;
OnCheckRank:
mes "[ ^FF0000PVP Warper^000000 ]";
query_sql("SELECT kills, deaths FROM pvp_rank WHERE char_id="+ getcharid(0), .@kills, .@deaths);
mes "Tus estadísticas actuales:";
mes "^0000FFKills:^000000 "+ (.@kills ? .@kills : 0);
mes "^FF0000Muertes:^000000 "+ (.@deaths ? .@deaths : 0);
close;
OnGMResetRank:
if (getgmlevel() < 60) {
dispbottom "No tienes permisos para usar este comando.";
end;
}
query_sql("TRUNCATE TABLE pvp_rank");
dispbottom "Ranking PVP reiniciado correctamente.";
end;
OnInit:
// General Configuration
setarray .pvp_map$[0], "guild_vs1", "guild_vs2", "pvp_y_1-2";
setarray .pvp_name$[0], "PVP Room 1", "PVP Room 2", "PVP Prontera";
setarray .pvp_level[0], 1, 50, 99;
setarray .pvp_max[0], 10, 15, 20;
// Enable or disable IP check (1 = ON, 0 = OFF)
.ip_check_enabled = 0;
// Kill cooldown in seconds (recommended: 60-120 sec)
.kill_cooldown = 60;
// GM configuration: Set the map that gives special points here (default is room 1)
.points_map$ = .pvp_map$[0]; // Change [0] to [1] or [2] to switch rooms
// Commands for player and GM
bindatcmd "pvprank",strnpcinfo(3)+"::OnCheckRank";
bindatcmd "resetpvprank",strnpcinfo(3)+"::OnGMResetRank",60,60;
end;
}
Feel free to ask for a change.