summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-measure.sp
blob: 2360625892eb84390e3ae692f5e38caaed068198 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <sourcemod>

#include <sdktools>

#include <gokz/core>

#undef REQUIRE_EXTENSIONS
#undef REQUIRE_PLUGIN
#include <updater>

#pragma newdecls required
#pragma semicolon 1

/*
	Lets players measure the distance between two points.
	Credits to DaFox (https://forums.alliedmods.net/showthread.php?t=88830?t=88830)
*/


public Plugin myinfo = 
{
	name = "GOKZ Measure", 
	author = "DanZay", 
	description = "Provides tools for measuring things", 
	version = GOKZ_VERSION, 
	url = GOKZ_SOURCE_URL
};

#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-measure.txt"
#define MEASURE_MIN_DIST 0.01
int gI_BeamModel;
bool gB_Measuring[MAXPLAYERS + 1];
bool gB_MeasurePosSet[MAXPLAYERS + 1][2];
float gF_MeasurePos[MAXPLAYERS + 1][2][3];
float gF_MeasureNormal[MAXPLAYERS + 1][2][3];
Handle gH_P2PRed[MAXPLAYERS + 1];
Handle gH_P2PGreen[MAXPLAYERS + 1];

#include "gokz-measure/measurer.sp"
#include "gokz-measure/commands.sp"
#include "gokz-measure/measure_menu.sp"


// =====[ PLUGIN EVENTS ]=====

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
	RegPluginLibrary("gokz-measure");
	return APLRes_Success;
}

public void OnPluginStart()
{
	LoadTranslations("gokz-measure.phrases");
	
	RegisterCommands();
}

public void OnAllPluginsLoaded()
{
	if (LibraryExists("updater"))
	{
		Updater_AddPlugin(UPDATER_URL);
	}
}

public void OnLibraryAdded(const char[] name)
{
	if (StrEqual(name, "updater"))
	{
		Updater_AddPlugin(UPDATER_URL);
	}
}



// =====[ OTHER EVENTS ]=====

public void OnMapStart()
{
	gI_BeamModel = PrecacheModel("materials/sprites/laserbeam.vmt", true);
}