Raised This Month: $ Target: $400
 0% 

[Fix] Admin Super Gag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Speedy'
Member
Join Date: Jan 2009
Old 04-08-2010 , 12:38   [Fix] Admin Super Gag
Reply With Quote #1

I've founded a nice gag plugin, and customized with colorchat, but now i get some errors.. hope one of you guys help me:

admin_super_gag.sma
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <time>
#include <colorchat>

#define PLUGIN "Super Gag"
#define VERSION "1.5"
#define AUTHOR "Numb"

#define GAGGED_SAY 1
#define GAGGED_SAY_TEAM 2
#define GAGGED_VOICE 3
#define GAGGED_NAME 4
#define GAG_TIME_LIMIT SECONDS_IN_DAY

new dataDir[64];
new 
amx_default_gag_time;
new 
amx_gag_by_authid;

new 
bool:wasgagged[33];
new 
bool:wasmuted[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_dictionary("common.txt");
    
register_dictionary("time.txt");
    
register_concmd("amx_gag""cmdGag"ADMIN_LEVEL_B"<name> [reason] <time (1m/60)> <flags abcd> ");
    
register_concmd("amx_ungag""cmdUnGag"ADMIN_LEVEL_B"<name> [reason] <ip/authid=1>");
    
register_concmd("say""cmdSay", -1" - check gagged player");
    
register_concmd("say_team""cmdSayTeam", -1" - check gagged player");
    
amx_default_gag_time register_cvar("amx_default_gag_time""10");
    
amx_gag_by_authid register_cvar("amx_gag_by_authid""0")
    
register_message(get_user_msgid("SayText"), "block_namechange_msg");
    
get_datadir(dataDir63);
}

public 
plugin_modules()
    
require_module("engine");

public 
cmdGagInfo(id)
{
    new 
filename[128], playerip[32], gagtime[128], fileDir[96];
    
fileDir get_gagsdir();
    if( 
get_pcvar_num(amx_gag_by_authid) )
    {
        
get_user_authid(idplayerip31);
        
replace_all(playerip31":""_");
        
format(filename127"%s/%s.txt"fileDirplayerip);
    }
    else
    {
        
get_user_ip(idplayerip311);
        
format(filename127"%s/%s.txt"fileDirplayerip);
        if( !
file_exists(filename) )
        {
            new 
server_ip[32];
            
get_user_ip(0server_ip311);
            if( 
equal(playeripserver_ip) )
                
format(filename127"%s/loopback.txt"fileDir);
            else if( 
equal(playerip"loopback") )
                
format(filename127"%s/%s.txt"fileDirserver_ip);
        }
    }
    
    if( 
file_exists(filename) )
    {
        new 
gag_saygag_say_teamauthid_gags get_pcvar_num(amx_gag_by_authid);
        
gag_say is_user_gagged(idGAGGED_SAYauthid_gags);
        
gag_say_team is_user_gagged(idGAGGED_SAY_TEAMauthid_gags);
        if( 
gag_say && gag_say_team )
            
ColorChat(idBLUE"[Extaziuss]^x01 Ai GAG ! Dupa ce iti va expira vei putea scrie din nou." );
        else
            
ColorChat(idBLUE"[Extaziuss]^x01 Ai GAG ! Dupa ce iti va expira vei putea scrie din nou." );
        
        new 
reason[64], txtsizetime;
        
read_file(filename7reason63txtsize);
        if( 
reason[0] )
            
ColorChat(idBLUE"[Extaziuss]^x01 Motivul pentru care ai primit GAG: ^x04%s."reason);
        else
            
ColorChat(idBLUE"[Extaziuss]^x01 Motivul pentru care ai primit GAG: ^x04Nespecificat.");
            
        
read_file(filename1gagtime127txtsize);
        
time str_to_num(gagtime)-get_systime(1);
        
ColorChat(idBLUE"[Extaziuss]^x01 GAG'ul iti va expira in ^x04%s."convert_time(time));
    }
    else
        
ColorChat(idGREEN"[Extaziuss]^x01 Nu mai ai ^x03GAG");
}

public 
cmdSay(id)
{
    new 
text[192], gaggedtext_len;
    
read_argv(1text191);
    
text_len strlen(text);
    if( 
text_len )
    {
        if( 
text[0] == '"' && text[text_len-1] == '"' )
            
format(texttext_len-2"%s"text[1]);
    }
    
    
gagged is_user_gagged(idGAGGED_SAYget_pcvar_num(amx_gag_by_authid));
    if( (
equal(text"/gaginfo") || equal(text".gaginfo")) && read_argc() == )
    {
        
cmdGagInfo(id);
        if( 
gagged )
            return 
PLUGIN_HANDLED;
    }
    if( 
gagged )
    {
        
ColorChat(idBLUE"[Extaziuss]^x01 Ai primit GAG! Scrie ^x04/gaginfo^x01 pentru mai multe informatii.");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
cmdSayTeam(id)
{
    new 
text[192], gaggedtext_len;
    
read_argv(1text191);
    
text_len strlen(text);
    if( 
text_len )
    {
        if( 
text[0] == '"' && text[text_len-1] == '"' )
            
format(texttext_len-2"%s"text[1]);
    }
    
    
gagged is_user_gagged(idGAGGED_SAY_TEAMget_pcvar_num(amx_gag_by_authid));
    if( (
equal(text"/gaginfo") || equal(text".gaginfo")) && read_argc() == )
    {
        
cmdGagInfo(id);
        if( 
gagged )
            return 
PLUGIN_HANDLED;
    }
    if( 
gagged )
    {
        
ColorChat(idBLUE"[Extaziuss] Ai primit GAG! Scrie ^x04/gaginfo^x01 pentru mai multe informatii.");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
client_putinserver(id)
{
    
set_task(1.0"client_connected"id);
    if( 
is_user_gagged(id0get_pcvar_num(amx_gag_by_authid)) )
        
wasgagged[id] = true;
    else
        
wasgagged[id] = false;
}

public 
client_connected(id)
{
    if( 
is_user_gagged(idGAGGED_VOICEget_pcvar_num(amx_gag_by_authid)) )
    {
        
client_cmd(id"-voicerecord");
        
set_speak(idSPEAK_MUTED);
        
wasmuted[id] = true;
    }
    else
        
wasmuted[id] = false;
    
check_gagged_name(id0);
}

public 
block_namechange_msg(msgidmsgdestmsgent)
{
    new 
msgtype[32];
    
get_msg_arg_string(2msgtype31);
    if( 
equal(msgtype"#Cstrike_Name_Change") )
    {
        new 
playernewname[32], custom_newname[32];
        
get_msg_arg_string(4newname31);
        for( 
player 1player 33player++ )
        {
            if( 
is_valid_ent(player) && is_user_connected(player) && is_user_alive(player) )
            {
                
custom_newname "";
                
get_user_info(player"name"custom_newname31);
                if( 
equal(newnamecustom_newname) )
                    break;
            }
            
            if( 
player == 32 )
            {
                
player 0;
                break;
            }
        }
        
        if( 
player )
        {
            if( 
is_user_gagged(playerGAGGED_NAMEget_pcvar_num(amx_gag_by_authid)) )
                return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
client_infochanged(id)
{
    if( 
is_user_gagged(idGAGGED_NAMEget_pcvar_num(amx_gag_by_authid)) )
    {
        
check_gagged_name(id1);
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
check_gagged_name(idnamechange)
{
    new 
authid_gags get_pcvar_num(amx_gag_by_authid);
    if( 
is_user_gagged(idGAGGED_NAMEauthid_gags) )
    {
        new 
filename[128], fileDir[96], playerip[32], gaggedname[32], newname[32];
        
fileDir get_gagsdir();
        if( 
authid_gags )
        {
            
get_user_authid(idplayerip31);
            
replace_all(playerip31":""_");
        }
        else
            
get_user_ip(idplayerip311);
        
        
format(filename127"%s/%s.txt"fileDirplayerip);
        
        if( !
file_exists(filename) && !authid_gags )
        {
            new 
server_ip[32];
            
get_user_ip(0server_ip311);
            if( 
equal(playeripserver_ip) )
                
format(filename127"%s/loopback.txt"fileDir);
            else if( 
equal(playerip"loopback") )
                
format(filename127"%s/%s.txt"fileDirserver_ip);
            
            if( !
file_exists(filename) )
                return;
        }
        
        new 
txtsize;
        
read_file(filename5gaggedname31txtsize);
        
get_user_info(id"name"newname31);
        
        if( !
equal(gaggednamenewname) )
        {
            if( 
namechange )
            {
                
ColorChat(idBLUE"[Extaziuss] Ai GAG! Dupa ce iti va expira iti vei putea schimba numele");
                
set_user_info(id"name"gaggedname);
            }
            else
                
client_cmd(id"name ^"%s^""gaggedname);
        }
    }
}

public 
client_PreThink(id)
{
    if( 
is_user_connected(id) )
    {
        static 
authid_gags;
        
authid_gags get_pcvar_num(amx_gag_by_authid);
        if( !
is_user_gagged(idGAGGED_VOICEauthid_gags) && wasmuted[id] )
        {
            
set_speak(idSPEAK_NORMAL);
            
wasmuted[id] = false;
        }
        
        if( 
is_user_gagged(id0authid_gags) )
            
wasgagged[id] = true;
        else if( 
wasgagged[id] )
        {
            
wasgagged[id] = false;
            if( 
get_user_time(id0) > )
                
ColorChat(idBLUE"[Extaziuss]^x01 Nu mai ai GAG!");
        }
    }
}

public 
cmdGag(idlevelcid)
{
    if( !
cmd_access(idlevelcid2) )
        return 
PLUGIN_HANDLED

    
new target[32], player;
    
read_argv(1target31);
    
player cmd_target(idtarget9);
    
    if( !
player)
        return 
PLUGIN_HANDLED;
    
    new 
sgagtime[32], flags[32], reason[64], gagtime;
    
read_argv(2reason63);
    
read_argv(3sgagtime31);
    
read_argv(4flags31);
    
remove_quotes(reason);
    
    if( 
sgagtime[0] )
    {
        if( 
contain(sgagtime,"m") > )
        {
            new 
sgagtime2[32];
            
copyc(sgagtime231sgagtime'm');
            
gagtime str_to_num(sgagtime2)*60;
        }
        else
            
gagtime str_to_num(sgagtime);
    }
    else
        
gagtime get_pcvar_num(amx_default_gag_time)*60;
    if( 
gagtime || gagtime GAG_TIME_LIMIT )
        
gagtime GAG_TIME_LIMIT;
    
    new 
newflags[32];
    
format(flags31"_%s"flags);
    if( 
contain(flags"d") > )
        
format(newflags7"d");
    if( 
contain(flags"c") > )
        
format(newflags7"c%s"newflags);
    if( 
contain(flags"b") > )
        
format(newflags7"b%s"newflags);
    if( 
contain(flags"a") > )
        
format(newflags7"a%s"newflags);
    if( !
newflags[0] )
        
newflags "abcd";
    
format(flags31"_%s_"newflags);
    
    new 
authid[32], authid2[32], playerip[32], playerip2[32], name[32], name2[32], useriduserid2;
    
get_user_authid(idauthid31);
    
get_user_authid(playerauthid231);
    
get_user_ip(idplayerip311);
    
get_user_ip(playerplayerip2311);
    
get_user_name(idname31);
    
get_user_name(playername231);
    
userid get_user_userid(id);
    
userid2 get_user_userid(player);
    
    new 
gag_saygag_say_teamgag_voice;
    
gag_say = (contain(flags"a") > 0);
    
gag_say_team = (contain(flags"b") > 0);
    
gag_voice = (contain(flags"c") > 0);
    if( !
reason[0] )
        
reason "Nespecificat";
    
    if( 
gag_voice )
    {
        
client_cmd(player"-voicerecord");
        
set_speak(playerSPEAK_MUTED);
        
wasmuted[player] = true;
    }
    new 
gaggedtimefilename[128];
    
gaggedtime gagtime get_systime(1);
    
    if( 
get_pcvar_num(amx_gag_by_authid) )
    {
        
filename authid2;
        
replace_all(filename31":""_");
        
format(filename127"%s/%s.txt"get_gagsdir(), filename);
    }
    else
        
format(filename127"%s/%s.txt"get_gagsdir(), playerip2);
    
    if( 
file_exists(filename) )
        
delete_file(filename);
        
    new 
sgagtime3[128];
    
num_to_str(gaggedtimesgagtime3127);
    
write_file(filename"Time data:");
    
write_file(filenamesgagtime3);
    
write_file(filename"Flags:");
    
write_file(filenameflags);
    
write_file(filename"Player name:");
    
write_file(filenamename2);
    
write_file(filename"Reason:");
    
write_file(filenamereason);
    
    
log_amx("Gag: ^"%s<#%d><%s><%s>^" gagged ^"%s<#%d><%s><%s>^" <%s> for <%ds> (reason: ^"%s^")", name, userid, authid, playerip, name2, userid2, authid2, playerip2, newflags, gagtime, reason);
    
    
format(reason127"pentru ^x03%s^x01 [Motiv: ^x04%s^x01]"convert_time(gagtime), reason);
    
    if( 
gag_say && gag_say_team )
    {
        switch(
get_cvar_num("amx_show_activity"))
        {
            case 
2ColorChat(0BLUE"[Extaziuss]^x04 %s ^x01i-a dat GAG lui ^x03%s ^x01%s"namename2reason);
            case 
1ColorChat(0BLUE"[Extaziuss]^x01 Jucatorul ^x03%s^x01 a primit GAG ^x01%s"name2reason);
        }
    }
    else
    {
        switch(
get_cvar_num("amx_show_activity"))
        {
            case 
2ColorChat(0BLUE"[Extaziuss]^x04 %s^x01 i-a dat GAG lui ^x03%s ^x01%s"namename2reason);
            case 
1ColorChat(0BLUE"[Extaziuss]^x01 Jucatorul ^x03%s^x01 a primit GAG ^x01%s"name2reason);
        }
    }
        
    
console_print(id"[Extaziuss] Jucatorul ^"%s^" a primit GAG !"name2);
    
    return 
PLUGIN_HANDLED;
}

public 
cmdUnGag(idlevelcid)
{
    if( !
cmd_access(idlevelcid2) )
        return 
PLUGIN_HANDLED

    
new target[32], playerip[32], reason[64];
    
read_argv(1target31);
    
read_argv(2reason63);
    
read_argv(3ip31);

    
remove_quotes(reason);
    if( !
reason[0] )
        
reason "Nespecificat";
    
    new 
authid[32], playerip[32], name[32], userid;
    
get_user_authid(idauthid31);
    
get_user_ip(idplayerip311);
    
get_user_name(idname31);
    
userid get_user_userid(id);
    if( !
str_to_num(ip) )
    {
        
player cmd_target(idtarget9);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
        
        new 
authid2[32], playerip2[32], name2[32], userid2;
        
get_user_authid(playerauthid231);
        
get_user_ip(playerplayerip2311);
        
get_user_name(playername231);
        
userid2 get_user_userid(player);
        
        new 
filename[128], fileDir[96], authid_gags get_pcvar_num(amx_gag_by_authid);
        
fileDir get_gagsdir();
        
        if( 
authid_gags )
        {
            
filename authid2;
            
replace_all(filename31":""_");
            
format(filename127"%s/%s.txt"fileDirfilename);
        }
        else
            
format(filename127"%s/%s.txt"fileDirplayerip2);
        
        
format(filename127"%s/%s.txt"fileDirplayerip2);
        if( 
file_exists(filename) )
            
delete_file(filename);
        else if( !
authid_gags )
        {
            new 
server_ip[32];
            
get_user_ip(0server_ip311);
            if( 
equal(playerip2server_ip) )
                
format(filename127"%s/loopback.txt"fileDir);
            else if( 
equal(playerip2"loopback") )
                
format(filename127"%s/%s.txt"fileDirserver_ip);
            if( !
file_exists(filename) )
            {
                
console_print(id"[Extaziuss] Error: Jucatorul ^"%s^" nu are GAG !"name2);
                return 
PLUGIN_HANDLED;
            }
        }
        else
        {
            
console_print(id"[Extaziuss] Error: Jucatorul ^"%s^" nu are GAG !"name2);
            return 
PLUGIN_HANDLED;
        }
        
        
log_amx("Gag: ^"%s<#%d><%s><%s>^" ungagged ^"%s<#%d><%s><%s>^" (reason: ^"%s^")", name, userid, authid, playerip, name2, userid2, authid2, playerip2, reason);
        
        
switch(get_cvar_num("amx_show_activity"))
        {
            case 
2ColorChat(0BLUE"[Extaziuss]^x04 %s ^x01i-a scos GAG'ul lui ^x03%s ^x01[Motiv: ^x04%s^x01]"namename2reason);
            case 
1ColorChat(0BLUE"[Extaziuss]^x01 Jucatorului ^x03%s^x01 i-a fost scos GAG'ul [Motiv: ^x04%s^x01]"name2reason);
        }
        
        
console_print(id"[Extaziuss] Jucatorului ^"%s^" i-a fost scos GAG'ul !"name2);
        return 
PLUGIN_HANDLED;
    }
    new 
filename[128], fileDir[96], authid_gags get_pcvar_num(amx_gag_by_authid);
    
fileDir get_gagsdir();
    
    if( 
authid_gags )
    {
        
filename target;
        
replace_all(filename31":""_");
        
format(filename127"%s/%s.txt"fileDirfilename);
    }
    else
        
format(filename127"%s/%s.txt"fileDirtarget);
    
    if( !
file_exists(filename) )
    {
        if( !
authid_gags )
        {
            new 
server_ip[32];
            
get_user_ip(0server_ip311);
            if( 
equal(targetserver_ip) )
                
format(filename127"%s/loopback.txt"fileDir);
            else if( 
equal(target"loopback") || equal(target"localhost") )
                
format(filename127"%s/%s.txt"fileDirserver_ip);
            if( !
file_exists(filename) )
            {
                
console_print(id"[Extaziuss] Error: IP'ul ^"%s^" nu a fost gasit !"target);
                return 
PLUGIN_HANDLED;
            }
        }
        else
        {
            
console_print(id"[Extaziuss] Error: IP'ul ^"%s^" nu a fost gasit !"target);
            return 
PLUGIN_HANDLED;
        }
    }
    
    new 
name2[32], txtsize;
    
read_file(filename5name231txtsize);
    
    new 
userplayerip2[32], playerip3[32], authid2[32], userid2;
    for( 
user 1user 33user++ )
    {
        if( 
is_user_connected(user) )
        {
            if( 
authid_gags )
                
get_user_authid(userplayerip331);
            else
                
get_user_ip(userplayerip3311);
            
            if( 
equal(targetplayerip3) > )
            {
                
userid2 get_user_userid(user);
                if( 
authid_gags )
                {
                    
authid2 playerip3;
                    
get_user_ip(userplayerip2311);
                }
                else
                {
                    
playerip2 playerip3;
                    
get_user_authid(userauthid231);
                }    
                if( 
is_user_gagged(userGAGGED_NAMEauthid_gags) )
                    
client_cmd(user"name ^"%s^""name2);
                else
                    
get_user_name(username231);
            }
        }
    }
    
    
delete_file(filename);
    
    
log_amx("Gag: ^"%s<#%d><%s><%s>^" ungagged by ip/authid ^"%s<#%d><%s><%s>^" (reason: ^"%s^")", name, userid, authid, playerip, name2, userid2, authid2, playerip2, reason);
    
    
switch(get_cvar_num("amx_show_activity"))
    {
        case 
2ColorChat(0BLUE"[Extaziuss]^x04 %s ^x01i-a scos GAG'ul lui ^x03%s (^x01%s^x03)^x01 [Motiv: ^x04%s^x01]"namename2targetreason);
        case 
1client_print(0print_chat"[Extaziuss] Jucatorului %s (%s) i-a fost scos GAG'ul ! [Motiv: %s]"name2targetreason);
    }
    
    
console_print(id"[Extaziuss] Jucatorului ^"%s^" cu IP'ul ^"%s^" i-a fost scos GAG'ul"name2target);
    
    return 
PLUGIN_HANDLED;
}

stock is_user_gagged(idflagauthid_gags)
{
    
    new 
filename[128], fileDir[96], playerip[32];
    
fileDir get_gagsdir();
    
    if( 
authid_gags )
    {
        
get_user_authid(idplayerip31);
        
replace_all(playerip31":""_");
        
format(filename127"%s/%s.txt"fileDirplayerip);
    }
    else
    {
        
get_user_ip(idplayerip311);
        
format(filename127"%s/%s.txt"fileDirplayerip);
    }
    
    if( !
file_exists(filename) )
    {
        if( 
authid_gags )
            return 
0;
        
        new 
server_ip[32];
        
get_user_ip(0server_ip311);
        if( 
equal(playeripserver_ip) )
            
format(filename127"%s/loopback.txt"fileDir);
        else if( 
equal(playerip"loopback") )
            
format(filename127"%s/%s.txt"fileDirserver_ip);
        if( !
file_exists(filename) )
            return 
0;
    }
    
    new 
gagtime[128], gagflags[32], txtsize;
    
read_file(filename1gagtime127txtsize);
    if( !(
str_to_num(gagtime) > get_systime(1)) )
    {
        
delete_file(filename);
        return 
0;
    }
    
    
read_file(filename3gagflags31txtsize);
    new 
g_sayg_say_teamg_voiceg_name;
    
g_say = (contain(gagflags"a") > 0);
    
g_say_team = (contain(gagflags"b") > 0);
    
g_voice = (contain(gagflags"c") > 0);
    
g_name = (contain(gagflags"d") > 0);
    if( !(
g_say || g_say_team || g_voice || g_name ) )
    {
        
log_amx("[GAG] Error: No flags found in <^"%s^"> file! Deleting file."filename);
        
delete_file(filename);
        return 
0;
    }
    
    if( 
flag == GAGGED_SAY )
    {
        if( 
g_say )
            return 
1;
    }
    else if( 
flag == GAGGED_SAY_TEAM )
    {
        if( 
g_say_team )
            return 
1;
    }
    else if( 
flag == GAGGED_VOICE )
    {
        if( 
g_voice )
            return 
1;
    }
    else if( 
flag == GAGGED_NAME )
    {
        if( 
g_name )
            return 
1;
    }
    else
        return 
1;
    
    return 
0;
}

stock convert_time(time)
{
    new 
TimeMsg[128];
    
get_time_length(0timetimeunit_secondsTimeMsg127);
    return 
TimeMsg;
}

stock get_gagsdir()
{
    new 
gagDir[96];
    
format(gagDir95"%s/gags"dataDir);
    if( !
dir_exists(gagDir) )
        
mkdir(gagDir);
    return 
gagDir;

And the erros:
Code:
L 04/08/2010 - 01:06:53: [AMXX] Displaying debug trace (plugin "admin_super_gag.amxx")
L 04/08/2010 - 01:06:53: [AMXX] Run time error 4: index out of bounds 
L 04/08/2010 - 01:06:53: [AMXX]    [0] colorchat.inc::ColorChat (line 76)
L 04/08/2010 - 01:06:53: [AMXX]    [1] admin_super_gag.sma::check_gagged_name (line 248)
L 04/05/2010 - 01:06:53: [AMXX]    [2] admin_super_gag.sma::client_infochanged (line 204)
Thanks in advance
__________________
Sorry for my English
Speedy' is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode