Raised This Month: $51 Target: $400
 12% 

Best Method for when a player connects...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 04-16-2018 , 17:34   Best Method for when a player connects...
Reply With Quote #1

...and doesn't fire again after map change or plugin reload. Only fires once the initial client connect, the only exception of course would be if they disconnect and reconnect. I have tried using 'OnClientAuthorized' and 'OnClientPostAdminCheck', which work fine until the map changes and they seem to fire again, I have a log file setup to verify. The plugin is reloaded on every map change and I am guessing this might be what is causing it but I do need it to reload after every map change.

I feel a bit silly asking this since it's basic SM functionality, but this is the issue I am running into. Thanks for any suggestions.
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-16-2018 , 17:51   Re: Best Method for when a player connects...
Reply With Quote #2

Try "player_connect" event.
Reiko1231 is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 04-16-2018 , 17:58   Re: Best Method for when a player connects...
Reply With Quote #3

Thank you, I wasn't sure if that would fire again, but since it's a hook that would make more sense to use that instead.
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-17-2018 , 09:12   Re: Best Method for when a player connects...
Reply With Quote #4

I haven't tried the event but otherwise you could do something like this. Also if you ask me, I have no idea why a simple forward like this don't exist in SM.

Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma newdecls required

bool firstConnection[MAXPLAYERS+1];

public void OnClientConnected(int client)
{
	if (IsFakeClient(client)) return;

	firstConnection[client] = false;		// reset the boolean just in case.	

	int connectionTime = RoundFloat(GetClientTime(client));
	if (connectionTime > 1) return;

	firstConnection[client] = true;			// A client just made a connection.
}

public void OnClientPostAdminCheck(int client)
{
	if (IsFakeClient(client)) return;

	if (firstConnection[client])				// The client is in game for the first time. Do all the necessary checks below.
	{
		firstConnection[client] = false;		// Reset the boolean so this OnClientPostAdminCheck call won't reoccour
		
		// Do stuff
	}
}

Last edited by Visual77; 04-17-2018 at 09:21.
Visual77 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:28.


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