Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rg_client_full_connect #327

Open
TheKrytyk opened this issue Aug 22, 2024 · 4 comments
Open

Add rg_client_full_connect #327

TheKrytyk opened this issue Aug 22, 2024 · 4 comments

Comments

@TheKrytyk
Copy link

TheKrytyk commented Aug 22, 2024

Hello,

At the moment we have 3 events:

a) client_connect
b) client_authorized
c) client_putinserver

and the problem is reading the values from nvault, when after changing the client_authorized map it is not always able to immediately verify whether, for example, it has flags added by the shop ( not users.ini ). Example:

public client_authorized( id )
{	
	if( get_user_flags( id ) & ADMIN_FLAG_W )
	{
		get_user_name( id, szUserAuthID[ id ], charsmax( szUserAuthID[ ] ) );	
		nvault_settings( id, NVAULT_READ, "client_authorized" );
	}
}

In order to read the values correctly you need to duplicate the code in the client_putinserver, so my suggestion is to add a new event rg_client_full_connect( index ) so that it executes after authorization ( reading the STEAMID ) and connecting the player to the server ( during team selection ).

It is still possible to add a set_task( 1.0, "nvault", id ) in client_authorised, but the player may leave the server. Also, the client_putinserver MAY sometimes execute BEFORE client_authorized ( from my observations and logs, 95% execute AFTER client_authorized, so a forward after the player is fully connected would be useful ).

Would it be possible to add something like this?

@NiceFeatures
Copy link

Set a task to a new function and

if(is_user_authorized(index))
{
    code...
}
else
{
 function()
}

@TheKrytyk
Copy link
Author

Tasks are unnecessary

@rtxa
Copy link

rtxa commented Dec 13, 2024

Not sure if it's useful but SourceMod had a similar issue which fix it by adding OnClientPostAdminCheck(). This could be use as a reference.

Called once a client is authorized and fully in-game, and after all post-connection authorizations have been performed.
This callback is guaranteed to occur on all clients, and always after each OnClientPutInServer() call.

@teddiboy
Copy link

#include <amxmodx>
#include <amxmisc>

new bool:g_bJoined[MAX_PLAYERS+1];

public plugin_init()
{
	register_plugin("Client Full Connect", "1.0", "teddy");
	register_event( "TeamInfo", "rg_client_full_connect", "a"); 
}
public rg_client_full_connect()
{	
	new id = read_data(1); 		
		
	if(is_user_bot(id) || is_user_hltv(id))
	{
        	return PLUGIN_HANDLED;
   	}
	
	if(!is_user_connected(id)) return PLUGIN_HANDLED;

	if(g_bJoined[id]) return PLUGIN_HANDLED;

	if( get_user_flags( id ) & ADMIN_FLAG_W )
	{
		code...
	}	

	g_bJoined[id] = true;
    	
	return PLUGIN_HANDLED;
}
public client_disconnected(id)
{
	g_bJoined[id] = false;
}

Try like this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants