View Single Post
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 01-16-2022 , 06:35   Re: [CSGO] Panorama Map Crash Fix (v1.4.0 30/03/2019)
Reply With Quote #56

Quote:
Originally Posted by pokemonmaster View Post
Wouldn't something like this be sufficient and better than timers? player_disconnect is only called once a player fully disconnects and is not called on map changes.

Only issue I can think of so far is that clients connecting from the same IP might face some issues, but that is (probably) easy to get around.

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Plugin myinfo =
{
    
name "Panorama Map crash fix test",
    
author "pokemonmaster",
    
description "",
    
version "1.0",
    
url "http://alliedmods.net/"
};

StringMap g_Trie_ReconnectingClients;

public 
void OnPluginStart()
{
    
g_Trie_ReconnectingClients = new StringMap();
    
HookEvent("player_disconnect"Event_PlayerDisconnect);
}

public 
void OnClientAuthorized(int client, const char[] szAuth)
{
    
PrintToServer("-- Client Authorized %N (%d)"clientclient);
    
char szIP[30];
    
GetClientIP(clientszIPsizeof szIPfalse);
    
SetTrieValue(g_Trie_ReconnectingClientsszIPtrue);
}

public 
void OnClientConnected(int client)
{
    
char szIP[30], iValue;
    
GetClientIP(clientszIPsizeof szIPfalse);
    
    if(
GetTrieValue(g_Trie_ReconnectingClientsszIPiValue))
    {
        
PrintToServer("-- Reconnecting client %N (%d) connected!"clientclient);
        
ClientCommand(client"retry");
        return;
    }
    
    
PrintToServer("-- Client %N (%d) connected!"clientclient);
}

public 
void Event_PlayerDisconnect(Event hEventchar[] szEventNamebool bDontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(hEvent"userid"));
    
    if(!
client)
    {
        return;
    }
    
    
char szIP[30];
    
GetClientIP(clientszIPsizeof szIPfalse);
    
PrintToServer("-- Client Disconnect ---- Event - %N (%d)"clientclient);
    
RemoveFromTrie(g_Trie_ReconnectingClientsszIP);

Have you done any testing with this? Does it work?
Ejziponken is offline