-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiuwiki_changemode.sp
57 lines (47 loc) · 1.52 KB
/
miuwiki_changemode.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <dhooks>
#define LINUX "@_ZN9CDirector11GetGameModeEv"
#define GAME_DATA "l4d2_gamemode"
#define PLUGIN_VERSION "1.0.0"
public Plugin myinfo =
{
name = "[L4D2] Modify The Game Mode",
author = "Miuwiki",
description = "Modify the game mode",
version = PLUGIN_VERSION,
url = "http://www.miuwiki.site"
}
public void OnPluginStart()
{
LoadGameData();
}
public void OnMapStart()
{
}
void LoadGameData()
{
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "gamedata/%s.txt", GAME_DATA);
if(FileExists(sPath) == false)
SetFailState("\n==========\nMissing required file: \"%s\".\n==========", sPath);
GameData hGameData = new GameData(GAME_DATA);
if(hGameData == null)
SetFailState("Failed to load \"%s.txt\" gamedata.", GAME_DATA);
Handle hDetour_ChangeGamemode;
hDetour_ChangeGamemode = DHookCreateFromConf(hGameData, "CDirector::GetGameMode");
if(!hDetour_ChangeGamemode)
SetFailState("Failed to find 'CDirector::GetGameMode' signature");
if(!DHookEnableDetour(hDetour_ChangeGamemode, false, OnGetGameModeHook))
SetFailState("Failed to detour 'CDirector::GetGameMode'");
}
public MRESReturn OnGetGameModeHook(DHookReturn hReturn)
{
static char temp[64];
hReturn.GetString(temp,sizeof(temp));
PrintToServer("fire GetGameMode(), %s, time = %f", temp, GetGameTime());
// hReturn.SetString("my gamemode");
return MRES_Ignored;
}