Vaigista m2ngija
Lehekülg 1, lehekülgi kokku 1 • Share
- Eduard
- Liitus : 28/09/2014
Postitusi : 321
Kuidas vaigistada m2ngija nii, et ta ei saaks kirjutada?
- Tonight
- Liitus : 19/02/2012
Postitusi : 18000
- Kood:
#include <amxmodx>
#include <amxmisc>
#include <engine>
// time in minutes
#define DEFAULT_GAG_TIME 10
#define DEFAULT_MUTE_TIME 10
// level to use amx_gag and amx_ungag
#define ADMIN_GAG ADMIN_LEVEL_A
new bool:g_AllowNameChange[33];
// text
new const g_TextGagTag[] = "[GAG]";
new bool:g_TextGagged[33];
new Float:g_TextGagTime[33];
new Float:g_PermTextGagged[100];
new g_TextGaggedAuthid[100][35];
new g_TotalTextGagLeaves;
// mute
new const g_MutedTag[] = "[MUTE]";
new bool:g_Muted[33];
new Float:g_MutedTime[33];
new Float:g_PermMuted[100];
new g_MutedAuthid[100][35];
new g_TotalMutedLeaves;
public plugin_init()
{
register_plugin("AMX Gag&Mute", "1.0", "Exolent");
register_concmd("amx_gag", "concmd_Gag", ADMIN_GAG, "<nick, #userid, authid> <time> -- leave time empty for rest of map");
register_concmd("amx_ungag", "concmd_Ungag", ADMIN_GAG, "<nick, #userid, authid>");
register_concmd("amx_mute", "concmd_Mute", ADMIN_GAG, "<nick, #userid, authid> <time> -- leave empty for rest of map");
register_concmd("amx_unmute", "concmd_Unmute", ADMIN_GAG, "<nick, #userid, authid>");
register_clcmd("say", "clcmd_Say");
register_clcmd("say_team", "clcmd_Say");
}
public client_putinserver(id)
{
g_TextGagged[id] = false;
g_TextGagTime[id] = 0.0;
g_Muted[id] = false;
g_MutedTime[id] = 0.0;
new authid[35], bool:text = false, mute = false;
if(g_TotalTextGagLeaves > 0)
{
get_user_authid(id, authid, 34);
for(new i=0; i < 100; i++)
{
if(equali(authid, g_TextGaggedAuthid[i]))
{
g_TextGagged[id] = true;
if(g_PermTextGagged[i] > -1.0)
set_task(g_PermTextGagged[i], "task_UngagPlayer", id + 112233);
g_TextGagTime[id] = g_PermTextGagged[i];
g_PermTextGagged[i] = 0.0;
g_TextGaggedAuthid[i][0] = '^0';
g_TotalTextGagLeaves--;
text = true;
break;
}
}
}
if(g_TotalMutedLeaves > 0)
{
if(!strlen(authid))
get_user_authid(id, authid, 34);
for(new i=0; i < 100; i++)
{
if(equali(authid, g_MutedAuthid[i]))
{
g_Muted[id] = true;
if(g_PermMuted[i] > -1.0)
set_task(g_PermMuted[i], "task_UnmutePlayer", id + 223344);
g_MutedTime[id] = g_PermMuted[i];
g_PermMuted[i] = 0.0;
g_MutedAuthid[i][0] = '^0';
g_TotalMutedLeaves--;
mute = true;
break;
}
}
}
if(text || mute)
{
new name[32], ip[64];
get_user_name(id, name, 31);
get_user_ip(id, ip, 63, 0);
if(text && mute)
{
client_print(0, print_chat, "[AMXX] A gagged&muted player has returned! %s", name);
format(name, 31, "%s%s%s", g_TextGagTag, g_MutedTag, name);
}
else if(text)
{
client_print(0, print_chat, "[AMXX] A gagged player has returned! %s", name);
format(name, 31, "%s%s", g_TextGagTag, name);
}
else if(mute)
{
client_print(0, print_chat, "[AMXX] A muted player has returned! %s", name);
format(name, 31, "%s%s", g_MutedTag, name);
}
client_print(0, print_chat, "[AMXX] IP: %s", ip);
g_AllowNameChange[id] = true;
set_user_name(id, name);
}
if(!mute)
set_speak(id, SPEAK_NORMAL);
else
set_speak(id, SPEAK_MUTED);
}
public client_disconnect(id)
{
if(!g_TextGagged[id] && !g_Muted[id])
return;
new authid[35], bool:text = g_TextGagged[id], mute = g_Muted[id];
get_user_authid(id, authid, 34);
if(g_TextGagged[id])
{
for(new i=0; i < 100; i++)
{
if(!strlen(g_TextGaggedAuthid[i]))
{
g_TextGagged[id] = false;
g_PermTextGagged[i] = g_TextGagTime[id];
formatex(g_TextGaggedAuthid[i], 34, authid);
g_TotalTextGagLeaves++;
text = true;
if(task_exists(id + 112233))
remove_task(id + 112233);
break;
}
}
}
if(g_Muted[id])
{
for(new i=0; i < 100; i++)
{
if(!strlen(g_MutedAuthid[i]))
{
g_Muted[id] = false;
g_PermMuted[i] = g_MutedTime[id];
formatex(g_MutedAuthid[i], 34, authid);
g_TotalMutedLeaves++;
mute = true;
if(task_exists(id + 223344))
remove_task(id + 223344);
break;
}
}
}
if(text || mute)
{
new name[32], ip[64];
get_user_name(id, name, 31);
get_user_ip(id, ip, 63, 0);
if(text && mute)
{
deletei(name, g_TextGagTag);
deletei(name, g_MutedTag);
client_print(0, print_chat, "[AMXX] A gagged&muted player has left! %s", name);
}
else if(text)
{
deletei(name, g_TextGagTag);
client_print(0, print_chat, "[AMXX] A gagged player has left! %s", name);
}
else if(mute)
{
deletei(name, g_MutedTag);
client_print(0, print_chat, "[AMXX] A muted player has left! %s", name);
}
client_print(0, print_chat, "[AMXX] IP: %s", ip);
}
}
public client_infochanged(id)
{
if(!g_TextGagged[id] && !g_Muted[id])
return;
if(g_AllowNameChange[id])
{
g_AllowNameChange[id] = false;
return;
}
new newname[32], oldname[32];
get_user_name(id, oldname, 31);
get_user_info(id, "name", newname, 31);
if(!equali(newname, oldname))
{
g_AllowNameChange[id] = true;
set_user_name(id, oldname);
}
}
public concmd_Gag(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED;
new arg[35];
read_argv(1, arg, 34);
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY);
if(!player)
return PLUGIN_HANDLED;
if(g_TextGagged[player])
{
client_print(id, print_console, "[AMXX] Client is already gagged!");
return PLUGIN_HANDLED;
}
new Float:gagtime;
if(read_argc() > 2)
{
read_argv(2, arg, 31);
gagtime = str_to_float(arg) * 60.0;
if(gagtime < 60.0)
gagtime = DEFAULT_GAG_TIME * 60.0;
}
else
gagtime = -1.0;
new gagtype[32];
if(!(gagtime > -1.0))
formatex(gagtype, 31, "until next map");
else
{
formatex(gagtype, 31, "for %.2f minutes", gagtime);
set_task(gagtime, "task_UngagPlayer", id + 112233);
}
new name_a[32], name_p[32];
new authid_a[35], authid_p[35];
get_user_name(id, name_a, 31);
get_user_name(player, name_p, 31);
get_user_authid(id, authid_a, 35);
get_user_authid(id, authid_p, 35);
show_activity(id, name_a, "gagged %s %s!", name_p, gagtype);
log_amx("%s <%s> gagged %s <%s> %s", name_a, authid_a, name_p, authid_p, gagtype);
format(name_p, 31, "%s%s", g_TextGagTag, name_p);
g_AllowNameChange[player] = true;
set_user_name(player, name_p);
g_TextGagged[player] = true;
g_TextGagTime[player] = gagtime;
return PLUGIN_HANDLED;
}
public concmd_Ungag(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED;
new arg[35];
read_argv(1, arg, 31);
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY);
if(!player)
return PLUGIN_HANDLED;
if(!g_TextGagged[player])
{
client_print(id, print_console, "[AMXX] Client was not gagged!");
return PLUGIN_HANDLED;
}
new name_a[32], name_p[32];
new authid_a[35], authid_p[35];
get_user_name(id, name_a, 31);
get_user_name(player, name_p, 31);
get_user_authid(id, authid_a, 35);
get_user_authid(id, authid_p, 35);
deletei(name_p, g_TextGagTag);
show_activity(id, name_a, "ungagged %s!", name_p);
log_amx("%s <%s> ungagged %s <%s>", name_a, authid_a, name_p, authid_p);
g_AllowNameChange[player] = true;
set_user_name(player, name_p);
g_TextGagged[player] = false;
g_TextGagTime[player] = 0.0;
if(task_exists(player + 112233))
remove_task(player + 112233);
return PLUGIN_HANDLED;
}
public concmd_Mute(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED;
new arg[35];
read_argv(1, arg, 34);
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY);
if(!player)
return PLUGIN_HANDLED;
if(g_Muted[player])
{
client_print(id, print_console, "[AMXX] Client is already muted!");
return PLUGIN_HANDLED;
}
new Float:mutetime;
if(read_argc() > 2)
{
read_argv(2, arg, 31);
mutetime = str_to_float(arg) * 60.0;
if(mutetime < 60.0)
mutetime = DEFAULT_MUTE_TIME * 60.0;
}
else
mutetime = -1.0;
new mutetype[32];
if(!(mutetime > -1.0))
formatex(mutetype, 31, "until next map");
else
{
formatex(mutetype, 31, "for %.2f minutes", mutetime);
set_task(mutetime, "task_UnmutePlayer", id + 223344);
}
new name_a[32], name_p[32];
new authid_a[35], authid_p[35];
get_user_name(id, name_a, 31);
get_user_name(player, name_p, 31);
get_user_authid(id, authid_a, 35);
get_user_authid(id, authid_p, 35);
show_activity(id, name_a, "muted %s %s!", name_p, mutetype);
log_amx("%s <%s> muted %s <%s> %s", name_a, authid_a, name_p, authid_p, mutetype);
format(name_p, 31, "%s%s", g_MutedTag, name_p);
g_AllowNameChange[player] = true;
set_user_name(player, name_p);
g_Muted[player] = true;
g_MutedTime[player] = mutetime;
set_speak(player, SPEAK_MUTED);
return PLUGIN_HANDLED;
}
public concmd_Unmute(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED;
new arg[35];
read_argv(1, arg, 31);
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY);
if(!player)
return PLUGIN_HANDLED;
if(!g_Muted[player])
{
client_print(id, print_console, "[AMXX] Client was not muted!");
return PLUGIN_HANDLED;
}
new name_a[32], name_p[32];
new authid_a[35], authid_p[35];
get_user_name(id, name_a, 31);
get_user_name(player, name_p, 31);
get_user_authid(id, authid_a, 35);
get_user_authid(id, authid_p, 35);
deletei(name_p, g_MutedTag);
show_activity(id, name_a, "unmuted %s!", name_p);
log_amx("%s <%s> unmuted %s <%s>", name_a, authid_a, name_p, authid_p);
g_AllowNameChange[player] = true;
set_user_name(player, name_p);
g_Muted[player] = false;
g_MutedTime[player] = 0.0;
if(task_exists(player + 223344))
remove_task(player + 223344);
return PLUGIN_HANDLED;
}
public clcmd_Say(id)
{
return g_TextGagged[id] ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
}
public task_UngagPlayer(id)
{
id -= 112233;
new name[32];
get_user_name(id, name, 31);
client_print(0, print_chat, "[AMXX] %s is now ungagged!", name);
g_TextGagged[id] = false;
g_TextGagTime[id] = 0.0;
}
public task_UnmutePlayer(id)
{
id -= 223344;
new name[32];
get_user_name(id, name, 31);
client_print(0, print_chat, "[AMXX] %s is now unmuted!", name);
g_Muted[id] = false;
g_MutedTime[id] = 0.0;
}
set_user_name(id, const name[])
{
set_user_info(id, "name", name);
client_cmd(id, "name ^"%s^"", name);
}
deletei(text[], const what[])
{
new pos = containi(text, what);
new len, i;
while(pos >= 0)
{
len = strlen(what);
i = 0;
while(text[pos+len+i] != 0)
{
text[pos+i] = text[pos+len+i];
i++;
}
text[pos+i] = '^0';
pos = containi(text, what);
}
}
http://www.amxmodx.org/webcompiler.cgi
- Eduard
- Liitus : 28/09/2014
Postitusi : 321
Olemas, t2nud!
Soovid vestluses osaleda?
Selleks logi sisse või tee endale kasutaja.
Lehekülg 1, lehekülgi kokku 1
Permissions in this forum:
Sa ei saa vastata siinsetele teemadele