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

OnClientPostAdminCheck(client) problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Annihilator
Senior Member
Join Date: Nov 2006
Location: Lithuania
Old 08-12-2012 , 00:42   OnClientPostAdminCheck(client) problem.
Reply With Quote #1

I've been trying to log client name and auth using OnClientPostAdminCheck(client) and I ran into a strange error.

code I'm using:

PHP Code:
public OnClientPostAdminCheck(client)
{
    
decl String:auth[32];
    
decl String:clientName[MAX_NAME_LENGTH];
    
GetClientAuthString(clientauthsizeof(auth));
    
LogError("%s"auth);
    
GetClientName(clientclientNamesizeof(clientName));
    
LogError("%N"clientName);

error:
PHP Code:
L 08/12/2012 07:40:23: [test.smxSTEAM_0:0:27319953
L 08
/12/2012 07:40:23: [SMNative "LogError" reportedClient index 7302741 is invalid
L 08
/12/2012 07:40:23: [SMDisplaying call stack trace for plugin "test.smx":
L 08/12/2012 07:40:23: [SM]   [0]  Line 213test.sp::OnClientPostAdminCheck() 
And I have absolutely no idea why I can retrieve steamid, but not the clients name :/
Any tips? ^^

Edit: Ups, found the misplaced %N

Last edited by Annihilator; 08-12-2012 at 00:44.
Annihilator is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 08-12-2012 , 00:46   Re: OnClientPostAdminCheck(client) problem.
Reply With Quote #2

PHP Code:
public OnClientPostAdminCheck(client)
{
    
decl String:auth[32];
    
GetClientAuthString(clientauthsizeof(auth));
    
LogError(auth);
    
LogError("%N"client);

When using %N, you specify a client index, not the client's actual name.

Also, LogError("%s", auth) is silly, just specify auth directly.
__________________
Dr. McKay is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-12-2012 , 03:02   Re: OnClientPostAdminCheck(client) problem.
Reply With Quote #3

Quote:
Originally Posted by Dr. McKay View Post
Also, LogError("%s", auth) is silly, just specify auth directly.
out of topic.
If string contain formats like "qwerty %i %s %d asd",
you can print output this way example, LogError("%s", auth)

But this way it give you error LogError(auth), it need input values for those.

carry on
__________________
Do not Private Message @me
Bacardi is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 08-12-2012 , 06:38   Re: OnClientPostAdminCheck(client) problem.
Reply With Quote #4

you would want:
Quote:
LogError("%s", clientName);
because you've stored the clients name in a string. If you wanted to use %N, you'd use the arg passed through to the function and its respecting name, i.e.:
void function functName(arg1);
Quote:
LogError("%N", client);
but why not just do:
Quote:
LogError("%s (%N)", auth, client);

Last edited by Skyy; 08-12-2012 at 06:40.
Skyy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 08-12-2012 , 12:34   Re: OnClientPostAdminCheck(client) problem.
Reply With Quote #5

LogError("%L", client) ??
__________________
View my Plugins | Donate
TnTSCS is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 08-12-2012 , 19:07   Re: OnClientPostAdminCheck(client) problem.
Reply With Quote #6

TnTSCS's right (as always). %L was specifically made for logging more details about the client.

Format Class Functions:
Quote:
%L: Requires a client index; expands to 1<2><3><> where 1 is the player's name, 2 is the player's userid, and 3 is the player's Steam ID. If the client index is 0, the string will be: Console<0><Console><Console>
__________________

Last edited by 11530; 08-12-2012 at 19:08.
11530 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 01:08.


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