View Single Post
Author Message
OfficialSikari
Junior Member
Join Date: Aug 2017
Location: /dev/null
Old 09-15-2017 , 07:40   [CSGO] Get game dir
Reply With Quote #1

Hey! I saw a few guys asking how to get the full game path to sourcemod
This might also work on other games

Code:
#include <sourcemod>

public void OnPluginStart()
{
	HookEvent("server_spawn", ServerSpawn);
}


public Action ServerSpawn(Event event, const char[] name, bool dontBroadcast)
{
        //Outputs G:\steamcmd\steamapps\common\Counter-Strike Global Offensive Beta - Dedicated Server\csgo
	char game[256];
	event.GetString("game", game, sizeof(game));
        
	char sm_path[128];
	BuildPath(Path_SM, sm_path, sizeof(sm_path), "");
	
	char full_path[400];
	Format(full_path, sizeof(full_path), "%s\\%s", game, sm_path);
	PrintToServer("Full Path: %s", full_path);
	//Output:  Full Path: G:\steamcmd\steamapps\common\Counter-Strike Global Offensive Beta - Dedicated Server\csgo\addons\sourcemod\

	UnhookEvent("server_spawn", ServerSpawn);
}

Last edited by OfficialSikari; 01-14-2019 at 16:00.
OfficialSikari is offline