AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Simple Plugin does not work. (https://forums.alliedmods.net/showthread.php?t=302039)

NWayne 10-14-2017 12:23

Simple Plugin does not work.
 
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 :D
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.");
        }
}


Bobakanoosh 10-14-2017 13:10

Re: Simple Plugin does not work.
 
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

Drixevel 10-14-2017 14:00

Re: Simple Plugin does not work.
 
The 'auth' field returns the same value as what 'AuthId_Steam2' returns using GetClientAuthId so you can just check for that using StrEqual instead.

DarkDeviL 10-14-2017 14:19

Re: Simple Plugin does not work.
 
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.... */
}


headline 10-14-2017 14:40

Re: Simple Plugin does not work.
 
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

Powerlord 10-14-2017 17:15

Re: Simple Plugin does not work.
 
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?

blaacky 10-14-2017 20:43

Re: Simple Plugin does not work.
 
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

WildCard65 10-15-2017 08:33

Re: Simple Plugin does not work.
 
Quote:

Originally Posted by blaacky (Post 2554559)
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.

Powerlord 10-15-2017 17:52

Re: Simple Plugin does not work.
 
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.


All times are GMT -4. The time now is 16:45.

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