Drak, your code lets the player change his nick once between 20s for 3 times & kick the 4th time? And there is no ct[id] reset on case 1, 2, 3 & 4 if this:
Code:
if(Time - g_LastTime[id] <= get_pcvar_float(nft)) returns false
I know case 1 & 2 doesn't exist, but it should, at least somehow, because the switch will not catch ct[id] any more after it exceeds 4.
I mentioned in the first post that the 20 sec are for all the nick changes

& kick on 4th if less then 20 sec passed form the 1st change.
Anyway, in the end i tried to code it myself using a switch, with a bit of perseverance (about ~2 hours) i made it work & this is how it looks like:
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "name flood protection"
#define VERSION "0.4.1"
#define AUTHOR "camper"
#pragma semicolon 1
new ct[33], Float:start_time[33], nft;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
nft = register_cvar("amx_name_flood_time", "20");
}
public client_putinserver(id)
{
ct[id] = -1;
start_time[id] = 0.0;
}
public client_infochanged(id)
{
static new_name[33], old_name[33];
get_user_info(id, "name",new_name, 32);
get_user_name(id, old_name, 32);
if(equal(new_name, old_name))
return PLUGIN_HANDLED;
if((ct[id]!=-1) && (get_gametime() - start_time[id] > get_pcvar_num(nft)))
{
ct[id] = -1;
}
switch(++ct[id])
{
case 0:
{
start_time[id] = get_gametime();
ct[id]++;
}
case 3:
{
client_print(id, print_chat, "*** Nick change flood! ***");
client_print(id, print_chat, "*** Stop or you will be kicked! ***");
}
case 4:
{
server_cmd("kick #%d ^"%s^"", get_user_userid(id), "Kicked due to name change flood.");
}
}
return PLUGIN_CONTINUE;
}
I'll appreciate any advice, mostly regarding improvement, i hope...