added some extra checks, re-run getauthstring on some users
This commit is contained in:
		
							parent
							
								
									93b8f48afc
								
							
						
					
					
						commit
						950fba2f5c
					
				@ -8,11 +8,12 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CBaseEntity;
 | 
					class CBaseEntity;
 | 
				
			||||||
 | 
					//class CBasePlayer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint8_t g_ClientIndex[SM_MAXPLAYERS + 1];
 | 
					uint8_t g_ClientGiveNamedCounter[SM_MAXPLAYERS + 1];
 | 
				
			||||||
char g_ClientSteamIDMap[SM_MAXPLAYERS + 1][32];
 | 
					char g_ClientSteamIDMap[SM_MAXPLAYERS + 1][32];
 | 
				
			||||||
char g_ClientNameMap[SM_MAXPLAYERS + 1][32];
 | 
					char g_ClientNameMap[SM_MAXPLAYERS + 1][32];
 | 
				
			||||||
int g_Capacity = 8;
 | 
					int g_Capacity = 20;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//https://sm.alliedmods.net/doxygen/index.html
 | 
					//https://sm.alliedmods.net/doxygen/index.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -49,17 +50,51 @@ size_t strlcpy(char *dst, const char *src, size_t dsize)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
DETOUR_DECL_MEMBER2(GiveNamedItem, void, char*, pszName, int, iSubType)
 | 
					DETOUR_DECL_MEMBER2(GiveNamedItem, void, char*, pszName, int, iSubType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    CBaseEntity *pPlayer = (CBaseEntity *)this;
 | 
					    CBaseEntity *pEntity = (CBaseEntity *)this;
 | 
				
			||||||
    int idx = gamehelpers->EntityToBCompatRef(pPlayer);
 | 
					    //int idx = gamehelpers->EntityToBCompatRef(pPlayer); //caused a crash
 | 
				
			||||||
    if (idx > 0 && idx < playerhelpers->GetMaxClients()) //should be in the index range for clients.
 | 
					    /*
 | 
				
			||||||
 | 
					    #0  0xeb7585a0 in CHalfLife2::EntityToBCompatRef (this=0xeb8605c0 <g_HL2>, pEntity=0x41)
 | 
				
			||||||
 | 
					        at /home/gameservers/automate/sourcemod_1.12.0.7137/core/HalfLife2.cpp:1132
 | 
				
			||||||
 | 
					    #1  0xeb75867e in non-virtual thunk to CHalfLife2::EntityToBCompatRef(CBaseEntity*) ()
 | 
				
			||||||
 | 
					       from /home/gameservers/css_ze/cstrike/addons/sourcemod/bin/sourcemod.2.css.so
 | 
				
			||||||
 | 
					    #2  0xe15a9d6a in GiveNamedItem (pContext=0x9cc6170, params=0xdbf85114) at /home/gameservers/automate/sourcemod_1.12.0.7137/extensions/sdktools/vnatives.cpp:327
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    //CBasePlayer* pPlayer = (CBasePlayer*) this;
 | 
				
			||||||
 | 
					    //CBasePlayer* pPlayer = CBasePlayer::GetLocalPlayer();
 | 
				
			||||||
 | 
					    //CBasePlayer* pPlayer = ToBasePlayer(UTIL_GetCommandClient());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (pEntity)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        IGamePlayer* gp = playerhelpers->GetGamePlayer(idx);
 | 
					        cell_t entRef = gamehelpers->EntityToReference(pEntity);
 | 
				
			||||||
        if (gp->IsConnected())
 | 
					        if (entRef)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            g_ClientIndex[idx]++;
 | 
					            int idx = gamehelpers->ReferenceToIndex(entRef);
 | 
				
			||||||
            smutils->LogMessage(myself, "got inside of DETOUR_DECL_MEMBER2. STEAMID: %s, playername: %s. pszName: %s. iSubType: %i. g_ClientIndex[idx]: %i", 
 | 
					            if (idx > 0 && idx <= playerhelpers->GetMaxClients()) //should be in the index range for clients.
 | 
				
			||||||
                                g_ClientSteamIDMap[idx], g_ClientNameMap[idx], pszName, iSubType, g_ClientIndex[idx]);
 | 
					            {
 | 
				
			||||||
            DETOUR_MEMBER_CALL(GiveNamedItem)(pszName, iSubType);
 | 
					                IGamePlayer* gp = playerhelpers->GetGamePlayer(idx);
 | 
				
			||||||
 | 
					                if (gp && gp->IsConnected() && gp->IsInGame())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (gp->IsFakeClient() || gp->IsSourceTV())
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        DETOUR_MEMBER_CALL(GiveNamedItem)(pszName, iSubType);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        g_ClientGiveNamedCounter[idx]++;
 | 
				
			||||||
 | 
					                        if (g_ClientGiveNamedCounter[idx] <= g_Capacity)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            smutils->LogMessage(myself, "DETOUR_DECL_MEMBER2. STEAMID: %s, name: %s. pszName: %s. iSubType: %i. counter: %i", 
 | 
				
			||||||
 | 
					                                                g_ClientSteamIDMap[idx], g_ClientNameMap[idx], pszName, iSubType, g_ClientGiveNamedCounter[idx]);
 | 
				
			||||||
 | 
					                            DETOUR_MEMBER_CALL(GiveNamedItem)(pszName, iSubType);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else //log spammers
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            smutils->LogMessage(myself, "SPAMS A LOT. STEAMID: %s, name: %s. pszName: %s. iSubType: %i. counter: %i", 
 | 
				
			||||||
 | 
					                                                g_ClientSteamIDMap[idx], g_ClientNameMap[idx], pszName, iSubType, g_ClientGiveNamedCounter[idx]);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -82,7 +117,7 @@ bool GiveNamedItemTracker::SDK_OnLoad(char *error, size_t maxlength, bool late)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    void *pBinary = dlopen("cstrike/bin/server_srv.so", RTLD_NOW);
 | 
					    void *pBinary = dlopen("cstrike/bin/server_srv.so", RTLD_NOW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(!pBinary)
 | 
					    if (!pBinary)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        smutils->LogError(myself, "Could not dlopen cstrike/bin/server_srv.so");
 | 
					        smutils->LogError(myself, "Could not dlopen cstrike/bin/server_srv.so");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
@ -114,7 +149,7 @@ bool GiveNamedItemTracker::SDK_OnLoad(char *error, size_t maxlength, bool late)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void GiveNamedItemTracker::OnClientPostAdminCheck(int client)
 | 
					void GiveNamedItemTracker::OnClientPostAdminCheck(int client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    g_ClientIndex[client] = 0;
 | 
					    g_ClientGiveNamedCounter[client] = 0;
 | 
				
			||||||
    IGamePlayer* gp = playerhelpers->GetGamePlayer(client);
 | 
					    IGamePlayer* gp = playerhelpers->GetGamePlayer(client);
 | 
				
			||||||
    strlcpy(g_ClientSteamIDMap[client], gp->GetAuthString(), sizeof(*g_ClientSteamIDMap));
 | 
					    strlcpy(g_ClientSteamIDMap[client], gp->GetAuthString(), sizeof(*g_ClientSteamIDMap));
 | 
				
			||||||
    strlcpy(g_ClientNameMap[client], gp->GetName(), sizeof(*g_ClientNameMap));
 | 
					    strlcpy(g_ClientNameMap[client], gp->GetName(), sizeof(*g_ClientNameMap));
 | 
				
			||||||
@ -122,25 +157,28 @@ void GiveNamedItemTracker::OnClientPostAdminCheck(int client)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void GiveNamedItemTracker::OnClientDisconnected(int client)
 | 
					void GiveNamedItemTracker::OnClientDisconnected(int client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    g_ClientIndex[client] = 0;
 | 
					    g_ClientGiveNamedCounter[client] = 0;
 | 
				
			||||||
    strlcpy(g_ClientSteamIDMap[client], "", sizeof(*g_ClientSteamIDMap));
 | 
					    strlcpy(g_ClientSteamIDMap[client], "", sizeof(*g_ClientSteamIDMap));
 | 
				
			||||||
    strlcpy(g_ClientNameMap[client], "", sizeof(*g_ClientNameMap));
 | 
					    strlcpy(g_ClientNameMap[client], "", sizeof(*g_ClientNameMap));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GiveNamedItemTracker::OnTimer()
 | 
					void GiveNamedItemTracker::OnTimer()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    for(int idx = 1; idx < playerhelpers->GetMaxClients(); idx++)
 | 
					    for (int idx = 0; idx <= playerhelpers->GetMaxClients(); idx++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        IGamePlayer* gp = playerhelpers->GetGamePlayer(idx);
 | 
					        if (strcmp(g_ClientSteamIDMap[idx], "") == 0)
 | 
				
			||||||
        if (gp->IsConnected())
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (g_ClientIndex[idx] > g_Capacity)
 | 
					            //empty steamid. (null). idx: 2. name: mituju
 | 
				
			||||||
 | 
					            //according to my logging does gp->GetAuthString() in DETOUR_DECL_MEMBER2 sometimes return null.
 | 
				
			||||||
 | 
					            //therefore rerunning it here to try and re-assign them their steam ID if still missing.
 | 
				
			||||||
 | 
					            IGamePlayer* gp = playerhelpers->GetGamePlayer(idx);
 | 
				
			||||||
 | 
					            if (gp && gp->IsConnected() && gp->IsInGame())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                smutils->LogMessage(myself, "Client with more weapons than capacity %i: STEAMID: %s. playername: %s. g_ClientIndex[idx]: %i", 
 | 
					                strlcpy(g_ClientSteamIDMap[idx], gp->GetAuthString(), sizeof(*g_ClientSteamIDMap));
 | 
				
			||||||
                                    g_Capacity, g_ClientSteamIDMap[idx], g_ClientNameMap[idx], g_ClientIndex[idx]);
 | 
					                strlcpy(g_ClientNameMap[idx], gp->GetName(), sizeof(*g_ClientNameMap));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            g_ClientIndex[idx] = 0;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        g_ClientGiveNamedCounter[idx] = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user