-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInfiniteFlashlight.as
65 lines (44 loc) · 1.53 KB
/
InfiniteFlashlight.as
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
58
59
60
61
62
63
64
65
/*
Copyright (c) 2017 Drake "MrOats" Denston
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
Current Status: Stable.
Documentation: https://github.com/MrOats/AngelScript_SC_Plugins/wiki/InfiniteFlashlight.as
*/
// Globals
CScheduledFunction@ g_TimeUntilMax = null;
CCVar@ g_InfiniteFlashLight;
void PluginInit()
{
g_Module.ScriptInfo.SetAuthor("MrOats");
g_Module.ScriptInfo.SetContactInfo("https://forums.svencoop.com/showthread.php/44687-Plugin-Infinite-Flashlight");
g_Hooks.RegisterHook(Hooks::Game::MapChange,@ResetCVars);
@g_InfiniteFlashLight = CCVar("infiniteFlashlightEnable", true, "Whether or not this plugin should run", ConCommandFlag::AdminOnly);
}
void MapActivate()
{
g_Scheduler.ClearTimerList();
@g_TimeUntilMax = null;
if (g_InfiniteFlashLight.GetBool())
@g_TimeUntilMax = g_Scheduler.SetInterval("SetFlashlightsToMax",5.0f,g_Scheduler.REPEAT_INFINITE_TIMES);
else
g_Game.AlertMessage(at_logged, "Infinite Flash Light disabled.\n");
}
void SetFlashlightsToMax()
{
for (int i = 1; i <= g_Engine.maxClients; i++)
{
CBasePlayer@ pPlayer = g_PlayerFuncs.FindPlayerByIndex(i);
if ( (pPlayer !is null) && (pPlayer.IsAlive()) )
pPlayer.m_iFlashBattery = 100;
}
}
HookReturnCode ResetCVars()
{
g_Scheduler.ClearTimerList();
@g_TimeUntilMax = null;
return HOOK_HANDLED;
}