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

Steam group Servercommand


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ted2020
Junior Member
Join Date: Feb 2021
Old 02-15-2021 , 03:26   Steam group Servercommand
Reply With Quote #1

I'm trying to make a script that checks if the user is a member of a steam group and execute the sm_addvip with the client id or steamid32 or if is not a member makes sure to remove them again with sm_delvip ..followed by their steamid32

This is the code I have so far

PHP Code:
#pragma semicolon 1

#define DEBUG

#include <sourcemod>
#include <SteamWorks>
#include <autoexecconfig>

#define LoopAllPlayers(%1) for(int %1=1;%1<=MaxClients;++%1)\
if(IsClientInGame(%1) && !IsFakeClient(%1))

bool b_InGroup[MAXPLAYERS 1];

Handle GroupID;

int iGroupID;

public 
Plugin myinfo 
{
    
name "VIP Group players",
    
author "TED",
    
description "Assign og take VIP from user",
    
version "1.0",
    
url ""
};

public 
void OnPluginStart()
{
    
AutoExecConfig_SetFile("groupplayers");
    
    
HookConVarChange(GroupID         =    AutoExecConfig_CreateConVar("sm_groupid""xxxxxxxxxxxxxxxxxx""Group ID 64"),                                 OnCvarChanged);
    
    
AutoExecConfig_ExecuteFile();
    
AutoExecConfig_CleanFile();
    
    
UpdateConvars();
    
}

public 
void OnCvarChanged(Handle hConvar, const char[] chOldValue, const char[] chNewValue)
{
    
UpdateConvars();
}

public 
void UpdateConvars()
{
    
iGroupID         GetConVarInt(GroupID);    
}


public 
void OnClientPutInServer(int client)
{
    
b_InGroup[client] = false;
    
SteamWorks_GetUserGroupStatus(clientiGroupID);
}

public 
void OnClientAuthorized(int client)
{

    
decl String:player_authid;

    if(
IsClientInGame(client) && b_InGroup[client])
    {
        
ServerCommand("sm_addvip %i member 0"client);
        
PrintToServer("Added member VIP %i"client);
    }
    else
    {
        
// ServerCommand("sm_delvip %i", client);
        // PrintToServer("Removed member VIP %i", client);
    
}
}

public 
int SteamWorks_OnClientGroupStatus(int authidint groupidbool isMemberbool isOfficer)
{
    
    
int client GetUserFromAuthID(authid);
    
    if(
isMember)
    {
        
b_InGroup[client] = true;
    }
    
}

int GetUserFromAuthID(int authid)
{
    
    
LoopAllPlayers(i)
    {
        
char authstring[50];
        
GetClientAuthId(iAuthId_Steam3authstringsizeof(authstring));    
        
        
char authstring2[50];
        
IntToString(authidauthstring2sizeof(authstring2));
        
        if(
StrContains(authstringauthstring2) != -1)
        {
            return 
i;
        }
    }
    
    return -
1;


But what hook should I use and does anyone know if steamworks still "works"? Also I think the steamid32 part does not work.

Last edited by ted2020; 02-15-2021 at 03:28.
ted2020 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-15-2021 , 08:29   Re: Steam group Servercommand
Reply With Quote #2

You should check after admin check callback.
To mess too much with admin privilege.

*edit
You could mention what game ? Maybe all games not support 'AuthId_Steam3'

PHP Code:
#include <steamworks>



public void OnClientPostAdminCheck(int client)
{
/*
    Called once a client is authorized and fully in-game, and after all post-connection authorizations have been performed.
    This callback is guaranteed to occur on all clients, and always after each OnClientPutInServer() call.
*/

    
if(IsFakeClient(client)) return;

    
// https://steamcommunity.com/groups/CrowbarTool
    
SteamWorks_GetUserGroupStatus(client103582791434761767);
}


public 
int SteamWorks_OnClientGroupStatus(int authidint groupidbool isMemberbool isOfficer)
{
    
char sauthid[20];
    
Format(sauthidsizeof(sauthid), "%i"authid);

    
char steamid[20];
    
int client 0;
    
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || IsFakeClient(i)) continue;
        
        if(!
GetClientAuthId(iAuthId_Steam3steamidsizeof(steamid))) continue;
        
        if(
StrContains(steamidsauthidfalse) == -1) continue;
        
        
client i;
        break;
    }

    if(
client == 0) return; // Client not in game anymore

    // Already in admin cache
    
if(GetUserAdmin(client) != INVALID_ADMIN_ID)
    {
        if(
isMember) return;
        if(
isOfficer) return;
        
        
// Client is admin, but not in group member
        // Do code here
        
PrintToServer("%N is admin but not in group member"client);
    }
    else if(
isMember)
    {
        
// Client not admin, but is member
        // Do code here
        
PrintToServer("%N is not admin but in group member"client);
    }



__________________
Do not Private Message @me

Last edited by Bacardi; 02-15-2021 at 08:34.
Bacardi is offline
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 02-26-2021 , 17:27   Re: Steam group Servercommand
Reply With Quote #3

ServerCommand("sm_addvip %i member 0", client);
->

ServerCommand("sm_addvip \"%N\" 1", client); or
ServerCommand("sm_addvip \"%N\" member 1", client);

Last edited by jugule; 02-26-2021 at 17:28.
jugule is offline
StrikeR14
AlliedModders Donor
Join Date: Apr 2016
Location: Behind my PC
Old 03-01-2021 , 15:59   Re: Steam group Servercommand
Reply With Quote #4

Quote:
Originally Posted by jugule View Post
ServerCommand("sm_addvip %i member 0", client);
->

ServerCommand("sm_addvip \"%N\" 1", client); or
ServerCommand("sm_addvip \"%N\" member 1", client);
Should use GetClientUserId(client) to prevent injections in players names.
__________________
Currently taking TF2/CSGO paid private requests!

My Plugins | My Discord Account
StrikeR14 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 19:08.


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