Raised This Month: $ Target: $400
 0% 

possible bug in admin flags when player times out?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
loki_himself
Member
Join Date: Nov 2021
Old 09-20-2022 , 08:16   possible bug in admin flags when player times out?
Reply With Quote #1

i have encountered a weird bug.

i use 2 steam accounts on the same IP, to connect to my Steam server. both are admins in users.ini but have different flags. when 1 account times out, cause i close CS, and i connect with the other account before the timeout period ends (60 sec), then this new account gets the flags of the other timing out account session, giving him the wrong admin flags.

this also can be reproduced with joining the steam server, then disconnecting, starting a local server where i have different flags, then joining back to the rehlds steam server, and i get treated with the local hlds server flags.

how can i reset a player who has not yet timed out or clear his flags on connect?

Last edited by loki_himself; 09-20-2022 at 08:18.
loki_himself is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-21-2022 , 00:43   Re: possible bug in admin flags when player times out?
Reply With Quote #2

Flags are stored on the server, not the client. Are you getting the same slot when you re-join the server?

Also, flags for each user are cleared when the client is authorized (client_authorized) and when they are put in the server (client_putinserver).

How are you being authenticated in those servers? Are you using SteamID? Also, have you verified with an actual Steam server (i.e. not ReHLDS)?
__________________
fysiks is offline
loki_himself
Member
Join Date: Nov 2021
Old 09-21-2022 , 08:59   Re: possible bug in admin flags when player times out?
Reply With Quote #3

it happens when i get the slot id of the timing out player. i am using steamid for all users.ini admins. i only have rehlds, no hlds online.

i read now again: "client_putinserver: It is not defined whether the client already has a SteamID when this
forward is called. client_authorized may occur either before or after
this."

i might be doing it wrong checking flags in my client_putinserver only... as they might not be cleared yet in the client_authorized of admin.sma? so a player is ready and checked, after both client_putinserver and client_authorized have been executed ONLY ? wow i never checked that

ok i will put some debug log in that admin.sma and see whats happening there.

how the error happens, i think?

Code:
old player is timing out on slot id 3
...
new player is joining on his slot id 3
...
admin.sma client_putinserver - does nothing
custom.sma client_putinserver - new player gets the old player flags
admin.sma client_authorized - now the new player flags gets cleared
custom.sma client_authorized - does nothing right now

Last edited by loki_himself; 09-21-2022 at 09:07.
loki_himself is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-22-2022 , 00:18   Re: possible bug in admin flags when player times out?
Reply With Quote #4

Yes, for anything related to admin access, you should do after client_authorized() and all plugins should be below admin.amxx in plugins.ini.
__________________
fysiks is offline
loki_himself
Member
Join Date: Nov 2021
Old 09-22-2022 , 05:59   Re: possible bug in admin flags when player times out?
Reply With Quote #5

i see a lot of approved popular plugins using only client_putinserver and handling admin/flags in there. what is the correct and clean way? cause my code does not work when i work with client_authorized, cause its a race condition, do i need to set_task and continue if both client_authorized and client_putinserver have been run? basically i want a client_authorizedAndPutinserver event...

i am doing this now. is there a better way?

Code:
public client_connect(id) 
{
	resetId(id)
}

public client_authorized(id, const auth[]) 
{
	g_isAuthorized[id] = true

	return PLUGIN_CONTINUE
}

public client_putinserver(id)
{
	g_waitingAuthorized[id] = get_systime()

	set_task(0.1, "checkAuthorized", id + TASK_PUTINSERVER, _, _, "b")

	return PLUGIN_CONTINUE
}

public checkAuthorized(id)
{
	if(id > TASK_PUTINSERVER) id = id - TASK_PUTINSERVER

	if(g_isAuthorized[id]) {
		remove_task(id + TASK_PUTINSERVER)
		onAuthorizedAndPutinserver(id)
	} else {
               // if he didnt authorize in 2 sec we dont need him
		if(get_systime() > g_waitingAuthorized[i]+2) kickPlayer(id)
	}
}

public onAuthorizedAndPutinserver(id) {

// player is now all clean to go...
}

about the order of plugins:
since i use csdm, they have their own plugins-csdm.ini

how is the order of those files, i assume:

1. plugins.ini
2. plugins-csdm.ini

where can i change that order? cause for example i want the official csdm_PostSpawn of plugins-csdm.ini csdm plugins to run before any plugins.ini plugins run csdm_PostSpawn. do i have to move the csdm plugins into plugins.ini before the custom ones then?

Last edited by loki_himself; 09-22-2022 at 07:44.
loki_himself is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-22-2022 , 22:53   Re: possible bug in admin flags when player times out?
Reply With Quote #6

You can easily wait for both to be true like this:

PHP Code:
new Bool:g_bInServerBool:g_bAuthorized

public client_putinserver(id)
{
    
g_bInServer true;
    if( 
g_bInServer && g_bAuthorized )
    {
        
eventAuthorizedAndPutInServer(id)
    }
}

public 
client_authorized(id)
{
    
g_bAuthorized true;
    if( 
g_bInServer && g_bAuthorized )
    {
        
eventAuthorizedAndPutInServer(id)
    }
}

eventAuthorizedAndPutInServer(id)
{
    
// Your code here

Regarding the order of plugin configuration files, plugins.ini will always load first.
__________________

Last edited by fysiks; 09-22-2022 at 22:54.
fysiks is offline
loki_himself
Member
Join Date: Nov 2021
Old 09-23-2022 , 05:57   Re: possible bug in admin flags when player times out?
Reply With Quote #7

thanks man, i was thinking too complicated
loki_himself is offline
Reply


Thread Tools
Display Modes

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 12:28.


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