Raised This Month: $ Target: $400
 0% 

Float does not work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
monolit
Junior Member
Join Date: May 2011
Old 05-15-2011 , 05:32   Float does not work
Reply With Quote #1

PHP Code:

Why the mute is not working ? I set user mute but he is still able to chat, same with ban.

Right. xD

######## PROBLEM 2 ########

Why the hell when I Mute player, he gets muted and after reconnect he is still muted, but when I ban player, server kicks him and he can join server again, even if he is banned.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Tutorial"
#define VERSION "1.0"
#define AUTHOR "Grim"

new Host[]     = "127.0.0.1"
new User[]    = "root"
new Pass[]     = ""
new Db[]     = "amx"


new Handle:g_SqlTuple
new g_Error[512]


new 
iMute[33];
new 
iBan[33];
new 
iMuteReason[33][255];
new 
iMuteAdmin[33][32];
new 
iBanReason[33][255];
new 
iBanAdmin[33][32];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
        
    
set_task(1.0"MySql_Init")
    
    
register_clcmd("say ""CmdSay")
    
register_clcmd("say_team ""CmdSayTeam")
    
    
register_clcmd("say !banhelp""CmdBanHelp")
    
register_clcmd("say !kickhelp""CmdKickHelp")
    
register_clcmd("say !mutehelp""CmdMuteHelp")
}

public 
CmdKickHelp(id)
{
    if(!(
get_user_flags(id) & ADMIN_BAN))
        return 
PLUGIN_HANDLED;
    
    
client_print_color(idDontChange"^4[ INFO ]^1 Kick help printed to your ^3console")
    
client_print(idprint_console"---------------------------")
    
client_print(idprint_console"-------- Kick help --------")
    
client_print(idprint_console"*** !kick player_name kick_reason")
    
client_print(idprint_console"*** player_name - part of player name, example: player")
    
client_print(idprint_console"*** kick_reason - reason of kick, example: away from keyboard")
    
client_print(idprint_console"-------- Kick help --------")
    
client_print(idprint_console"---------------------------")
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdMuteHelp(id)
{
    if(!(
get_user_flags(id) & ADMIN_BAN))
        return 
PLUGIN_HANDLED;
    
    
client_print_color(idDontChange"^4[ INFO ]^1 Mute help printed to your ^3console")
    
client_print(idprint_console"--------------------------")
    
client_print(idprint_console"-------- Mute help -------")
    
client_print(idprint_console"*** !mute player_name mute_time mute_reason")
    
client_print(idprint_console"*** player_name - part of player name, example: player")
    
client_print(idprint_console"*** mute_time - time of mute (m | h), example: 5m (Max time is 6 hours)")
    
client_print(idprint_console"*** mute_reason - reason of mute, example: use of abusive language")
    
client_print(idprint_console"-------- Mute help -------")
    
client_print(idprint_console"--------------------------")
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdBanHelp(id)
{
    if(!(
get_user_flags(id) & ADMIN_BAN))
        return 
PLUGIN_HANDLED;
    
    
client_print_color(idDontChange"^4[ INFO ]^1 Ban help printed to your ^3console")
    
client_print(idprint_console"--------------------------")
    
client_print(idprint_console"-------- Ban help --------")
    
client_print(idprint_console"*** !ban player_name ban_time ban_reason")
    
client_print(idprint_console"*** player_name - part of player name, example: player")
    
client_print(idprint_console"*** ban_time - time of ban (m | h | d), example: 5m (Max time is 7 days)")
    
client_print(idprint_console"*** ban_reason - reason of ban, example: advertising")
    
client_print(idprint_console"-------- Ban help --------")
    
client_print(idprint_console"--------------------------")
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdSay(id) {
    if(
iMute[id] > get_systime() )
    {
        static 
iTimeLeftiHoursiMinutesiSeconds
        iTimeLeft 
iMute[id] - get_systime()
        
iHours iTimeLeft 86400 3600
        iMinutes 
iTimeLeft 3600 60
        iSeconds 
iTimeLeft 60
        
        
if(iHours 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 hour%s and ^3%d^1 minute%s "iHoursiHours "s" ""iMinutesiMinutes "s" "")
        }
        else if(
iMinutes 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 minute%s and ^3%d^1 second%s "iMinutesiMinutes "s" ""iSecondsiSeconds "s" "")
        }
        else if(
iSeconds 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 second%s "iSecondsiSeconds "s" "")
        }
        return 
PLUGIN_HANDLED;
    }
        
    if(~
get_user_flags(id) & ADMIN_BAN)
        return 
PLUGIN_CONTINUE;
        
    new 
szArg[192]
    
read_args(szArgcharsmax(szArg))
    
remove_quotes(szArg)
    new 
szCmd[12], szTarget[12], szTime[4], szReason[50]
    
strbreak(szArgszCmdcharsmax(szCmd), szArgcharsmax(szArg))
    if(
equali(szCmd"!mute"))
    {
        
strbreak(szArgszTargetcharsmax(szTarget), szArgcharsmax(szArg))
        
strbreak(szArgszTimecharsmax(szTime), szReasoncharsmax(szReason))
        
        if(!
szTarget[0] || !szTime[0] || !szReason[0])
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!mute player_name mute_time mute_reason")
            return 
PLUGIN_HANDLED_MAIN;
        }
        
        new 
szAdminName[33];
        
get_user_name(idszAdminName32)
        
        new 
player cmd_target(idszTarget);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
            
        new 
iMuteTime;
        if(
containi(szTime"m") != -1)
        {
            
replace(szTimecharsmax(szTime), "m""")
            
iMuteTime str_to_num(szTime) * 60
        
}
        else if(
containi(szTime"h") != -1)
        {
            
replace(szTimecharsmax(szTime), "h""")
            
iMuteTime str_to_num(szTime) * 60 60
        
}
        else if(
containi(szTime"d") != -1)
        {
            
replace(szTimecharsmax(szTime), "d""")
            
iMuteTime str_to_num(szTime) * 60 60 24
        
}
        
        if( 
iMuteTime 21600 )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Mute time can not exceed 6 hours")
            return 
PLUGIN_HANDLED
        
}
        else if( 
iMuteTime <= )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Mute time is not valid")
            return 
PLUGIN_HANDLED
        
}
        
        
iMute[player] = get_systime() + iMuteTime;
            
        new 
szTargetName[33];
        
get_user_name(playerszTargetName32)
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
            case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
        }
        
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_CTclient_print_color(playerBLUE"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)
            case 
CS_TEAM_Tclient_print_color(playerRED"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(playerGREY"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)
        }
        new 
szIp[33];
        
get_user_ip(playerszIp321)
        
        new 
szTemp[512]
        
format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `mute_time`, `mute_reason`, `mute_admin`)VALUES ('%s','%d', '%s', '%s');"szIpiMute[player], szReasonszAdminName)
        
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    if(
equali(szCmd"!ban"))
    {
        
strbreak(szArgszTargetcharsmax(szTarget), szArgcharsmax(szArg))
        
strbreak(szArgszTimecharsmax(szTime), szReasoncharsmax(szReason))
        
        if(!
szTarget[0] || !szTime[0] || !szReason[0])
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!ban player_name ban_time ban_reason")
            return 
PLUGIN_HANDLED_MAIN;
        }
        
        new 
szAdminName[33];
        
get_user_name(idszAdminName32)
        
        new 
player cmd_target(idszTarget);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
        new 
PrintTime[15];
        if(
equali(szTime"m") != -1)
        {
            
replace(szTimecharsmax(szTime), "m""")
            
formatex(PrintTime14"%d minute%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }else if(
equali(szTime"h") != -1)
        {
            
replace(szTimecharsmax(szTime), "h""")
            
formatex(PrintTime14"%d hour%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }else if(
equali(szTime"d") != -1)
        {
            
replace(szTimecharsmax(szTime), "d""")
            
formatex(PrintTime14"%d day%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }
        else
        {
            
formatex(PrintTime14"%d second%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }
        
        
        new 
iBanTime;
        if(
containi(szTime"m") != -1)
        {
            
replace(szTimecharsmax(szTime), "m""")
            
iBanTime str_to_num(szTime) * 60
        
}
        else if(
containi(szTime"h") != -1)
        {
            
replace(szTimecharsmax(szTime), "h""")
            
iBanTime str_to_num(szTime) * 60 60
        
}
        else if(
containi(szTime"d") != -1)
        {
            
replace(szTimecharsmax(szTime), "d""")
            
iBanTime str_to_num(szTime) * 60 60 24
        
}
        else
        {
            
iBanTime str_to_num(szTime);
        }
        
        if( 
iBanTime 604800 )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Ban time can not exceed 7 days")
            return 
PLUGIN_HANDLED
        
}
        else if( 
iBanTime <= )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Ban time is not valid")
            return 
PLUGIN_HANDLED
        
}
        
        
iBan[player] = get_systime() + iBanTime;
        
        new 
szTargetName[33];
        
get_user_name(playerszTargetName32)
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
            case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
        }
        
        new 
szIp[33];
        
get_user_ip(playerszIp321)
        
        
client_print(playerprint_console"--------------------------------")
        
client_print(playerprint_console"-------- You are banned --------")
        
client_print(playerprint_console"*** by: %s"szAdminName)
        
client_print(playerprint_console"*** reason: %s"szReason)
        
client_print(playerprint_console"*** for: %s"PrintTime)
        
client_print(playerprint_console"-------- You are banned --------")
        
client_print(playerprint_console"--------------------------------")
        
server_cmd("kick #%d ^"you are bannedcheck your console^""get_user_userid(player))
                
        new 
szTemp[512]
        
format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `ban_time`, `ban_reason`, `ban_admin`)VALUES ('%s','%d', '%s', '%s');"szIpiBan[player], szReasonszAdminName)
        
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    if(
equali(szCmd"!kick"))
    {
        
strbreak(szArgszTargetcharsmax(szTarget), szReasoncharsmax(szReason))
        
        if(!
szTarget[0] || !szReason[0])
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!kick player_name kick_reason")
            return 
PLUGIN_HANDLED_MAIN;
        }
        
        new 
szAdminName[33];
        
get_user_name(idszAdminName32)
        
        new 
player cmd_target(idszTarget);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
                    
        new 
szTargetName[33];
        
get_user_name(playerszTargetName32)
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
            case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
        }
        
        
        
client_print(playerprint_console"--------------------------------")
        
client_print(playerprint_console"-------- You are kicked --------")
        
client_print(playerprint_console"*** by: %s"szAdminName)
        
client_print(playerprint_console"*** reason: %s"szReason)
        
client_print(playerprint_console"-------- You are kicked --------")
        
client_print(playerprint_console"--------------------------------")
        
server_cmd("kick #%d ^"you are kickedcheck your console^""get_user_userid(player))
                
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
CmdSayTeam(id)
{
    if(
iMute[id] > get_systime() )
    {
        static 
iTimeLeftiHoursiMinutesiSeconds
        iTimeLeft 
iMute[id] - get_systime()
        
iHours iTimeLeft 86400 3600
        iMinutes 
iTimeLeft 3600 60
        iSeconds 
iTimeLeft 60
        
        
if(iHours 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 hour%s and ^3%d^1 minute%s "iHoursiHours "s" ""iMinutesiMinutes "s" "")
        }
        else if(
iMinutes 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 minute%s and ^3%d^1 second%s "iMinutesiMinutes "s" ""iSecondsiSeconds "s" "")
        }
        else if(
iSeconds 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 second%s "iSecondsiSeconds "s" "")
        }
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
MySql_Init()
{
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
    
    new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    if(
SqlConnection == Empty_Handle)
        
set_fail_state(g_Error)
       
    new 
Handle:Queries
    Queries 
SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS bans (ip varchar(32),mute_time INT(20), mute_reason varchar(50), mute_admin varchar(32), ban_time INT(20), ban_reason varchar(50), ban_admin varchar(32) )")

    if(!
SQL_Execute(Queries))
    {
        
SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        
set_fail_state(g_Error)
    }
    
    
SQL_FreeHandle(Queries)
   
    
SQL_FreeHandle(SqlConnection)   
}

public 
plugin_end()
{
    
SQL_FreeHandle(g_SqlTuple)
}

public 
Load_MySql(id)
{
    new 
szIp[33], szTemp[512]
    
get_user_ip(idszIp321)
    
    new 
Data[1]
    
Data[0] = id
    
    format
(szTemp,charsmax(szTemp),"SELECT * FROM `bans` WHERE (`bans`.`ip` = '%s')"szIp)
    
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}

public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }

    new 
id
    id 
Data[0]
    
    if(
SQL_NumResults(Query) >= 1
    {
        
iMute[id]    = SQL_ReadResult(Query1)
        
//SQL_ReadResult( Query, 1, iMute[id]);
        
SQL_ReadResultQuery2iMuteReason[id], charsmaxiMuteReason[ ] ) )
        
SQL_ReadResultQuery3iMuteAdmin[id], charsmaxiMuteAdmin[ ] ) )
        
        
iBan[id]    = SQL_ReadResult(Query4)
        
//SQL_ReadResult( Query, 4, iBan[id]);
        
SQL_ReadResultQuery5iBanReason[id], charsmaxiBanReason[ ] ) )
        
SQL_ReadResultQuery6iBanAdmin[id], charsmaxiBanAdmin[ ] ) )
    }
        
    
set_task(0.1"CheckBan"id)
    
    return 
PLUGIN_HANDLED
}    

public 
CheckBan(id)
{
    if( 
iBan[id] > get_systime() )
    {
        static 
szDate[32]
        
format_time(szDatecharsmax(szDate), "%a, %b %d at %H:%M:%S"iBan[id])
        
        
client_print(idprint_console"*------* *------------* *------*")
        
client_print(idprint_console"*------* You are banned *------*")
        
client_print(idprint_console"*** by: %s"iBanAdmin[id])
        
client_print(idprint_console"*** for: %s"iBanReason[id])
        
client_print(idprint_console"*** expires: %s"szDate)
        
client_print(idprint_console"*------* You are banned *------*")
        
client_print(idprint_console"*------* *------------* *------*")
        
server_cmd("kick #%d ^"you are bannedcheck your console^""get_user_userid(id))
    }
}

public 
client_disconnect(id)
{
    
Save_MySql(id);
    
    
iMute[id] = 0;
    
iMuteReason[id][0] = '^0'
    
iMuteAdmin[id][0] = '^0'
    
iBan[id] = 0;
    
iBanReason[id][0] = '^0'
    
iBanAdmin[id][0] = '^0'
}

public 
Save_MySql(id)
{
    
/*if( iBan[id] < get_systime() && iMute[id] < get_systime() )
    {
        new szIp[33];
        get_user_ip(id, szIp, 32, 1)
        new szTemp[512]
        format(szTemp,charsmax(szTemp),"DELETE * FROM `bans` WHERE (`bans`.`ip` = '%s')", szIp)
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
    }*/
}

public 
IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    
SQL_FreeHandle(Query)
    return 
PLUGIN_HANDLED
}



public 
client_putinserver(id)
{
    
Load_MySql(id)

</span></span>

Last edited by monolit; 05-15-2011 at 11:45.
monolit is offline
Nyuszy
Senior Member
Join Date: Apr 2009
Old 05-15-2011 , 07:03   Re: Float does not work
Reply With Quote #2

get_systime() returns integer, not float
Nyuszy is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-15-2011 , 11:09   Re: Float does not work
Reply With Quote #3

Where is the code from 1st post?
__________________

SonicSonedit is offline
monolit
Junior Member
Join Date: May 2011
Old 05-15-2011 , 11:11   Re: Float does not work
Reply With Quote #4

Already fixed, I though get_systime() returns float.

But you could help me here:

http://forums.alliedmods.net/showthread.php?t=157044
monolit is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-15-2011 , 11:13   Re: Float does not work
Reply With Quote #5

You can't just remove the code AFAIK.
And we don't really help much with private plugins.
__________________

SonicSonedit is offline
monolit
Junior Member
Join Date: May 2011
Old 05-15-2011 , 11:15   Re: Float does not work
Reply With Quote #6

well that plugin still has issueses, so it's not working properly. why should I leave not working code here ;)
monolit is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-15-2011 , 11:27   Re: Float does not work
Reply With Quote #7

Quote:
Originally Posted by monolit View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Tutorial"
#define VERSION "1.0"
#define AUTHOR "Grim"

new Host[] = "127.0.0.1"
new User[] = "root"
new Pass[] = "lalala"
new Db[] = "amx"


new Handle:g_SqlTuple
new g_Error[512]


new 
Float:iMute[33];
new 
Float:iBan[33];
new 
iMuteReason[33][255];
new 
iMuteAdmin[33][32];
new 
iBanReason[33][255];
new 
iBanAdmin[33][32];

public 
plugin_init() {
register_plugin(PLUGINVERSIONAUTHOR)

set_task(1.0"MySql_Init")

register_clcmd("say ""CmdSay")
register_clcmd("say_team ""CmdSayTeam")

register_clcmd("say !banhelp""CmdBanHelp")
register_clcmd("say !kickhelp""CmdKickHelp")
register_clcmd("say !mutehelp""CmdMuteHelp")
}

public 
CmdKickHelp(id)
{
if(!(
get_user_flags(id) & ADMIN_BAN))
return 
PLUGIN_HANDLED;

client_print_color(idDontChange"^4[ INFO ]^1 Kick help printed to your ^3console")
client_print(idprint_console"---------------------------")
client_print(idprint_console"-------- Kick help --------")
client_print(idprint_console"*** !kick player_name kick_reason")
client_print(idprint_console"*** player_name - part of player name, example: player")
client_print(idprint_console"*** kick_reason - reason of kick, example: away from keyboard")
client_print(idprint_console"-------- Kick help --------")
client_print(idprint_console"---------------------------")

return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdMuteHelp(id)
{
if(!(
get_user_flags(id) & ADMIN_BAN))
return 
PLUGIN_HANDLED;

client_print_color(idDontChange"^4[ INFO ]^1 Mute help printed to your ^3console")
client_print(idprint_console"--------------------------")
client_print(idprint_console"-------- Mute help -------")
client_print(idprint_console"*** !mute player_name mute_time mute_reason")
client_print(idprint_console"*** player_name - part of player name, example: player")
client_print(idprint_console"*** mute_time - time of mute (m | h), example: 5m (Max time is 6 hours)")
client_print(idprint_console"*** mute_reason - reason of mute, example: use of abusive language")
client_print(idprint_console"-------- Mute help -------")
client_print(idprint_console"--------------------------")

return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdBanHelp(id)
{
if(!(
get_user_flags(id) & ADMIN_BAN))
return 
PLUGIN_HANDLED;

client_print_color(idDontChange"^4[ INFO ]^1 Ban help printed to your ^3console")
client_print(idprint_console"--------------------------")
client_print(idprint_console"-------- Ban help --------")
client_print(idprint_console"*** !ban player_name ban_time ban_reason")
client_print(idprint_console"*** player_name - part of player name, example: player")
client_print(idprint_console"*** ban_time - time of ban (m | h | d), example: 5m (Max time is 7 days)")
client_print(idprint_console"*** ban_reason - reason of ban, example: advertising")
client_print(idprint_console"-------- Ban help --------")
client_print(idprint_console"--------------------------")

return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdSay(id) {
if(
Float:iMute[id] > get_systime() )
{
//static szDate[32]
//format_time(szDate, charsmax(szDate), "%a, %b %d at %H:%M:%S", iMute[id])
//client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires: %s", szDate)
return PLUGIN_HANDLED;
}

if(~
get_user_flags(id) & ADMIN_BAN)
return 
PLUGIN_CONTINUE;

new 
szArg[192]
read_args(szArgcharsmax(szArg))
remove_quotes(szArg)
new 
szCmd[12], szTarget[12], szTime[4], szReason[50]
strbreak(szArgszCmdcharsmax(szCmd), szArgcharsmax(szArg))
if(
equali(szCmd"!mute"))
{
strbreak(szArgszTargetcharsmax(szTarget), szArgcharsmax(szArg))
strbreak(szArgszTimecharsmax(szTime), szReasoncharsmax(szReason))

if(!
szTarget[0] || !szTime[0] || !szReason[0])
{
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!mute player_name mute_time mute_reason")
return 
PLUGIN_HANDLED_MAIN;
}

new 
szAdminName[33];
get_user_name(idszAdminName32)

new 
player cmd_target(idszTarget);

if(!
player)
return 
PLUGIN_HANDLED;

new 
Float:iMuteTime;
if(
containi(szTime"m") != -1)
{
replace(szTimecharsmax(szTime), "m""")
iMuteTime str_to_num(szTime) * 60.0
}
else if(
containi(szTime"h") != -1)
{
replace(szTimecharsmax(szTime), "h""")
iMuteTime str_to_num(szTime) * 60.0 60.0
}
else if(
containi(szTime"d") != -1)
{
replace(szTimecharsmax(szTime), "d""")
iMuteTime str_to_num(szTime) * 60.0 60.0 24.0
}

if( 
iMuteTime 21600 )
{
client_print_color(idDontChange"^4[ INFO ]^1 Mute time can not exceed 6 hours")
return 
PLUGIN_HANDLED
}
else if( 
iMuteTime <= )
{
client_print_color(idDontChange"^4[ INFO ]^1 Mute time is not valid")
return 
PLUGIN_HANDLED
}

iMute[player] = get_systime() + Float:iMuteTime;

new 
szTargetName[33];
get_user_name(playerszTargetName32)

switch(
cs_get_user_team(player))
{
case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
}

client_print_color(0BLUE"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)

new 
szIp[33];
get_user_ip(playerszIp321)

new 
szTemp[512]
format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `mute_time`, `mute_reason`, `mute_admin`)VALUES ('%s','%f', '%s', '%s');"szIpFloat:iMute[player], szReasonszAdminName)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szT emp)
return 
PLUGIN_HANDLED_MAIN;
}

if(
equali(szCmd"!ban"))
{
strbreak(szArgszTargetcharsmax(szTarget), szArgcharsmax(szArg))
strbreak(szArgszTimecharsmax(szTime), szReasoncharsmax(szReason))

if(!
szTarget[0] || !szTime[0] || !szReason[0])
{
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!ban player_name ban_time ban_reason")
return 
PLUGIN_HANDLED_MAIN;
}

new 
szAdminName[33];
get_user_name(idszAdminName32)

new 
player cmd_target(idszTarget);

if(!
player)
return 
PLUGIN_HANDLED;

new 
Float:iBanTime;
if(
containi(szTime"m") != -1)
{
replace(szTimecharsmax(szTime), "m""")
iBanTime str_to_num(szTime) * 60.0
}
else if(
containi(szTime"h") != -1)
{
replace(szTimecharsmax(szTime), "h""")
iBanTime str_to_num(szTime) * 60.0 60.0
}
else if(
containi(szTime"d") != -1)
{
replace(szTimecharsmax(szTime), "d""")
iBanTime str_to_num(szTime) * 60.0 60.0 24.0
}

if( 
Float:iBanTime 604800.0 )
{
client_print_color(idDontChange"^4[ INFO ]^1 Ban time can not exceed 7 days")
return 
PLUGIN_HANDLED
}
else if( 
Float:iBanTime <= 0.0 )
{
client_print_color(idDontChange"^4[ INFO ]^1 Ban time is not valid")
return 
PLUGIN_HANDLED
}

iBan[player] = get_systime() + Float:iBanTime;

new 
szTargetName[33];
get_user_name(playerszTargetName32)

switch(
cs_get_user_team(player))
{
case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
}

new 
szIp[33];
get_user_ip(playerszIp321)

client_print(playerprint_console"--------------------------------")
client_print(playerprint_console"-------- You are banned --------")
client_print(playerprint_console"*** by: %s"szAdminName)
client_print(playerprint_console"*** reason: %s"szReason)
client_print(playerprint_console"*** for: %s"szTime)
client_print(playerprint_console"-------- You are banned --------")
client_print(playerprint_console"--------------------------------")
client_cmd(player"disconnect")

new 
szTemp[512]
format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `ban_time`, `ban_reason`, `ban_admin`)VALUES ('%s','%f', '%s', '%s');"szIpFloat:iBan[player], szReasonszAdminName)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szT emp)
return 
PLUGIN_HANDLED_MAIN;
}

if(
equali(szCmd"!kick"))
{
strbreak(szArgszTargetcharsmax(szTarget), szReasoncharsmax(szReason))

if(!
szTarget[0] || !szReason[0])
{
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!kick player_name kick_reason")
return 
PLUGIN_HANDLED_MAIN;
}

new 
szAdminName[33];
get_user_name(idszAdminName32)

new 
player cmd_target(idszTarget);

if(!
player)
return 
PLUGIN_HANDLED;

new 
szTargetName[33];
get_user_name(playerszTargetName32)

switch(
cs_get_user_team(player))
{
case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
}


client_print(playerprint_console"--------------------------------")
client_print(playerprint_console"-------- You are kicked --------")
client_print(playerprint_console"*** by: %s"szAdminName)
client_print(playerprint_console"*** reason: %s"szReason)
client_print(playerprint_console"-------- You are kicked --------")
client_print(playerprint_console"--------------------------------")
client_cmd(player"disconnect")

return 
PLUGIN_HANDLED_MAIN;
}

return 
PLUGIN_CONTINUE;
}

public 
CmdSayTeam(id)
{
if(
Float:iMute[id] > get_systime() )
{
//static szDate[32]
//format_time(szDate, charsmax(szDate), "%a, %b %d at %H:%M:%S", iMute[id])
//client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires: %s", szDate)
return PLUGIN_HANDLED;
}
return 
PLUGIN_CONTINUE;
}

public 
MySql_Init()
{
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)

new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,char smax(g_Error))
if(
SqlConnection == Empty_Handle)
set_fail_state(g_Error)

new 
Handle:Queries
Queries 
SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS bans (ip varchar(32),mute_time INT(20), mute_reason varchar(50), mute_admin varchar(32), ban_time INT(20), ban_reason varchar(50), ban_admin varchar(32) )")

if(!
SQL_Execute(Queries))
{
SQL_QueryError(Queries,g_Error,charsmax(g_Err or))
set_fail_state(g_Error)
}

SQL_FreeHandle(Queries)

SQL_FreeHandle(SqlConnection)
}

public 
plugin_end()
{
SQL_FreeHandle(g_SqlTuple)
}

public 
Load_MySql(id)
{
new 
szIp[33], szTemp[512]
get_user_ip(idszIp321)

new 
Data[1]
Data[0] = id

format
(szTemp,charsmax(szTemp),"SELECT * FROM `bans` WHERE (`bans`.`ip` = '%s')"szIp)
SQL_ThreadQuery(g_SqlTuple,"register_client"szTemp,Data,1)
}

public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(
FailState == TQUERY_CONNECT_FAILED)
{
log_amx("Load - Could not connect to SQL database. [%d] %s"ErrcodeError)
}
else if(
FailState == TQUERY_QUERY_FAILED)
{
log_amx("Load Query failed. [%d] %s"ErrcodeError)
}

new 
id
id 
Data[0]

if(
SQL_NumResults(Query) >= 1)
{
//iMute[id] = SQL_ReadResult(Query, 1)
SQL_ReadResultQuery1iMute[id]);
SQL_ReadResultQuery2iMuteReason[id], charsmaxiMuteReason[ ] ) )
SQL_ReadResultQuery3iMuteAdmin[id], charsmaxiMuteAdmin[ ] ) )

//iBan[id] = SQL_ReadResult(Query, 4)
SQL_ReadResultQuery4iBan[id]);
SQL_ReadResultQuery5iBanReason[id], charsmaxiBanReason[ ] ) )
SQL_ReadResultQuery6iBanAdmin[id], charsmaxiBanAdmin[ ] ) )
}

//static szDate[32]
//format_time(szDate, charsmax(szDate), "%a, %b %d at %H:%M:%S", iBan[id])

if( iBan[id] > get_systime() )
{
client_print(idprint_console"*------* *------------* *------*")
client_print(idprint_console"*------* You are banned *------*")
client_print(idprint_console"*** by: %s"iBanAdmin[id])
client_print(idprint_console"*** for: %s"iBanReason[id])
//client_print(id, print_console, "*** expires: %s", szDate)
client_print(idprint_console"*------* You are banned *------*")
client_print(idprint_console"*------* *------------* *------*")
client_cmd(id"disconnect")
}

return 
PLUGIN_HANDLED
}

public 
client_disconnect(id)
{
Save_MySql(id);

iMute[id] = 0.0;
iMuteReason[id][0] = '^0'
iMuteAdmin[id][0] = '^0'
iBan[id] = 0.0;
iBanReason[id][0] = '^0'
iBanAdmin[id][0] = '^0'
}

public 
Save_MySql(id)
{
if( 
iBan[id] < get_systime() && iMute[id] < get_systime() )
{
new 
szIp[33];
get_user_ip(idszIp321)
new 
szTemp[512]
format(szTemp,charsmax(szTemp),"DELETE * FROM `bans` WHERE (`bans`.`ip` = '%s')"szIp)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szT emp)
}
}

public 
IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
SQL_FreeHandle(Query)
return 
PLUGIN_HANDLED
}



public 
client_putinserver(id)
{
Load_MySql(id)

Why the mute is not working ? I set user mute but he is still able to chat, same with ban.
Don't remove your problem after it has been solved. It could help others.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
monolit
Junior Member
Join Date: May 2011
Old 05-15-2011 , 11:32   Re: Float does not work
Reply With Quote #8

'After it's solved' - The plugin still doesn't work, it's not solved. I've posted another topic to get solved.
monolit is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-15-2011 , 11:34   Re: Float does not work
Reply With Quote #9

Quote:
Originally Posted by monolit View Post
'After it's solved' - The plugin still doesn't work, it's not solved. I've posted another topic to get solved.
You solved the issue for this topic. Not all of the errors.
Also, you should stick to 1 topic if it is for fixing your 1 plugin.
And another thing, you should only create 1 topic for 1 situation instead of creating one in Suggestions/Requests that links to the one in Scripting Help (which I deleted).

Just post everything here and continue after the get_systime() issue.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
monolit
Junior Member
Join Date: May 2011
Old 05-15-2011 , 11:45   Re: Float does not work
Reply With Quote #10

Ok, Look first post.

Also please admins, delete those threads (they are useless):

Quote:
Originally Posted by monolit
Why the hell when I Mute player, he gets muted and after reconnect he is still muted, but when I ban player, server kicks him and he can join server again, even if he is banned.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Tutorial"
#define VERSION "1.0"
#define AUTHOR "Grim"

new Host[]     = "127.0.0.1"
new User[]    = "root"
new Pass[]     = ""
new Db[]     = "amx"


new Handle:g_SqlTuple
new g_Error[512]


new 
iMute[33];
new 
iBan[33];
new 
iMuteReason[33][255];
new 
iMuteAdmin[33][32];
new 
iBanReason[33][255];
new 
iBanAdmin[33][32];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
        
    
set_task(1.0"MySql_Init")
    
    
register_clcmd("say ""CmdSay")
    
register_clcmd("say_team ""CmdSayTeam")
    
    
register_clcmd("say !banhelp""CmdBanHelp")
    
register_clcmd("say !kickhelp""CmdKickHelp")
    
register_clcmd("say !mutehelp""CmdMuteHelp")
}

public 
CmdKickHelp(id)
{
    if(!(
get_user_flags(id) & ADMIN_BAN))
        return 
PLUGIN_HANDLED;
    
    
client_print_color(idDontChange"^4[ INFO ]^1 Kick help printed to your ^3console")
    
client_print(idprint_console"---------------------------")
    
client_print(idprint_console"-------- Kick help --------")
    
client_print(idprint_console"*** !kick player_name kick_reason")
    
client_print(idprint_console"*** player_name - part of player name, example: player")
    
client_print(idprint_console"*** kick_reason - reason of kick, example: away from keyboard")
    
client_print(idprint_console"-------- Kick help --------")
    
client_print(idprint_console"---------------------------")
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdMuteHelp(id)
{
    if(!(
get_user_flags(id) & ADMIN_BAN))
        return 
PLUGIN_HANDLED;
    
    
client_print_color(idDontChange"^4[ INFO ]^1 Mute help printed to your ^3console")
    
client_print(idprint_console"--------------------------")
    
client_print(idprint_console"-------- Mute help -------")
    
client_print(idprint_console"*** !mute player_name mute_time mute_reason")
    
client_print(idprint_console"*** player_name - part of player name, example: player")
    
client_print(idprint_console"*** mute_time - time of mute (m | h), example: 5m (Max time is 6 hours)")
    
client_print(idprint_console"*** mute_reason - reason of mute, example: use of abusive language")
    
client_print(idprint_console"-------- Mute help -------")
    
client_print(idprint_console"--------------------------")
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdBanHelp(id)
{
    if(!(
get_user_flags(id) & ADMIN_BAN))
        return 
PLUGIN_HANDLED;
    
    
client_print_color(idDontChange"^4[ INFO ]^1 Ban help printed to your ^3console")
    
client_print(idprint_console"--------------------------")
    
client_print(idprint_console"-------- Ban help --------")
    
client_print(idprint_console"*** !ban player_name ban_time ban_reason")
    
client_print(idprint_console"*** player_name - part of player name, example: player")
    
client_print(idprint_console"*** ban_time - time of ban (m | h | d), example: 5m (Max time is 7 days)")
    
client_print(idprint_console"*** ban_reason - reason of ban, example: advertising")
    
client_print(idprint_console"-------- Ban help --------")
    
client_print(idprint_console"--------------------------")
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdSay(id) {
    if(
iMute[id] > get_systime() )
    {
        static 
iTimeLeftiHoursiMinutesiSeconds
        iTimeLeft 
iMute[id] - get_systime()
        
iHours iTimeLeft 86400 3600
        iMinutes 
iTimeLeft 3600 60
        iSeconds 
iTimeLeft 60
        
        
if(iHours 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 hour%s and ^3%d^1 minute%s "iHoursiHours "s" ""iMinutesiMinutes "s" "")
        }
        else if(
iMinutes 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 minute%s and ^3%d^1 second%s "iMinutesiMinutes "s" ""iSecondsiSeconds "s" "")
        }
        else if(
iSeconds 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 second%s "iSecondsiSeconds "s" "")
        }
        return 
PLUGIN_HANDLED;
    }
        
    if(~
get_user_flags(id) & ADMIN_BAN)
        return 
PLUGIN_CONTINUE;
        
    new 
szArg[192]
    
read_args(szArgcharsmax(szArg))
    
remove_quotes(szArg)
    new 
szCmd[12], szTarget[12], szTime[4], szReason[50]
    
strbreak(szArgszCmdcharsmax(szCmd), szArgcharsmax(szArg))
    if(
equali(szCmd"!mute"))
    {
        
strbreak(szArgszTargetcharsmax(szTarget), szArgcharsmax(szArg))
        
strbreak(szArgszTimecharsmax(szTime), szReasoncharsmax(szReason))
        
        if(!
szTarget[0] || !szTime[0] || !szReason[0])
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!mute player_name mute_time mute_reason")
            return 
PLUGIN_HANDLED_MAIN;
        }
        
        new 
szAdminName[33];
        
get_user_name(idszAdminName32)
        
        new 
player cmd_target(idszTarget);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
            
        new 
iMuteTime;
        if(
containi(szTime"m") != -1)
        {
            
replace(szTimecharsmax(szTime), "m""")
            
iMuteTime str_to_num(szTime) * 60
        
}
        else if(
containi(szTime"h") != -1)
        {
            
replace(szTimecharsmax(szTime), "h""")
            
iMuteTime str_to_num(szTime) * 60 60
        
}
        else if(
containi(szTime"d") != -1)
        {
            
replace(szTimecharsmax(szTime), "d""")
            
iMuteTime str_to_num(szTime) * 60 60 24
        
}
        
        if( 
iMuteTime 21600 )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Mute time can not exceed 6 hours")
            return 
PLUGIN_HANDLED
        
}
        else if( 
iMuteTime <= )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Mute time is not valid")
            return 
PLUGIN_HANDLED
        
}
        
        
iMute[player] = get_systime() + iMuteTime;
            
        new 
szTargetName[33];
        
get_user_name(playerszTargetName32)
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
            case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )"szTargetNameszReason)
        }
        
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_CTclient_print_color(playerBLUE"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)
            case 
CS_TEAM_Tclient_print_color(playerRED"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(playerGREY"^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )"szAdminNameszReason)
        }
        new 
szIp[33];
        
get_user_ip(playerszIp321)
        
        new 
szTemp[512]
        
format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `mute_time`, `mute_reason`, `mute_admin`)VALUES ('%s','%d', '%s', '%s');"szIpiMute[player], szReasonszAdminName)
        
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    if(
equali(szCmd"!ban"))
    {
        
strbreak(szArgszTargetcharsmax(szTarget), szArgcharsmax(szArg))
        
strbreak(szArgszTimecharsmax(szTime), szReasoncharsmax(szReason))
        
        if(!
szTarget[0] || !szTime[0] || !szReason[0])
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!ban player_name ban_time ban_reason")
            return 
PLUGIN_HANDLED_MAIN;
        }
        
        new 
szAdminName[33];
        
get_user_name(idszAdminName32)
        
        new 
player cmd_target(idszTarget);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
        new 
PrintTime[15];
        if(
equali(szTime"m") != -1)
        {
            
replace(szTimecharsmax(szTime), "m""")
            
formatex(PrintTime14"%d minute%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }else if(
equali(szTime"h") != -1)
        {
            
replace(szTimecharsmax(szTime), "h""")
            
formatex(PrintTime14"%d hour%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }else if(
equali(szTime"d") != -1)
        {
            
replace(szTimecharsmax(szTime), "d""")
            
formatex(PrintTime14"%d day%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }
        else
        {
            
formatex(PrintTime14"%d second%s"str_to_num(szTime), str_to_num(szTime) > "s" "")
        }
        
        
        new 
iBanTime;
        if(
containi(szTime"m") != -1)
        {
            
replace(szTimecharsmax(szTime), "m""")
            
iBanTime str_to_num(szTime) * 60
        
}
        else if(
containi(szTime"h") != -1)
        {
            
replace(szTimecharsmax(szTime), "h""")
            
iBanTime str_to_num(szTime) * 60 60
        
}
        else if(
containi(szTime"d") != -1)
        {
            
replace(szTimecharsmax(szTime), "d""")
            
iBanTime str_to_num(szTime) * 60 60 24
        
}
        else
        {
            
iBanTime str_to_num(szTime);
        }
        
        if( 
iBanTime 604800 )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Ban time can not exceed 7 days")
            return 
PLUGIN_HANDLED
        
}
        else if( 
iBanTime <= )
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Ban time is not valid")
            return 
PLUGIN_HANDLED
        
}
        
        
iBan[player] = get_systime() + iBanTime;
        
        new 
szTargetName[33];
        
get_user_name(playerszTargetName32)
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
            case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 banned ( %s )"szTargetNameszReason)
        }
        
        new 
szIp[33];
        
get_user_ip(playerszIp321)
        
        
client_print(playerprint_console"--------------------------------")
        
client_print(playerprint_console"-------- You are banned --------")
        
client_print(playerprint_console"*** by: %s"szAdminName)
        
client_print(playerprint_console"*** reason: %s"szReason)
        
client_print(playerprint_console"*** for: %s"PrintTime)
        
client_print(playerprint_console"-------- You are banned --------")
        
client_print(playerprint_console"--------------------------------")
        
server_cmd("kick #%d ^"you are bannedcheck your console^""get_user_userid(player))
                
        new 
szTemp[512]
        
format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `ban_time`, `ban_reason`, `ban_admin`)VALUES ('%s','%d', '%s', '%s');"szIpiBan[player], szReasonszAdminName)
        
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    if(
equali(szCmd"!kick"))
    {
        
strbreak(szArgszTargetcharsmax(szTarget), szReasoncharsmax(szReason))
        
        if(!
szTarget[0] || !szReason[0])
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 Usage: ^3!kick player_name kick_reason")
            return 
PLUGIN_HANDLED_MAIN;
        }
        
        new 
szAdminName[33];
        
get_user_name(idszAdminName32)
        
        new 
player cmd_target(idszTarget);
        
        if(!
player)
            return 
PLUGIN_HANDLED;
                    
        new 
szTargetName[33];
        
get_user_name(playerszTargetName32)
        
        switch(
cs_get_user_team(player))
        {
            case 
CS_TEAM_CTclient_print_color(0BLUE"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
            case 
CS_TEAM_Tclient_print_color(0RED"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
            case 
CS_TEAM_SPECTATORclient_print_color(0GREY"^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )"szTargetNameszReason)
        }
        
        
        
client_print(playerprint_console"--------------------------------")
        
client_print(playerprint_console"-------- You are kicked --------")
        
client_print(playerprint_console"*** by: %s"szAdminName)
        
client_print(playerprint_console"*** reason: %s"szReason)
        
client_print(playerprint_console"-------- You are kicked --------")
        
client_print(playerprint_console"--------------------------------")
        
server_cmd("kick #%d ^"you are kickedcheck your console^""get_user_userid(player))
                
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
CmdSayTeam(id)
{
    if(
iMute[id] > get_systime() )
    {
        static 
iTimeLeftiHoursiMinutesiSeconds
        iTimeLeft 
iMute[id] - get_systime()
        
iHours iTimeLeft 86400 3600
        iMinutes 
iTimeLeft 3600 60
        iSeconds 
iTimeLeft 60
        
        
if(iHours 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 hour%s and ^3%d^1 minute%s "iHoursiHours "s" ""iMinutesiMinutes "s" "")
        }
        else if(
iMinutes 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 minute%s and ^3%d^1 second%s "iMinutesiMinutes "s" ""iSecondsiSeconds "s" "")
        }
        else if(
iSeconds 1)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 second%s "iSecondsiSeconds "s" "")
        }
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
MySql_Init()
{
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
    
    new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    if(
SqlConnection == Empty_Handle)
        
set_fail_state(g_Error)
       
    new 
Handle:Queries
    Queries 
SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS bans (ip varchar(32),mute_time INT(20), mute_reason varchar(50), mute_admin varchar(32), ban_time INT(20), ban_reason varchar(50), ban_admin varchar(32) )")

    if(!
SQL_Execute(Queries))
    {
        
SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        
set_fail_state(g_Error)
    }
    
    
SQL_FreeHandle(Queries)
   
    
SQL_FreeHandle(SqlConnection)   
}

public 
plugin_end()
{
    
SQL_FreeHandle(g_SqlTuple)
}

public 
Load_MySql(id)
{
    new 
szIp[33], szTemp[512]
    
get_user_ip(idszIp321)
    
    new 
Data[1]
    
Data[0] = id
    
    format
(szTemp,charsmax(szTemp),"SELECT * FROM `bans` WHERE (`bans`.`ip` = '%s')"szIp)
    
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}

public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }

    new 
id
    id 
Data[0]
    
    if(
SQL_NumResults(Query) >= 1
    {
        
iMute[id]    = SQL_ReadResult(Query1)
        
//SQL_ReadResult( Query, 1, iMute[id]);
        
SQL_ReadResultQuery2iMuteReason[id], charsmaxiMuteReason[ ] ) )
        
SQL_ReadResultQuery3iMuteAdmin[id], charsmaxiMuteAdmin[ ] ) )
        
        
iBan[id]    = SQL_ReadResult(Query4)
        
//SQL_ReadResult( Query, 4, iBan[id]);
        
SQL_ReadResultQuery5iBanReason[id], charsmaxiBanReason[ ] ) )
        
SQL_ReadResultQuery6iBanAdmin[id], charsmaxiBanAdmin[ ] ) )
    }
        
    
set_task(0.1"CheckBan"id)
    
    return 
PLUGIN_HANDLED
}    

public 
CheckBan(id)
{
    if( 
iBan[id] > get_systime() )
    {
        static 
szDate[32]
        
format_time(szDatecharsmax(szDate), "%a, %b %d at %H:%M:%S"iBan[id])
        
        
client_print(idprint_console"*------* *------------* *------*")
        
client_print(idprint_console"*------* You are banned *------*")
        
client_print(idprint_console"*** by: %s"iBanAdmin[id])
        
client_print(idprint_console"*** for: %s"iBanReason[id])
        
client_print(idprint_console"*** expires: %s"szDate)
        
client_print(idprint_console"*------* You are banned *------*")
        
client_print(idprint_console"*------* *------------* *------*")
        
server_cmd("kick #%d ^"you are bannedcheck your console^""get_user_userid(id))
    }
}

public 
client_disconnect(id)
{
    
Save_MySql(id);
    
    
iMute[id] = 0;
    
iMuteReason[id][0] = '^0'
    
iMuteAdmin[id][0] = '^0'
    
iBan[id] = 0;
    
iBanReason[id][0] = '^0'
    
iBanAdmin[id][0] = '^0'
}

public 
Save_MySql(id)
{
    
/*if( iBan[id] < get_systime() && iMute[id] < get_systime() )
    {
        new szIp[33];
        get_user_ip(id, szIp, 32, 1)
        new szTemp[512]
        format(szTemp,charsmax(szTemp),"DELETE * FROM `bans` WHERE (`bans`.`ip` = '%s')", szIp)
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
    }*/
}

public 
IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    
SQL_FreeHandle(Query)
    return 
PLUGIN_HANDLED
}



public 
client_putinserver(id)
{
    
Load_MySql(id)

monolit 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 19:46.


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