| andrius2006x |
10-07-2007 15:34 |
Need Help with Slot reservation Plugins
Hello.
Sory for my bad english :oops:
I have a problem with one plugin.
I need a plugin who will when server full and admin try connect to server the plugin kick the player with the highest ping.
I found some plugins but they dont working when server was full i try to connect many times but the plugin dont kick anyone :cry:
So, I need a plugin who will kick the players when server is full if anyone can help please code or show some plugins who are realy working. :up:
there is one off the plugins but this plugin does not work :cry:
There is a code of that plugin
Code:
#include <amxmodx>
#include <cstrike>
// filename of LAN ips
#define FILENAME "addons/amxmodx/data/lan.ini"
// are we running cstrike?
new bool:CS = false;
// load the battering ram!
public plugin_init() {
register_plugin("VIP Slotu rezervacija","0.1","csZone");
set_cvar_num("sv_maxvisibleplayers %i",get_maxplayers()-1);
if(module_exists("cstrike"))
CS = true;
}
// zomg someone is connecting
public client_authorized(id) {
// full house and a LAN user is connecting
if(get_playersnum(1) == get_maxplayers() && is_user_LAN(id)) {
new worstPlayer = worst_player();
if(worstPlayer) {
server_cmd("kick #%i ^"Nera vietu sio metu! pirk VIP'a ir turesi rezervuota vieta bei daug privalumu!^"",get_user_userid(worstPlayer));
checkSlots();
}
else {
server_cmd("kick #%i ^"Nebeliko laisvu vietu! Pirk VIP'a ir turesi vieta bei daug privalumu!!^"",get_user_userid(id));
}
}
else if(get_playersnum(1) == get_maxplayers()) {
server_cmd("kick #%i ^"Nebeliko laisvu vietu! Pirk VIP'a ir turesi vieta bei daug privalumu!!^"",get_user_userid(id));
}
else {
checkSlots();
}
}
public client_disconnect(id) {
checkSlots();
}
public checkSlots() {
if(get_playersnum(1) == get_maxplayers()-1) {
set_cvar_num("sv_maxvisibleplayers %i",get_maxplayers());
}
else {
set_cvar_num("sv_maxvisibleplayers %i",get_maxplayers()-1);
}
}
// find the current worst player
public worst_player() {
// get team numbers
new players[32], num, i, Ts, CTs;
get_players(players,Ts,"e","TERRORIST");
get_players(players,CTs,"e","CT");
// if one team has more than the other,
// kick someone that is on that team.
// if equal numbers find overall worst.
if(Ts > CTs) {
get_players(players,num,"e","TERRORIST");
}
else if(CTs > Ts) {
get_players(players,num,"e","CT");
}
else {
get_players(players,num);
}
// prepare to find the worst
new worstPlayer, worstFrags, worstDeaths;
// loop through players
for(i=0;i<num;i++) {
new player = players[i];
// exclude LAN players
if(is_user_LAN(player)) {
continue;
}
// get data
new myFrags, myDeaths;
myFrags = get_user_frags(player);
myDeaths = cs_get_user_deaths(player);
// no one yet
if(!worstPlayer) {
worstPlayer = player;
worstFrags = myFrags;
worstDeaths = myDeaths;
continue;
}
// lowest frags or tied frags but higher deaths = lowest on scoreboard
if( (myFrags < worstFrags) || (myFrags == worstFrags && myDeaths > worstDeaths) ) {
worstPlayer = player;
worstFrags = myFrags;
worstDeaths = myDeaths;
continue;
}
}
return worstPlayer;
}
// see if this player is a member of the LAN
public bool:is_user_LAN(id) {
new ip[32];
get_user_ip(id,ip,31,0);
new line, text[64], txtlen;
while( (line = read_file(FILENAME,line,text,63,txtlen)) != 0 ) {
trim(text);
if( equali(ip,text,strlen(text)) ) {
return true;
}
}
return false;
}
I make a file lan.ini in addons/amxmodx/data/lan.ini and add to the this file my IP but it still dont works. Iff anyone know the problem please help me or show me some plugins allready maked :wink:
Thanks.
|