Raised This Month: $ Target: $400
 0% 

Float does not work


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 04:23.


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