Re: Creating a script with data/lang
Code:
console_print(id, "%L", id, "TESTING")
It isn't working :( , but evry thing alce dose. :P
Will it be difrent if i'll use LANG_PLAYER isted of id?
This plugin:
Code:
/*
* Cvars:
*
* amx_reservation <value>
* 0 - Disables the plugin.
* 1 - Kicks the Player with the shortest playing time when an admin connects to a full server.
* 2 - Kicks the Player with the longest playing time when an admin connects to a full server.
* 3 - Kicks the Player with the highest ping when an admin connects to a full server.
* 4 - Normal AMX Mode: 'amx_reservedslots' are reserved, nobody is kicked when an admin connects to a full server
*
* amx_reservedslots <value> : number of reserved slots (if amx_reservation is set to 4)
*
* amx_hideslots <1 or 0> : hide reserved slots or not (if amx_reservation is set to 4)
*
* amx_rslot_redirect <1 or 0> : if 1 will redirect player, if 0 - kick
*
* amx_rslot_redirectip <server.ip.address.and:port> : set server ip/domain and port to where player will be redirected (if amx_rslot_redirect is set to 1)
*
* amx_rslot_redirectpw <password> : set password of server where player will be redirected (if amx_rslot_redirect is set to 1)
*
*
*/
#define PLUGIN "Admin Slots Ultimate"
#define VERSION "1.2"
#define AUTHOR "NumB & Slmclarengt"
#include <amxmodx>
#include <amxmisc>
new g_maxplayers
new cvar_redirectip
new cvar_redirectpw
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("amx_reservation","0")
register_cvar("amx_reservedslots","0")
register_cvar("amx_hideslots","0")
register_cvar("amx_rslot_redirect","0")
cvar_redirectip = register_cvar("amx_rslot_redirectip"," ")
cvar_redirectpw = register_cvar("amx_rslot_redirectpw"," ")
register_dictionary("adminslots_ultimate.txt")
g_maxplayers = get_maxplayers()
}
public plugin_cfg() {
new amx_reservation_var = get_cvar_num("amx_reservation")
new amx_hideslots = get_cvar_num("amx_hideslots")
new amx_reservedslots = get_cvar_num("amx_reservedslots")
if(amx_reservation_var > 0 && amx_reservation_var < 4) {
set_cvar_num("sv_visiblemaxplayers", g_maxplayers - 1)
} else if(amx_reservation_var == 4) {
if(amx_hideslots == 1) {
new players = get_playersnum(1)
new limit = g_maxplayers - amx_reservedslots
setVisibleSlots(players, limit)
}
}
}
kick(id) {
new amx_rslot_redirect = get_cvar_num("amx_rslot_redirect")
if(amx_rslot_redirect == 1) {
if (is_user_bot(id)) {
new lReason[128]
format(lReason, 127, "%L", id, "DROPPED_RESERV")
server_cmd("kick #%d %s", get_user_userid(id), lReason)
} else {
new redirectip[64], redirectpw[32]
get_pcvar_string(cvar_redirectip,redirectip,63)
get_pcvar_string(cvar_redirectpw,redirectpw,31)
client_cmd(id,"echo;echo -=====-;echo Redirecting...;echo -=====-;echo;wait;disconnect;password ^"%s^";serverpassword ^"%s^";connect %s",redirectpw,redirectpw,redirectip)
}
} else {
new lReason[128]
format(lReason, 127, "%L", id, "DROPPED_RESERV")
server_cmd("kick #%d %s", get_user_userid(id), lReason)
}
}
public client_authorized(id) {
new players = get_playersnum(1)
new limit, who
new amx_reservation_var = get_cvar_num("amx_reservation")
if(amx_reservation_var <= 0) return PLUGIN_CONTINUE
if(amx_reservation_var < 4) {
limit = g_maxplayers - 1
if(players > limit) {
if(get_user_flags(id) & ADMIN_RESERVATION) {
switch(amx_reservation_var) {
case 1:
who = kickShortestPlayingTime()
case 2:
who = kickLongestPlayingTime()
case 3:
who = kickLag()
}
if(who) {
new name[32]
get_user_name(who, name, 31)
console_print(id, "* %L", id, "WAS_KICKED", name)
}
return PLUGIN_CONTINUE
}
kick(id)
return PLUGIN_HANDLED
}
} else if(amx_reservation_var == 4) {
limit = g_maxplayers - get_cvar_num("amx_reservedslots")
if((get_user_flags(id) & ADMIN_RESERVATION) || (players <= limit)) {
if(get_cvar_num("amx_hideslots") == 1) {
setVisibleSlots(players, limit)
}
return PLUGIN_CONTINUE
}
kick(id)
}
return PLUGIN_CONTINUE
}
public client_disconnect(id) {
if(get_cvar_num("amx_reservation") == 4 && get_cvar_num("amx_hideslots") == 1) {
setVisibleSlots(get_playersnum(1) - 1, g_maxplayers - get_cvar_num("amx_reservedslots"))
}
return
}
kickShortestPlayingTime() {
new who = 0, itime, shortest = 0x7fffffff
for(new i = 1; i <= g_maxplayers; ++i) {
if(!is_user_connected(i) && !is_user_connecting(i))
continue
if(get_user_flags(i) & ADMIN_RESERVATION)
continue
itime = get_user_time(i)
if(shortest > itime) {
shortest = itime
who = i
}
}
if(who) {
console_print(who, "%L", who, "DROPPED_SHORTEST")
kick(who)
}
return who
}
kickLongestPlayingTime() {
new who = 0, itime, longest = -1
for(new i = 1; i <= g_maxplayers; ++i) {
if(!is_user_connected(i) && !is_user_connecting(i))
continue
if(get_user_flags(i) & ADMIN_RESERVATION)
continue
itime = get_user_time(i)
if(longest < itime) {
longest = itime
who = i
}
}
if(who) {
console_print(who, "%L", who, "DROPPED_LONGEST")
kick(who)
}
return who
}
kickLag() {
new who = 0, ping, loss, worst = -1
for(new i = 1; i <= g_maxplayers; ++i) {
if(!is_user_connected(i) && !is_user_connecting(i))
continue
if(get_user_flags(i) & ADMIN_RESERVATION)
continue
get_user_ping(i, ping, loss)
if(ping > worst) {
worst = ping
who = i
}
}
if(who) {
console_print(who, "%L", who, "DROPPED_HIGHPING")
kick(who)
}
return who
}
setVisibleSlots(players, limit) {
new num = players + 1
if(players == g_maxplayers) {
num = g_maxplayers
} else if(players < limit) {
num = limit
}
set_cvar_num("sv_visiblemaxplayers", num)
}
lang:
[en]
DROPPED_RESERV = Dropped due to slot reservation
WAS_KICKED = * "%s" was kicked to free this slot
DROPPED_SHORTEST = Dropped due to shortest playing time to free slot for an admin
DROPPED_LONGEST = Dropped due to longest playing time to free slot for an admin
DROPPED_HIGHPING = Dropped due to high ping to free slot for an admin
|