You need to work with SteamIDs here, using a Trie is usually the best option for that. Just using the client entity index is not reliable because they are not constant for any one client. If player a leaves and player b connects afterwards they will have the same index.
PHP Code:
#include <amxmodx>
#define RETRY_TIME 10.0
new Trie:g_last_leave, Trie:g_leave_count, g_steamid[33][33];
public plugin_init() {
g_last_leave = TrieCreate();
g_leave_count = TrieCreate();
}
public client_authorized(client) {
get_user_authid(client, g_steamid[client], charsmax(g_steamid[]));
new Float:last;
if (TrieGetCell(g_last_leave, g_steamid[client], last) && get_gametime() - last <= RETRY_TIME) {
new count;
TrieGetCell(g_leave_count, g_steamid[client], count);
TrieSetCell(g_leave_count, g_steamid[client], count - 1);
}
}
public client_disconnect(client) {
TrieSetCell(g_last_leave, g_steamid[client], get_gametime());
new count;
TrieGetCell(g_leave_count, g_steamid[client], count);
TrieSetCell(g_leave_count, g_steamid[client], count + 1);
}
This is a very basic example. On client_disconnect we save the last time the player disconnected and increment the leave count by one. If the player reconnects within RETRY_TIME seconds we decrement the counter by one.
__________________