AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Steam group Servercommand (https://forums.alliedmods.net/showthread.php?t=330665)

ted2020 02-15-2021 03:26

Steam group Servercommand
 
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.

Bacardi 02-15-2021 08:29

Re: Steam group Servercommand
 
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);
    }





jugule 02-26-2021 17:27

Re: Steam group Servercommand
 
ServerCommand("sm_addvip %i member 0", client);
->

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

StrikeR14 03-01-2021 15:59

Re: Steam group Servercommand
 
Quote:

Originally Posted by jugule (Post 2738435)
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.


All times are GMT -4. The time now is 07:40.

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