Junior Member
|
05-15-2011
, 11:45
Re: Float does not work
|
#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(PLUGIN, VERSION, AUTHOR) 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(id, DontChange, "^4[ INFO ]^1 Kick help printed to your ^3console") client_print(id, print_console, "---------------------------") client_print(id, print_console, "-------- Kick help --------") client_print(id, print_console, "*** !kick player_name kick_reason") client_print(id, print_console, "*** player_name - part of player name, example: player") client_print(id, print_console, "*** kick_reason - reason of kick, example: away from keyboard") client_print(id, print_console, "-------- Kick help --------") client_print(id, print_console, "---------------------------") return PLUGIN_HANDLED_MAIN; }
public CmdMuteHelp(id) { if(!(get_user_flags(id) & ADMIN_BAN)) return PLUGIN_HANDLED; client_print_color(id, DontChange, "^4[ INFO ]^1 Mute help printed to your ^3console") client_print(id, print_console, "--------------------------") client_print(id, print_console, "-------- Mute help -------") client_print(id, print_console, "*** !mute player_name mute_time mute_reason") client_print(id, print_console, "*** player_name - part of player name, example: player") client_print(id, print_console, "*** mute_time - time of mute (m | h), example: 5m (Max time is 6 hours)") client_print(id, print_console, "*** mute_reason - reason of mute, example: use of abusive language") client_print(id, print_console, "-------- Mute help -------") client_print(id, print_console, "--------------------------") return PLUGIN_HANDLED_MAIN; }
public CmdBanHelp(id) { if(!(get_user_flags(id) & ADMIN_BAN)) return PLUGIN_HANDLED; client_print_color(id, DontChange, "^4[ INFO ]^1 Ban help printed to your ^3console") client_print(id, print_console, "--------------------------") client_print(id, print_console, "-------- Ban help --------") client_print(id, print_console, "*** !ban player_name ban_time ban_reason") client_print(id, print_console, "*** player_name - part of player name, example: player") client_print(id, print_console, "*** ban_time - time of ban (m | h | d), example: 5m (Max time is 7 days)") client_print(id, print_console, "*** ban_reason - reason of ban, example: advertising") client_print(id, print_console, "-------- Ban help --------") client_print(id, print_console, "--------------------------") return PLUGIN_HANDLED_MAIN; }
public CmdSay(id) { if(iMute[id] > get_systime() ) { static iTimeLeft, iHours, iMinutes, iSeconds iTimeLeft = iMute[id] - get_systime() iHours = iTimeLeft % 86400 / 3600 iMinutes = iTimeLeft % 3600 / 60 iSeconds = iTimeLeft % 60 if(iHours > 1) { client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 hour%s and ^3%d^1 minute%s ", iHours, iHours > 1 ? "s" : "", iMinutes, iMinutes > 1 ? "s" : "") } else if(iMinutes > 1) { client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 minute%s and ^3%d^1 second%s ", iMinutes, iMinutes > 1 ? "s" : "", iSeconds, iSeconds > 1 ? "s" : "") } else if(iSeconds > 1) { client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 second%s ", iSeconds, iSeconds > 1 ? "s" : "") } return PLUGIN_HANDLED; } if(~get_user_flags(id) & ADMIN_BAN) return PLUGIN_CONTINUE; new szArg[192] read_args(szArg, charsmax(szArg)) remove_quotes(szArg) new szCmd[12], szTarget[12], szTime[4], szReason[50] strbreak(szArg, szCmd, charsmax(szCmd), szArg, charsmax(szArg)) if(equali(szCmd, "!mute")) { strbreak(szArg, szTarget, charsmax(szTarget), szArg, charsmax(szArg)) strbreak(szArg, szTime, charsmax(szTime), szReason, charsmax(szReason)) if(!szTarget[0] || !szTime[0] || !szReason[0]) { client_print_color(id, DontChange, "^4[ INFO ]^1 Usage: ^3!mute player_name mute_time mute_reason") return PLUGIN_HANDLED_MAIN; } new szAdminName[33]; get_user_name(id, szAdminName, 32) new player = cmd_target(id, szTarget); if(!player) return PLUGIN_HANDLED; new iMuteTime; if(containi(szTime, "m") != -1) { replace(szTime, charsmax(szTime), "m", "") iMuteTime = str_to_num(szTime) * 60 } else if(containi(szTime, "h") != -1) { replace(szTime, charsmax(szTime), "h", "") iMuteTime = str_to_num(szTime) * 60 * 60 } else if(containi(szTime, "d") != -1) { replace(szTime, charsmax(szTime), "d", "") iMuteTime = str_to_num(szTime) * 60 * 60 * 24 } if( iMuteTime > 21600 ) { client_print_color(id, DontChange, "^4[ INFO ]^1 Mute time can not exceed 6 hours") return PLUGIN_HANDLED } else if( iMuteTime <= 0 ) { client_print_color(id, DontChange, "^4[ INFO ]^1 Mute time is not valid") return PLUGIN_HANDLED } iMute[player] = get_systime() + iMuteTime; new szTargetName[33]; get_user_name(player, szTargetName, 32) switch(cs_get_user_team(player)) { case CS_TEAM_CT: client_print_color(0, BLUE, "^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )", szTargetName, szReason) case CS_TEAM_T: client_print_color(0, RED, "^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )", szTargetName, szReason) case CS_TEAM_SPECTATOR: client_print_color(0, GREY, "^4[ INFO ]^1 Player ^3%s^1 mutted ( %s )", szTargetName, szReason) } switch(cs_get_user_team(id)) { case CS_TEAM_CT: client_print_color(player, BLUE, "^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )", szAdminName, szReason) case CS_TEAM_T: client_print_color(player, RED, "^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )", szAdminName, szReason) case CS_TEAM_SPECTATOR: client_print_color(player, GREY, "^4[ INFO ]^1 You were mutted by: ^3%s^1 ( %s )", szAdminName, szReason) } new szIp[33]; get_user_ip(player, szIp, 32, 1) new szTemp[512] format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `mute_time`, `mute_reason`, `mute_admin`)VALUES ('%s','%d', '%s', '%s');", szIp, iMute[player], szReason, szAdminName) SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) return PLUGIN_HANDLED_MAIN; } if(equali(szCmd, "!ban")) { strbreak(szArg, szTarget, charsmax(szTarget), szArg, charsmax(szArg)) strbreak(szArg, szTime, charsmax(szTime), szReason, charsmax(szReason)) if(!szTarget[0] || !szTime[0] || !szReason[0]) { client_print_color(id, DontChange, "^4[ INFO ]^1 Usage: ^3!ban player_name ban_time ban_reason") return PLUGIN_HANDLED_MAIN; } new szAdminName[33]; get_user_name(id, szAdminName, 32) new player = cmd_target(id, szTarget); if(!player) return PLUGIN_HANDLED; new PrintTime[15]; if(equali(szTime, "m") != -1) { replace(szTime, charsmax(szTime), "m", "") formatex(PrintTime, 14, "%d minute%s", str_to_num(szTime), str_to_num(szTime) > 1 ? "s" : "") }else if(equali(szTime, "h") != -1) { replace(szTime, charsmax(szTime), "h", "") formatex(PrintTime, 14, "%d hour%s", str_to_num(szTime), str_to_num(szTime) > 1 ? "s" : "") }else if(equali(szTime, "d") != -1) { replace(szTime, charsmax(szTime), "d", "") formatex(PrintTime, 14, "%d day%s", str_to_num(szTime), str_to_num(szTime) > 1 ? "s" : "") } else { formatex(PrintTime, 14, "%d second%s", str_to_num(szTime), str_to_num(szTime) > 1 ? "s" : "") } new iBanTime; if(containi(szTime, "m") != -1) { replace(szTime, charsmax(szTime), "m", "") iBanTime = str_to_num(szTime) * 60 } else if(containi(szTime, "h") != -1) { replace(szTime, charsmax(szTime), "h", "") iBanTime = str_to_num(szTime) * 60 * 60 } else if(containi(szTime, "d") != -1) { replace(szTime, charsmax(szTime), "d", "") iBanTime = str_to_num(szTime) * 60 * 60 * 24 } else { iBanTime = str_to_num(szTime); } if( iBanTime > 604800 ) { client_print_color(id, DontChange, "^4[ INFO ]^1 Ban time can not exceed 7 days") return PLUGIN_HANDLED } else if( iBanTime <= 0 ) { client_print_color(id, DontChange, "^4[ INFO ]^1 Ban time is not valid") return PLUGIN_HANDLED } iBan[player] = get_systime() + iBanTime; new szTargetName[33]; get_user_name(player, szTargetName, 32) switch(cs_get_user_team(player)) { case CS_TEAM_CT: client_print_color(0, BLUE, "^4[ INFO ]^1 Player ^3%s^1 banned ( %s )", szTargetName, szReason) case CS_TEAM_T: client_print_color(0, RED, "^4[ INFO ]^1 Player ^3%s^1 banned ( %s )", szTargetName, szReason) case CS_TEAM_SPECTATOR: client_print_color(0, GREY, "^4[ INFO ]^1 Player ^3%s^1 banned ( %s )", szTargetName, szReason) } new szIp[33]; get_user_ip(player, szIp, 32, 1) client_print(player, print_console, "--------------------------------") client_print(player, print_console, "-------- You are banned --------") client_print(player, print_console, "*** by: %s", szAdminName) client_print(player, print_console, "*** reason: %s", szReason) client_print(player, print_console, "*** for: %s", PrintTime) client_print(player, print_console, "-------- You are banned --------") client_print(player, print_console, "--------------------------------") server_cmd("kick #%d ^"you are banned, check 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');", szIp, iBan[player], szReason, szAdminName) SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) return PLUGIN_HANDLED_MAIN; } if(equali(szCmd, "!kick")) { strbreak(szArg, szTarget, charsmax(szTarget), szReason, charsmax(szReason)) if(!szTarget[0] || !szReason[0]) { client_print_color(id, DontChange, "^4[ INFO ]^1 Usage: ^3!kick player_name kick_reason") return PLUGIN_HANDLED_MAIN; } new szAdminName[33]; get_user_name(id, szAdminName, 32) new player = cmd_target(id, szTarget); if(!player) return PLUGIN_HANDLED; new szTargetName[33]; get_user_name(player, szTargetName, 32) switch(cs_get_user_team(player)) { case CS_TEAM_CT: client_print_color(0, BLUE, "^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )", szTargetName, szReason) case CS_TEAM_T: client_print_color(0, RED, "^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )", szTargetName, szReason) case CS_TEAM_SPECTATOR: client_print_color(0, GREY, "^4[ INFO ]^1 Player ^3%s^1 kicked ( %s )", szTargetName, szReason) } client_print(player, print_console, "--------------------------------") client_print(player, print_console, "-------- You are kicked --------") client_print(player, print_console, "*** by: %s", szAdminName) client_print(player, print_console, "*** reason: %s", szReason) client_print(player, print_console, "-------- You are kicked --------") client_print(player, print_console, "--------------------------------") server_cmd("kick #%d ^"you are kicked, check your console^"", get_user_userid(player)) return PLUGIN_HANDLED_MAIN; } return PLUGIN_CONTINUE; }
public CmdSayTeam(id) { if(iMute[id] > get_systime() ) { static iTimeLeft, iHours, iMinutes, iSeconds iTimeLeft = iMute[id] - get_systime() iHours = iTimeLeft % 86400 / 3600 iMinutes = iTimeLeft % 3600 / 60 iSeconds = iTimeLeft % 60 if(iHours > 1) { client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 hour%s and ^3%d^1 minute%s ", iHours, iHours > 1 ? "s" : "", iMinutes, iMinutes > 1 ? "s" : "") } else if(iMinutes > 1) { client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 minute%s and ^3%d^1 second%s ", iMinutes, iMinutes > 1 ? "s" : "", iSeconds, iSeconds > 1 ? "s" : "") } else if(iSeconds > 1) { client_print_color(id, DontChange, "^4[ INFO ]^1 You are ^3mutted^1, mute expires after: ^3%d^1 second%s ", iSeconds, iSeconds > 1 ? "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(id, szIp, 32, 1) 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", Errcode, Error) } else if(FailState == TQUERY_QUERY_FAILED) { log_amx("Load Query failed. [%d] %s", Errcode, Error) }
new id id = Data[0] if(SQL_NumResults(Query) >= 1) { iMute[id] = SQL_ReadResult(Query, 1) //SQL_ReadResult( Query, 1, iMute[id]); SQL_ReadResult( Query, 2, iMuteReason[id], charsmax( iMuteReason[ ] ) ) SQL_ReadResult( Query, 3, iMuteAdmin[id], charsmax( iMuteAdmin[ ] ) ) iBan[id] = SQL_ReadResult(Query, 4) //SQL_ReadResult( Query, 4, iBan[id]); SQL_ReadResult( Query, 5, iBanReason[id], charsmax( iBanReason[ ] ) ) SQL_ReadResult( Query, 6, iBanAdmin[id], charsmax( iBanAdmin[ ] ) ) } set_task(0.1, "CheckBan", id) return PLUGIN_HANDLED }
public CheckBan(id) { if( iBan[id] > get_systime() ) { static szDate[32] format_time(szDate, charsmax(szDate), "%a, %b %d at %H:%M:%S", iBan[id]) client_print(id, print_console, "*------* *------------* *------*") client_print(id, print_console, "*------* You are banned *------*") client_print(id, print_console, "*** by: %s", iBanAdmin[id]) client_print(id, print_console, "*** for: %s", iBanReason[id]) client_print(id, print_console, "*** expires: %s", szDate) client_print(id, print_console, "*------* You are banned *------*") client_print(id, print_console, "*------* *------------* *------*") server_cmd("kick #%d ^"you are banned, check 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) }
|
|
|