Raised This Month: $18 Target: $400

Solved SourceMod API GetClientAuthId Function

Post New Thread Reply   
Thread Tools Display Modes
Author Message
PC Gamer
Senior Member
Join Date: Mar 2014
Old 11-01-2019 , 23:36   SourceMod API GetClientAuthId Function
Reply With Quote #1


I've upgraded to Sourcemod 1.10 and began cleaning up plugins. I've noticed this warning on a few of them when compiling: warning 234: symbol "GetClientAuthString" is marked as deprecated: Use GetClientAuthId

I reviewed the GetClientAuthId function (link: https://sm.alliedmods.net/new-api/cl...etClientAuthId). However, I'm a bit stumped on how to use it to get the Steam2 ID.

How would you rewrite the code below to use GetClientAuthId instead of GetClientAuthString to get a Steam2 ID?

public Action:Command_Addvip(client, args)
	if(args < 1)
		ReplyToCommand(client, "[SM] Usage: sm_addvip <name or #userid>");
		return Plugin_Handled;
	decl String:buffer[64];
	GetCmdArg(1, buffer, sizeof(buffer));
	new target = FindTarget(client, buffer, true, false);
	decl String:steamid[64];
	GetClientAuthString(target, steamid, sizeof(steamid));

	new String:szFile[256];
	BuildPath(Path_SM, szFile, sizeof(szFile), "configs/admins_simple.ini");

	new Handle:hFile = OpenFile(szFile, "at");

	WriteFileLine(hFile, "\"%s\" \"5:a\"", steamid);


	return Plugin_Handled;

Last edited by PC Gamer; 11-02-2019 at 00:36.
PC Gamer is offline
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-01-2019 , 23:48   Re: SourceMod API GetClientAuthId Function
Reply With Quote #2

GetClientAuthId(target, AuthId_Steam2, steamid, sizeof(steamid));
8guawong is offline
PC Gamer
Senior Member
Join Date: Mar 2014
Old 11-02-2019 , 00:36   Re: SourceMod API GetClientAuthId Function
Reply With Quote #3

8guawong, that worked perfectly. Thanks!
PC Gamer is offline
SourceMod Moderator
Join Date: Apr 2012
Old 11-02-2019 , 01:08   Re: SourceMod API GetClientAuthId Function
Reply With Quote #4

Both the very old GetClientAuthString (since SM and (since SM 1.6.0) has always been a boolean.

So now you also have the chance to change and do things properly from your end, with some superior code like:

PHP Code:
if (!GetClientAuthId(targetAuthId_Steam2steamidsizeof(steamid)))
/* User probably not authenticated yet or Steam network (or connectivity to it) is temporarily down... Print "try again later" message? */
return Plugin_Handled;

PHP Code:
if (GetClientAuthId(targetAuthId_Steam2steamidsizeof(steamid)))
/* User probably not authenticated yet or Steam network (or connectivity to it) is temporarily down... Print "try again later" message? */
return Plugin_Handled;

Even with the older GetClientAuthString, you should also have had done that kind of thing as well, checking the actual return values before you blindly use the data.
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

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 04:08.

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