#include <amxmodx>
#include <reapi>
#define NEXT_CHANGE_TIME 300
new Float:g_fNextNameChange[MAX_CLIENTS + 1]
public plugin_init()
{
register_plugin("NameChangeTime", "0.0.1", "Vaqtincha")
RegisterHookChain(RG_CBasePlayer_SetClientUserInfoName, "CBasePlayer_SetUserInfoName", .post = false)
}
public client_putinserver(pPlayer){
g_fNextNameChange[pPlayer] = 0.0
}
public CBasePlayer_SetUserInfoName(const pPlayer, infobuffer[], szNewName[])
{
new Float:fCurtime = get_gametime()
if(g_fNextNameChange[pPlayer] > fCurtime)
{
PrintMsg(pPlayer, "!n[!gСервер!n] Cледующая смена ника доступна через !g%0.f!n секунд.", g_fNextNameChange[pPlayer] - fCurtime)
SetHookChainReturn(ATYPE_INTEGER, false)
return HC_SUPERCEDE
}
g_fNextNameChange[pPlayer] = fCurtime + NEXT_CHANGE_TIME.0
return HC_CONTINUE
}
stock PrintMsg(const id, const Message[], any:...)
{
if(!is_user_connected(id))
{
return;
}
new szMsg[190];
vformat(szMsg, charsmax(szMsg), Message, 3);
while(replace(szMsg, charsmax(szMsg), "!n", "^1")) {}
while(replace(szMsg, charsmax(szMsg), "!t", "^3")) {}
while(replace(szMsg, charsmax(szMsg), "!g", "^4")) {}
message_begin(MSG_ONE_UNRELIABLE, 76, _, id);
write_byte(id);
write_string(szMsg);
message_end();
}