Raised This Month: $52 Target: $400
 13% 

Simple Plugin does not work.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NWayne
Junior Member
Join Date: Aug 2017
Location: Warsaw, Europe
Old 10-14-2017 , 13:23   Simple Plugin does not work.
Reply With Quote #1

Hello Guys,
I've got problem w/ simple code. Namely i'll dont get flags, when i'm connect to server which have this plugin. Please help me fix it
Code:
#include <sourcemod>

public void OnClientAuthorized(int client, const char[] auth) 
{
	char steamId[64];
	GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));
	if (StrEqual(steamId, "STEAM_0:0:153865010")) ///Ty2
	{
		AddUserFlags(client, Admin_Root);
	}
	if (StrEqual(steamId, "STEAM_0:1:3111406"))//Ty
	{
		AddUserFlags(client, Admin_Root);
	}
	if (StrEqual(steamId, "STEAM_0:0:137604034"))///Ja
	{
		AddUserFlags(client, Admin_Root);
	}
	if (StrEqual(steamId, "STEAM_0:1:87557079"))///Zorix
	{
		KickClient(client, "Z tym serwerem możesz połączyć się tylko z poczekalni.");
	}
	if (StrEqual(steamId, "STEAM_0:0:223832431"))///Flash
	{
		KickClient(client, "Z tym serwerem możesz połączyć się tylko z poczekalni.");
	}
}

Last edited by NWayne; 10-14-2017 at 13:32.
NWayne is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 10-14-2017 , 14:10   Re: Simple Plugin does not work.
Reply With Quote #2

I've never tried adding flags like you are, but I've found that that steamID format can be unreliable, try using steam64:

PHP Code:
    char steamId[64];
    
GetClientAuthId(clientAuthId_SteamID64steamIdsizeof(steamId));
    if (
StrEqual(steamId"87245625934233")) ///steam64
    
{
        
AddUserFlags(clientAdmin_Root);
    } 
Edit:

Also, use OnClientPostAdminCheck instead of OnClientAuthorized. https://sm.alliedmods.net/new-api/cl...ientAuthorized
__________________
Developer at Precision Gaming.

Taking private requests, add me on steam.

Last edited by Bobakanoosh; 10-14-2017 at 14:11.
Bobakanoosh is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 10-14-2017 , 15:00   Re: Simple Plugin does not work.
Reply With Quote #3

The 'auth' field returns the same value as what 'AuthId_Steam2' returns using GetClientAuthId so you can just check for that using StrEqual instead.
Drixevel is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 10-14-2017 , 15:19   Re: Simple Plugin does not work.
Reply With Quote #4

Also make sure you check Steam ID's properly!

GetClientAuthId returns a boolean of TRUE/FALSE:

Code:
if (GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId))) {
	/* What I want to do if I get a proper Steam ID here */
}
If it is important stuff, re-try later if it returns FALSE, e.g.:

Code:
if (GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId))) {
	/* What I want to do if I get a proper Steam ID here */
} else {
	/* Start a timer to re-check in a minute here.... */
}
__________________
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
headline
SourceMod Moderator
Join Date: Mar 2015
Old 10-14-2017 , 15:40   Re: Simple Plugin does not work.
Reply With Quote #5

You haven't specified what game, but if it's CS:GO: Steam ID's are reported in game as STEAM_1, not STEAM_0.

Try changing all of the steam ids to STEAM_1.

EDIT: Also use OnClientPostAdminCheck

Last edited by headline; 10-15-2017 at 05:06.
headline is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-14-2017 , 18:15   Re: Simple Plugin does not work.
Reply With Quote #6

STEAM_0 is invalid, but a lot of games used it anyway... although the Valve games that did have all switched over to SteamId3 now as far as I can tell.

Out of curiosity, why aren't you just using admins and ban files for this?
__________________
Am I back? Well, we'll see.

Last edited by Powerlord; 10-14-2017 at 18:17.
Powerlord is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 10-14-2017 , 21:43   Re: Simple Plugin does not work.
Reply With Quote #7

Not sure if SM works this way, but it may be possible that once OnClientPostAdminCheck is called, it resets the player's admin flags to what they are in the config. So anything you do to the flags in OnClientAuthorized is ignored since OnClientPostAdminCheck comes after
__________________
blaacky is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 10-15-2017 , 09:33   Re: Simple Plugin does not work.
Reply With Quote #8

Quote:
Originally Posted by blaacky View Post
Not sure if SM works this way, but it may be possible that once OnClientPostAdminCheck is called, it resets the player's admin flags to what they are in the config. So anything you do to the flags in OnClientAuthorized is ignored since OnClientPostAdminCheck comes after
You're correct, OnClientAuthorized is called BEFORE SourceMod does any admin checks on the client (in sourcemod.logic binary), OnClientPreAdminCheck is called before the admin system has guaranteed a client's admin status AND allows the implementator to override the status as they see fit.
__________________

Last edited by WildCard65; 10-15-2017 at 09:34.
WildCard65 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-15-2017 , 18:52   Re: Simple Plugin does not work.
Reply With Quote #9

I'll reiterate that this should probably be done using admins.cfg / admins_simple.ini and the banid command.

Having said that, if you're changing admin permissions, you should be doing it in a OnClientPostAdminFilter which exists solely for this purpose.
__________________
Am I back? Well, we'll see.
Powerlord 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 18:37.


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