AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSGO] Get game dir (https://forums.alliedmods.net/showthread.php?t=301285)

OfficialSikari 09-15-2017 07:40

[CSGO] Get game dir
 
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);
}


Ermert1992 10-23-2017 03:30

Re: [CSGO] Get game dir
 
Cool. Thank you!


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

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