Example #1
0
bool __stdcall hooked_ExecuteStringCmd( const char* cmd)
{
	IClient *ply = 0;
	__asm mov ply, ecx;

	if (!ply || !cmd || !Lua||!ply->GetNetworkIDString())
		return ExecuteStringCmd(cmd);

	Lua->PushSpecial(SPECIAL_GLOB);
	Lua->GetField(-1, "hook");
	Lua->GetField(-1, "Call");
	Lua->PushString("LAC.ExecuteStringCmd");
	Lua->PushNil();
	Lua->PushString(ply->GetNetworkIDString());
	Lua->PushString(cmd);
	int error = Lua->PCall(4, 1, 0);
	if (error)
	{
		Msg("!LAC ERROR! - ExecuteStringCmd: %s\n", Lua->GetString(-1));
		Lua->Pop();
	}

	if (Lua->IsType(-1, GarrysMod::Lua::Type::BOOL))
	{
		if (Lua->GetBool(-1))
		{
			Lua->Pop(3);
			return true;
		}
			
	}

	Lua->Pop(3);

	return ExecuteStringCmd( cmd);
}
    void CBaseServer::OnFillServerInfo(int SVC_ServerInfo)
    {
        cell_t result = Pl_Continue;
    
        if (g_pFwdAddonsDisabler && AddonsDisabler::AddonsEclipse > 0 && vanillaModeSig)
        {
            int m_nPlayerSlot = *(int *)((unsigned char *)SVC_ServerInfo + 48);
            IClient *pClient = g_pServer->GetClient(m_nPlayerSlot);

            L4D_DEBUG_LOG("ADDONS DISABLER: Eligible client '%s' connected[%s]", pClient->GetClientName(), pClient->GetNetworkIDString());
            
            g_pFwdAddonsDisabler->PushString(pClient->GetNetworkIDString());
            g_pFwdAddonsDisabler->Execute(&result);
            
            /* uint8_t != unsigned char in terms of type */
            uint8_t disableAddons = result == Pl_Handled ? 0 : 1;
            memset((unsigned char *)SVC_ServerInfo + 25, disableAddons, sizeof(uint8_t));
        }

        (this->*(GetTrampoline()))(SVC_ServerInfo);
    }