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

[ANY] Keep Player Name


Post New Thread Reply   
 
Thread Tools Display Modes
Tonblader
Senior Member
Join Date: Jul 2011
Location: Peru
Old 01-23-2021 , 11:40   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.2
Reply With Quote #21

Quote:
Originally Posted by Teamkiller324 View Post
Should be fixed now.
I have the same problem i mentioned above.
I am doing this:
Close L4D2 > install plugin > Open L4D2 > map c1m1 > my actual name is Tonblader > sm_forcename Tonblader 12345 > sm_clearname 12345 > setinfo name Tonblader > my name return to 12345 > this should not happen no?

Last edited by Tonblader; 01-23-2021 at 11:41.
Tonblader is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 01-23-2021 , 19:44   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.2
Reply With Quote #22

Quote:
Originally Posted by Tonblader View Post
I have the same problem i mentioned above.
I am doing this:
Close L4D2 > install plugin > Open L4D2 > map c1m1 > my actual name is Tonblader > sm_forcename Tonblader 12345 > sm_clearname 12345 > setinfo name Tonblader > my name return to 12345 > this should not happen no?
That is most likely because you're using client listen server. Dedicated server behaves differently and SourceMod/MetaMod: Source is designed for dedicated server and not in-game client listen server.
__________________
Teamkiller324 is offline
Tonblader
Senior Member
Join Date: Jul 2011
Location: Peru
Old 01-23-2021 , 21:07   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.2
Reply With Quote #23

Quote:
Originally Posted by Teamkiller324 View Post
That is most likely because you're using client listen server. Dedicated server behaves differently and SourceMod/MetaMod: Source is designed for dedicated server and not in-game client listen server.
Quote:
L 01/23/2021 - 13:07:20: [SM] Exception reported: Client index 0 is invalid
L 01/23/2021 - 13:07:20: [SM] Blaming: all\keep_player_name.smx
L 01/23/2021 - 13:07:20: [SM] Call stack trace:
L 01/23/2021 - 13:07:20: [SM] [0] IsClientInGame
L 01/23/2021 - 13:07:20: [SM] [1] Line 73, D:\scripting\spedit\sourcepawn\configs\sm_1_1 0\include\multicolors/colors.inc::C_PrintToChat
L 01/23/2021 - 13:07:20: [SM] [2] Line 78, D:\scripting\spedit\sourcepawn\configs\sm_1_1 0\include\multicolors.inc::CPrintToChat
L 01/23/2021 - 13:07:20: [SM] [3] Line 198, D:\scripting\Keep Player Name\addons\sourcemod\scripting\keep_player_n ame.sp::ForceName
Yes, the problem is related to the client index 0, then the problem is only me, as host, but for the other users that if they have a client index 1 or more, it should not cause major problems.
Tonblader is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 01-23-2021 , 21:09   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.3
Reply With Quote #24

type through the chat instead console.

!clearname 12344

for the listen server host, using console the client index will always be 0 and in chat usually 1
__________________

Last edited by Marttt; 01-23-2021 at 21:27.
Marttt is offline
Tonblader
Senior Member
Join Date: Jul 2011
Location: Peru
Old 01-23-2021 , 21:22   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.3
Reply With Quote #25

Quote:
Originally Posted by Marttt View Post
type through chat instead console
!clearname 12344
using console the client index will be 0 and in chat usually 1
It's true, this worked, the bad thing is that the errorlog will be spamming me with the client index 0 problem.
Tonblader is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 01-23-2021 , 22:06   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.3
Reply With Quote #26

Quote:
Originally Posted by Teamkiller324 View Post
[...] as i somehow messed that part up lol, my bad
Don't worry, just make it even better...

Quote:
Originally Posted by Teamkiller324 View Post
OnClientSettingsChanged function is not working properly and just spams errors instead and is disabled temporarily
Maybe if you did the actual coding properly, it would work properly too? The errors are signs that you are not doing things "properly".

Your code that included "OnClientSettingsChanged", also seem to be including a
Code:
stock	bool	IsValidClient(int client)
where a lot (BUT NOT ALL!) of your functions uses IsValidClient first.

OnClientSettingsChanged did however not.

Code:
public	void	OnClientSettingsChanged(int client)	{
	if(IsClientInGame(client) && !IsFakeClient(client))	{
		if(GetClientTeam(client) > 0)	{
			setcookies(client,	true);
		}
	}
}
... so maybe, if you changed that one to:

Code:
public	void	OnClientSettingsChanged(int client)	{
/* Added IsValidClient before IsClientInGame */
/* Removed IsFakeClient, as it is already a part of  IsValidClient */
	if(IsValidClient(client) && IsClientInGame(client))	{
		if(GetClientTeam(client) > 0)	{
			setcookies(client,	true);
		}
	}
}
should solve the issue, as IsValidClient already checks if the client id is 1 or below/equal to MaxClients, ... if you really insist on mixing different patterns across your code.


OR, AN ALTERNATIVE WAY FOR MORE CONSISTENCY: Change your IsValidClient bool, to like e.g.:

Code:
stock	bool	IsValidClient(int client)	{
	if(client	<	1)
		return	false;
	if(client	>	MaxClients)
		return	false;
/* ADDITIONS BELOW */
	if(!IsClientInGame(client))
		return	false;
/* ADDITIONS ABOVE */
	if(IsFakeClient(client))
		return	false;
	return	true;
}
And simply used e.g.:

Code:
public	void	OnClientSettingsChanged(int client)	{
/* Changed IsClientInGame, to your IsValidClient */
/* Removed IsFakeClient, as it is already a part of  IsValidClient */
	if(IsValidClient(client))	{
		if(GetClientTeam(client) > 0)	{
			setcookies(client,	true);
		}
	}
}
This way, you can also add multiple sanity checks to your IsValidClient, and make one change stick across all your functions, where you use your IsValidClient.


Code:
if(GetClientTeam(client) > 0)
0 is unassigned, but the actual spectator is above 0, as far as I remember?

Do you really care about spectators? Otherwise, you might want to look into this one somehow else.

From include/cstrike.inc, after commit a615c13, made on 2021-01-14:

Code:
#define CS_TEAM_NONE        0   /**< No team yet. */
#define CS_TEAM_SPECTATOR   1   /**< Spectators. */
#define CS_TEAM_T           2   /**< Terrorists. */
#define CS_TEAM_CT          3   /**< Counter-Terrorists. */
From include/tf2.inc, after commit a615c13, made on 2021-01-14:

Code:
enum TFTeam
{
	TFTeam_Unassigned = 0,
	TFTeam_Spectator = 1,
	TFTeam_Red = 2,
	TFTeam_Blue = 3
};

I cannot guarantee you that all games have the same "team numbers" though, but if you don't care about spectators, just as you don't care about unassigned, ... maybe you should also update your "filters" here?


Just my two cents, ... or maybe a couple of more cents, but whatever.


Quote:
Originally Posted by Tonblader View Post
In Left 4 Dead 2 Listen Server Windows, when i use sm_forcename Tonblader hola , my game crash, no errorlog.
I see many threads saying: SourceMod is NOT supported on "listen servers".

Switch to SRCDS, and most (if not all) of your issues will likely vanish.

Quote:
Originally Posted by Tonblader View Post
It's true, this worked, the bad thing is that the errorlog will be spamming me with the client index 0 problem.
Even with some of the coding suggestions above, it most likely still won't work for you, when you are running a listen server...
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Tonblader
Senior Member
Join Date: Jul 2011
Location: Peru
Old 01-23-2021 , 22:52   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.3
Reply With Quote #27

Quote:
Originally Posted by DarkDeviL View Post
I see many threads saying: SourceMod is NOT supported on "listen servers".

Switch to SRCDS, and most (if not all) of your issues will likely vanish.
It is true and despite this, the plugins work on the listening server, many of these work without showing me errorlogs, using chat commands.

The other reason why I use Listen Server, is because it offers me better MS/ping, unlike a dedicated server, because I need it hand in hand with this plugin:
[L4D2] Auto Bunnyhop
Tonblader is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 01-23-2021 , 22:57   Re: [ANY] Keep Player Name [Updated 23-01-21] Version 1.1.3
Reply With Quote #28

Ty DarkDeviL

when i wrote the plugin, i was up too long as i couldn't sleep but i appreciate your help, i will definitely try solve the problems now before just pushing out an update and think it's "ok".

Have some special bacon
__________________

Last edited by Teamkiller324; 01-23-2021 at 23:50.
Teamkiller324 is offline
Lannister
Veteran Member
Join Date: Apr 2015
Old 01-27-2021 , 07:58   Re: [ANY] Keep Player Name [Updated 25-01-21] Version 1.1.5
Reply With Quote #29

Looking forward this!

Good job man!
Lannister is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 01-29-2021 , 14:34   Re: [ANY] Keep Player Name [Updated 25-01-21] Version 1.1.5
Reply With Quote #30

Quote:
Originally Posted by Lannister View Post
Looking forward this!

Good job man!
Thanks, mate.
__________________
Teamkiller324 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 14:53.


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