View Single Post
dustinandband
Senior Member
Join Date: May 2015
Old 04-26-2017 , 11:07   Re: [ANY] SteamWorks
Reply With Quote #547

Hello,

Trying to get a plugin to work that uses this extention. The plugin requires Steamworks to be installed on the server. However I don't think I installed it correctly.

> Installed latest dev build from http://users.alliedmods.net/~kyles/builds/SteamWorks/
> Not sure where to install the main attached file ("SteamClient.tar.xz") since I can't find any file paths that are similar within the server.

To prevent non-group members from using our L4D2 servers (we're adding a bunch of addon maps and rayman's mutation mod), we're adding a check that on first connect - at least one client is a group member. If none is found - the server will quit (a cron job will then auto-relaunch the server when no screen session is found):

PHP Code:
//Pragma
#pragma semicolon 1
//#pragma newdecls required

//Sourcemod Includes
#include <sourcemod>
#include <sourcemod-misc>
#include <SteamWorks>

//ConVars
ConVar convar_Status;

//Globals
bool g_bIsPartOfGroup[MAXPLAYERS 1];

public 
Plugin myinfo 
{
    
name "Group Check"
    
author "Keith Warren (Drixevel)"
    
description "Checks the players if they're in a group and handles the server with the information."
    
version "1.0.0"
    
url "http://www.drixevel.com/"
};

public 
void OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
    
convar_Status CreateConVar("sm_groupcheck_status""1""Status of the plugin.\n1 = on, 0 = off"FCVAR_NOTIFYtrue0.0true1.0);
    
AutoExecConfig();
    
    
HookEvent("round_freeze_end"Event_OnRoundFreezeEnd);
}

public 
void OnConfigsExecuted()
{

}

public 
void Event_OnRoundFreezeEnd(Event event, const char[] namebool dontBroadcast)
{
    if (!
GetConVarBool(convar_Status))
    {
        return;
    }
    
    
CreateTimer(2.0Timer_CheckStatus_TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action Timer_CheckStatus(Handle timer)
{
    
bool closeserver;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i) && !g_bIsPartOfGroup[i])
        {
            
closeserver true;
        }
    }
    
    if (
closeserver)
    {
        
PrintToChatAll("\x06[SM] No players in session belong to steam group...");
        
        
CreateTimer(5.0Timer_Message2_TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action Timer_Message2(Handle timer)
{
    
PrintToChatAll("\x06Please join our steam group to use our servers:");
    
PrintToChatAll("\x06 GROUP_URL");
    
    
CreateTimer(5.0Timer_Message3_TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action Timer_Message3(Handle timer)
{
    
PrintToChatAll("\x06[SM] server shutting down in 10 seconds...");
    
    
CreateTimer(10.0Timer_Shutdown_TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action Timer_Shutdown(Handle timer)
{
    
ServerCommand("_restart");
}

public 
void OnClientPutInServer(int client)
{
    if (!
GetConVarBool(convar_Status) || IsFakeClient(client))
    {
        return;
    }
    
    
SteamWorks_GetUserGroupStatus(clientGROUPID);
}

public 
int SteamWorks_OnClientGroupStatus(int authidint groupidbool isMemberbool isOfficer)
{
    
int client GetClientFromAuthId(authid);
    
    if (
client == 0)
    {
        return;
    }
    
    
g_bIsPartOfGroup[client] = isMember;
}

int GetClientFromAuthId(int authid)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && authid == GetSteamAccountID(i))
        {
            return 
i;
        }
    }
    
    return 
0;

dustinandband is offline