AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catching retrying players (https://forums.alliedmods.net/showthread.php?t=107690)

Mlk27 10-29-2009 05:40

Catching retrying players
 
I have this one plugin I need to adapt for my own use but the logic behind the way it works looks rather flawed to me so I need someone to look at it and correct me if I am wrong about it since the original author has long gone from this community.

Code:
#include <amxmodx> #include <amxmisc> #define MAX_PLAYERS 32 new g_szAuthID[MAX_PLAYERS+1][35] new g_iRetryCount[MAX_PLAYERS+1] new cv_RetryBanTime, cv_RetryTime, cv_RetryCount; new bool:g_RetryPlayer[33] public plugin_init() {     register_plugin("Ban Retry Player","1.1","[email protected]")     cv_RetryBanTime = register_cvar("amx_retryban","30")     cv_RetryTime = register_cvar("amx_retrytime","10")     cv_RetryCount = register_cvar("amx_retrycount","3")     for(new i=0; i< MAX_PLAYERS; i++)         g_iRetryCount[i]=0;     return PLUGIN_CONTINUE } public client_authorized(id) {     g_RetryPlayer[id] = false     set_task(5.0, "CheckRetry", id) } public CheckRetry(id) {     if ((!is_user_bot(id)) && (is_user_connected(id)) && ( !(get_user_flags(id) & ADMIN_IMMUNITY)) )     {         g_RetryPlayer[id] = true         new authid[35]         new uname[32]         new userid = get_user_userid(id)         get_user_authid(id, authid, 34)         get_user_name(id, uname, 31)         for(new i = 1; i <= MAX_PLAYERS; i++)         {             if (equal(authid, g_szAuthID[i], 34))             {                 if ( !(get_user_flags(id) & ADMIN_IMMUNITY) )                 {                     if (g_iRetryCount[i] < get_pcvar_num(cv_RetryCount))                         return PLUGIN_CONTINUE                     new BanTime = get_pcvar_num(cv_RetryBanTime)                     new RetryCount = get_pcvar_num(cv_RetryCount)                     new TimetoBan = get_pcvar_num(cv_RetryTime)                     new BanMessage[128]                     formatex(BanMessage, 127, "You reconnected %d time(s) in %d minute(s). Ban for %d minutes from this server", RetryCount, TimetoBan, BanTime)                     client_print(0, print_chat, "[BanRetryPlayer] Ban %s %m min(s) for reconnecting %d time(s) in %m min(s)", uname, BanTime, RetryCount, TimetoBan);                     server_cmd("kick #%d ^"%s^";wait;banid %d ^"%s^";wait;writeid", userid, BanMessage, get_pcvar_num(cv_RetryBanTime),authid)                     g_iRetryCount[i] = 0                     g_szAuthID[i][0] = 0                 }                 return PLUGIN_CONTINUE             }         }     }     return PLUGIN_CONTINUE } public client_disconnect(id) {     remove_task(id)     if ((!is_user_bot(id)) && ( !(get_user_flags(id) & ADMIN_IMMUNITY) ) && g_RetryPlayer[id])     {         for(new i = 1; i <= MAX_PLAYERS; i++)         {             if(g_szAuthID[i][0] == 0)             {                 g_iRetryCount[i]++;                 server_print("----MarkSteamID[%d] = %d----", i, g_iRetryCount[i])                 if (g_iRetryCount[i] == 1)                     set_task(60.0 * get_pcvar_num(cv_RetryTime), "clean_MarkedAuthID",i);                 else if (g_iRetryCount[i] == get_pcvar_num(cv_RetryCount))                 {                     new authid[35]                     get_user_authid(id, authid, 34)                     copy(g_szAuthID[i], 34, authid)                 }                 return PLUGIN_CONTINUE             }         }     }     return PLUGIN_CONTINUE } public clean_MarkedAuthID(id) {     g_iRetryCount[id] = 0; }

What I don't understand is the highlighted lines. When a player disconnect, it loops through g_szAuthID array and use the first available blank slot found in the array to mark retry count in g_iRetryCount. So what if a player leaves and another player joins in right after that and leave shortly after, the retry count in g_iRetryCount for the same array slot gets increased anyway right?

Exolent[jNr] 10-29-2009 10:57

Re: Catching retrying players
 
Take a look at this:
http://forums.alliedmods.net/showpos...17&postcount=8


All times are GMT -4. The time now is 17:45.

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