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(client, iGroupID);
}
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 authid, int groupid, bool isMember, bool isOfficer)
{
int client = GetUserFromAuthID(authid);
if(isMember)
{
b_InGroup[client] = true;
}
}
int GetUserFromAuthID(int authid)
{
LoopAllPlayers(i)
{
char authstring[50];
GetClientAuthId(i, AuthId_Steam3, authstring, sizeof(authstring));
char authstring2[50];
IntToString(authid, authstring2, sizeof(authstring2));
if(StrContains(authstring, authstring2) != -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.