Raised This Month: $ Target: $400
 0% 

Float does not work


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



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