Devzones

Created Diff never expires
145 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
910 lines
136 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
901 lines
/* SM DEV Zones
*
* Copyright (C) 2017-2018 Francisco 'Franc1sco' García and Totenfluch
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/.
*/

#pragma semicolon 1
#pragma semicolon 1
#include <sourcemod>
#include <sourcemod>
#include <sdktools>
#include <sdktools>
#include <colorvariables>




#define VERSION "3.3.1"
#define PLUGIN_VERSION "0.1.0"
#pragma newdecls required
#pragma newdecls required


#define MAX_ZONES 256
#define MAX_ZONES 256


int beamColorT[4] = { 255, 0, 0, 255 };
int beamColorT[4] = { 255, 0, 0, 255 };
int beamColorCT[4] = { 0, 0, 255, 255 };
int beamColorCT[4] = { 0, 0, 255, 255 };
int beamColorN[4] = { 255, 255, 0, 255 };
int beamColorN[4] = { 255, 255, 0, 255 };
int beamColorM[4] = { 0, 255, 0, 255 };
int beamColorM[4] = { 0, 255, 0, 255 };


int g_CurrentZoneTeam[MAXPLAYERS + 1];
int g_CurrentZoneTeam[MAXPLAYERS + 1];
int g_CurrentZoneVis[MAXPLAYERS + 1];
int g_CurrentZoneVis[MAXPLAYERS + 1];
char g_CurrentZoneName[MAXPLAYERS + 1][64];
char g_CurrentZoneName[MAXPLAYERS + 1][64];
// VARIABLES
// VARIABLES
Handle g_Zones = INVALID_HANDLE;
Handle g_Zones = INVALID_HANDLE;
int g_Editing[MAXPLAYERS + 1] = { 0, ... };
int g_Editing[MAXPLAYERS + 1] = { 0, ... };
float g_Positions[MAXPLAYERS + 1][2][3];
float g_Positions[MAXPLAYERS + 1][2][3];
int g_ClientSelectedZone[MAXPLAYERS + 1] = { -1, ... };
int g_ClientSelectedZone[MAXPLAYERS + 1] = { -1, ... };
bool g_bFixName[MAXPLAYERS + 1];
bool g_bFixName[MAXPLAYERS + 1];


int g_BeamSprite;
int g_BeamSprite;
int g_HaloSprite;
int g_HaloSprite;


Handle hOnClientEntry = INVALID_HANDLE;
Handle hOnClientEntry = INVALID_HANDLE;
Handle hOnClientLeave = INVALID_HANDLE;
Handle hOnClientLeave = INVALID_HANDLE;




enum g_eList {
enum struct g_eList {
String:liName[64],
char liName[64];
bool:liThis
bool liThis;
};
}


int g_iZones[2048][MAX_ZONES][g_eList]; // max zones = 256
g_eList g_iZones[2048][MAX_ZONES];




// cvars
// cvars


Handle cvar_filter;
Handle cvar_filter;
Handle cvar_mode;
Handle cvar_mode;
Handle cvar_checker;
Handle cvar_checker;
Handle cvar_model;
Handle cvar_model;


bool g_bfilter;
bool g_bfilter;
float checker;
float checker;
bool mode_plugin;
bool mode_plugin;
char sModel[192];
char sModel[192];


Handle cvar_timer = INVALID_HANDLE;
Handle cvar_timer = INVALID_HANDLE;
Handle g_SlapDamage = INVALID_HANDLE;
Handle g_PunishDelay = INVALID_HANDLE;
Handle g_PunishFreq = INVALID_HANDLE;


Handle hOnZoneCreated;
Handle hOnZoneCreated;


Handle g_hClientTimers[MAXPLAYERS + 1] = {null, ...};
Handle g_hPunishTimers[MAXPLAYERS + 1] = {null, ...};
Handle g_hFreqTimers[MAXPLAYERS + 1] = {null, ...};
char g_numRepeats[MAXPLAYERS + 1] = {0, ...};
Handle cvar_time;

// PLUGIN INFO
// PLUGIN INFO
public Plugin myinfo =
public Plugin myinfo =
{
{
name = "SM DEV Zones",
name = "Advanced AntiCamp",
author = "Franc1sco, root, Totenfluch",
author = "Sarrus, Franc1sco",
description = "Adds Custom Zones",
description = "Adds zones where players can't camp for more than a specific amount of time.",
version = VERSION,
version = PLUGIN_VERSION,
url = "https://github.com/Franc1sco/DevZones"
url = ""
};
};


public void OnPluginStart() {
public void OnPluginStart() {
cvar_filter = CreateConVar("sm_devzones_filter", "1", "1 = Only allow valid alive clients to be detected in the native zones. 0 = Detect entities and all (you need to add more checkers in the third party plugins).");
LoadTranslations("advancedanticamp.phrases");
cvar_mode = CreateConVar("sm_devzones_mode", "1", "0 = Use checks every X seconds for check if a player join or leave a zone, 1 = hook zone entities with OnStartTouch and OnEndTouch (less CPU consume)");

cvar_checker = CreateConVar("sm_devzones_checker", "5.0", "checks and beambox refreshs per second, low value = more precise but more CPU consume, More hight = less precise but less CPU consume");
CreateConVar("advanced_anticamp_version", PLUGIN_VERSION, "Plugin Version", FCVAR_REPLICATED);
cvar_model = CreateConVar("sm_devzones_model", "models/error.mdl", "Use a model for zone entity (IMPORTANT: change this value only on map start)");
cvar_filter = CreateConVar("sm_advancedanticamp_filter", "1", "1 = Only allow valid alive clients to be detected in the native zones. 0 = Detect entities and all (you need to add more checkers in the third party plugins).");
cvar_mode = CreateConVar("sm_advancedanticamp_mode", "1", "0 = Use checks every X seconds for check if a player join or leave a zone, 1 = hook zone entities with OnStartTouch and OnEndTouch (less CPU consume)");
cvar_checker = CreateConVar("sm_advancedanticamp_checker", "5.0", "checks and beambox refreshs per second, low value = more precise but more CPU consume, More hight = less precise but less CPU consume");
cvar_model = CreateConVar("sm_advancedanticamp_model", "models/error.mdl", "Use a model for zone entity (IMPORTANT: change this value only on map start)");
cvar_time = CreateConVar("sm_advancedanticamp_time", "10", "Time in seconds before players must leave the zone or die");
g_SlapDamage = CreateConVar("sm_advancedanticamp_slapdamage", "0", "Damage to inflict to the player when slapping.", 0, true, 0.0, true, 100.0);
g_PunishDelay = CreateConVar("sm_advancedanticamp_punishdelay", "2", "How much time before slapping.", 0, true, 0.0);
g_PunishFreq = CreateConVar("sm_advancedanticamp_punishfreq", "2", "How much time between slaps.", 0, true, 0.0);
g_Zones = CreateArray(256);
g_Zones = CreateArray(256);
RegAdminCmd("sm_zones", Command_CampZones, ADMFLAG_CUSTOM6);
RegAdminCmd("sm_campzones", Command_CampZones, ADMFLAG_CUSTOM6);
RegConsoleCmd("say", fnHookSay);
RegConsoleCmd("say", fnHookSay);

HookEventEx("round_start", Event_OnRoundStart);
HookEventEx("round_start", Event_OnRoundStart);
HookEventEx("round_end", Event_OnRoundEnd, EventHookMode_Pre);
HookEventEx("player_spawn", Event_PlayerSpawn, EventHookMode_Pre);
HookEventEx("player_spawn", Event_PlayerSpawn, EventHookMode_Pre);
HookEventEx("teamplay_round_start", Event_OnRoundStart);
HookEventEx("teamplay_round_start", Event_OnRoundStart);
//HookEvent("round_start", OnRoundStart);

GetCVars();
GetCVars();

HookConVarChange(cvar_filter, CVarChange);
HookConVarChange(cvar_filter, CVarChange);
HookConVarChange(cvar_checker, CVarChange);
HookConVarChange(cvar_checker, CVarChange);
HookConVarChange(cvar_mode, CVarChange);
HookConVarChange(cvar_mode, CVarChange);
HookConVarChange(cvar_model, CVarChange);
HookConVarChange(cvar_model, CVarChange);
HookConVarChange(g_SlapDamage, CVarChange);
HookConVarChange(g_PunishDelay, CVarChange);
AutoExecConfig(true,"plugin.advancedanticamp");

}
}


// fixes for Zone_IsClientInZone native
// fixes for Zone_IsClientInZone native
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int client = GetClientOfUserId(GetEventInt(event, "userid"));
resetClient(client);
resetClient(client);
}
}


public void OnEntityDestroyed(int entity)
public void OnEntityDestroyed(int entity)
{
{
if (entity < 0 || entity > 2048)return;
if (entity < 0 || entity > 2048)return;

resetClient(entity);
resetClient(entity);
}
}
//
//


public void OnPluginEnd()
public void OnPluginEnd()
{
{
RemoveZones();
RemoveZones();
}
}


public void resetClient(int client) {
public void resetClient(int client) {
for (int i = 0; i < MAX_ZONES; i++)
for (int i = 0; i < MAX_ZONES; i++)
g_iZones[client][i][liThis] = false;
g_iZones[client][i].liThis = false;
}
}


public void CVarChange(Handle convar_hndl, const char[] oldValue, const char[] newValue) {
public void CVarChange(Handle convar_hndl, const char[] oldValue, const char[] newValue) {
GetCVars();
GetCVars();
}
}


// Get int values of cvars if they has being changed
// Get int values of cvars if they has being changed
public void GetCVars() {
public void GetCVars() {
g_bfilter = GetConVarBool(cvar_filter);
g_bfilter = GetConVarBool(cvar_filter);
mode_plugin = GetConVarBool(cvar_mode);
mode_plugin = GetConVarBool(cvar_mode);
checker = GetConVarFloat(cvar_checker);
checker = GetConVarFloat(cvar_checker);
GetConVarString(cvar_model, sModel, 192);
GetConVarString(cvar_model, sModel, 192);

if (cvar_timer != INVALID_HANDLE) {
if (cvar_timer != INVALID_HANDLE) {
KillTimer(cvar_timer);
KillTimer(cvar_timer);
cvar_timer = INVALID_HANDLE;
cvar_timer = INVALID_HANDLE;
}
}
cvar_timer = CreateTimer(checker, BeamBoxAll, _, TIMER_REPEAT);
cvar_timer = CreateTimer(checker, BeamBoxAll, _, TIMER_REPEAT);
}
}


public void OnClientPostAdminCheck(int client) {
public void OnClientPostAdminCheck(int client) {
g_ClientSelectedZone[client] = -1;
g_ClientSelectedZone[client] = -1;
g_Editing[client] = 0;
g_Editing[client] = 0;
g_bFixName[client] = false;
g_bFixName[client] = false;
resetClient(client);
resetClient(client);
}
}


public Action Event_OnRoundStart(Handle event, const char[] name, bool dontBroadcast) {
public Action Event_OnRoundStart(Handle event, const char[] name, bool dontBroadcast) {
if (mode_plugin)
if (mode_plugin)
RefreshZones();
RefreshZones();
}
}


public int CreateZoneEntity(float fMins[3], float fMaxs[3], char sZoneName[64]) {
public int CreateZoneEntity(float fMins[3], float fMaxs[3], char sZoneName[64]) {
float fMiddle[3];
float fMiddle[3];
int iEnt = CreateEntityByName("trigger_multiple");
int iEnt = CreateEntityByName("trigger_multiple");

Call_StartForward(hOnZoneCreated);
Call_StartForward(hOnZoneCreated);
Call_PushString(sZoneName);
Call_PushString(sZoneName);
Call_Finish();
Call_Finish();

DispatchKeyValue(iEnt, "spawnflags", "64");
DispatchKeyValue(iEnt, "spawnflags", "64");
Format(sZoneName, sizeof(sZoneName), "sm_devzone %s", sZoneName);
Format(sZoneName, sizeof(sZoneName), "sm_devzone %s", sZoneName);
DispatchKeyValue(iEnt, "targetname", sZoneName);
DispatchKeyValue(iEnt, "targetname", sZoneName);
DispatchKeyValue(iEnt, "wait", "0");
DispatchKeyValue(iEnt, "wait", "0");

DispatchSpawn(iEnt);
DispatchSpawn(iEnt);
ActivateEntity(iEnt);
ActivateEntity(iEnt);

GetMiddleOfABox(fMins, fMaxs, fMiddle);
GetMiddleOfABox(fMins, fMaxs, fMiddle);

TeleportEntity(iEnt, fMiddle, NULL_VECTOR, NULL_VECTOR);
TeleportEntity(iEnt, fMiddle, NULL_VECTOR, NULL_VECTOR);
SetEntityModel(iEnt, sModel);
SetEntityModel(iEnt, sModel);


// Have the mins always be negative
// Have the mins always be negative
fMins[0] = fMins[0] - fMiddle[0];
fMins[0] = fMins[0] - fMiddle[0];
if (fMins[0] > 0.0)
if (fMins[0] > 0.0)
fMins[0] *= -1.0;
fMins[0] *= -1.0;
fMins[1] = fMins[1] - fMiddle[1];
fMins[1] = fMins[1] - fMiddle[1];
if (fMins[1] > 0.0)
if (fMins[1] > 0.0)
fMins[1] *= -1.0;
fMins[1] *= -1.0;
fMins[2] = fMins[2] - fMiddle[2];
fMins[2] = fMins[2] - fMiddle[2];
if (fMins[2] > 0.0)
if (fMins[2] > 0.0)
fMins[2] *= -1.0;
fMins[2] *= -1.0;

// And the maxs always be positive
// And the maxs always be positive
fMaxs[0] = fMaxs[0] - fMiddle[0];
fMaxs[0] = fMaxs[0] - fMiddle[0];
if (fMaxs[0] < 0.0)
if (fMaxs[0] < 0.0)
fMaxs[0] *= -1.0;
fMaxs[0] *= -1.0;
fMaxs[1] = fMaxs[1] - fMiddle[1];
fMaxs[1] = fMaxs[1] - fMiddle[1];
if (fMaxs[1] < 0.0)
if (fMaxs[1] < 0.0)
fMaxs[1] *= -1.0;
fMaxs[1] *= -1.0;
fMaxs[2] = fMaxs[2] - fMiddle[2];
fMaxs[2] = fMaxs[2] - fMiddle[2];
if (fMaxs[2] < 0.0)
if (fMaxs[2] < 0.0)
fMaxs[2] *= -1.0;
fMaxs[2] *= -1.0;

SetEntPropVector(iEnt, Prop_Send, "m_vecMins", fMins);
SetEntPropVector(iEnt, Prop_Send, "m_vecMins", fMins);
SetEntPropVector(iEnt, Prop_Send, "m_vecMaxs", fMaxs);
SetEntPropVector(iEnt, Prop_Send, "m_vecMaxs", fMaxs);
SetEntProp(iEnt, Prop_Send, "m_nSolidType", 2);
SetEntProp(iEnt, Prop_Send, "m_nSolidType", 2);

int iEffects = GetEntProp(iEnt, Prop_Send, "m_fEffects");
int iEffects = GetEntProp(iEnt, Prop_Send, "m_fEffects");
iEffects |= 32;
iEffects |= 32;
SetEntProp(iEnt, Prop_Send, "m_fEffects", iEffects);
SetEntProp(iEnt, Prop_Send, "m_fEffects", iEffects);

HookSingleEntityOutput(iEnt, "OnStartTouch", EntOut_OnStartTouch);
HookSingleEntityOutput(iEnt, "OnStartTouch", EntOut_OnStartTouch);
HookSingleEntityOutput(iEnt, "OnEndTouch", EntOut_OnEndTouch);
HookSingleEntityOutput(iEnt, "OnEndTouch", EntOut_OnEndTouch);

return iEnt;
return iEnt;
}
}


public void EntOut_OnStartTouch(const char[] output, int caller, int activator, float delay) {
public void EntOut_OnStartTouch(const char[] output, int caller, int activator, float delay) {
// Ignore dead players
// Ignore dead players
if (g_bfilter)
if (g_bfilter)
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
return;
return;

char sTargetName[256];
char sTargetName[256];
GetEntPropString(caller, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
GetEntPropString(caller, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
ReplaceString(sTargetName, sizeof(sTargetName), "sm_devzone ", "");
ReplaceString(sTargetName, sizeof(sTargetName), "sm_devzone ", "");


// entra
// entra
char nBuf[64];
char nBuf[64];
Entity_GetGlobalName(caller, nBuf, sizeof(nBuf));
Entity_GetGlobalName(caller, nBuf, sizeof(nBuf));
int callerId = StringToInt(nBuf);
int callerId = StringToInt(nBuf);
g_iZones[activator][callerId][liThis] = true;
g_iZones[activator][callerId].liThis = true;
Format(g_iZones[activator][callerId][liName], 64, sTargetName);
Format(g_iZones[activator][callerId].liName, 64, sTargetName);
//PrintToChatAll("E::%i::%s::", callerId, sTargetName);
//PrintToChatAll("E::%i::%s::", callerId, sTargetName);
Call_StartForward(hOnClientEntry);
Call_StartForward(hOnClientEntry);
Call_PushCell(activator);
Call_PushCell(activator);
Call_PushString(sTargetName);
Call_PushString(sTargetName);
Call_Finish();
Call_Finish();
}
}


public void EntOut_OnEndTouch(const char[] output, int caller, int activator, float delay) {
public void EntOut_OnEndTouch(const char[] output, int caller, int activator, float delay) {
// Ignore dead players
// Ignore dead players
if (g_bfilter)
if (g_bfilter)
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
return;
return;

char sTargetName[256];
char sTargetName[256];
GetEntPropString(caller, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
GetEntPropString(caller, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
ReplaceString(sTargetName, sizeof(sTargetName), "sm_devzone ", "");
ReplaceString(sTargetName, sizeof(sTargetName), "sm_devzone ", "");


// sale
// sale
char nBuf[64];
char nBuf[64];
Entity_GetGlobalName(caller, nBuf, sizeof(nBuf));
Entity_GetGlobalName(caller, nBuf, sizeof(nBuf));
int callerId = StringToInt(nBuf);
int callerId = StringToInt(nBuf);
g_iZones[activator][callerId][liThis] = false;
g_iZones[activator][callerId].liThis = false;
Format(g_iZones[activator][callerId][liName], 64, "");
Format(g_iZones[activator][callerId].liName, 64, "");
//PrintToChatAll("EX::%i::%s::", callerId, sTargetName);
//PrintToChatAll("EX::%i::%s::", callerId, sTargetName);
Call_StartForward(hOnClientLeave);
Call_StartForward(hOnClientLeave);
Call_PushCell(activator);
Call_PushCell(activator);
Call_PushString(sTargetName);
Call_PushString(sTargetName);
Call_Finish();
Call_Finish();

}
}


public void OnMapStart() {
public void OnMapStart() {


for (int i = 1; i < MAXPLAYERS; i++)
for (int i = 1; i < MAXPLAYERS; i++)
resetClient(i);
resetClient(i);


g_BeamSprite = PrecacheModel("sprites/laserbeam.vmt");
g_BeamSprite = PrecacheModel("sprites/laserbeam.vmt");
g_HaloSprite = PrecacheModel("materials/sprites/halo.vmt");
g_HaloSprite = PrecacheModel("materials/sprites/halo.vmt");
PrecacheModel(sModel);
PrecacheModel(sModel);

ReadZones();
ReadZones();
RefreshZones();
RefreshZones();
}
}


public void OnMapEnd() {
public void OnMapEnd() {
SaveZones(0);
SaveZones(0);
for(int iClient = 1; iClient <= MaxClients; iClient++)
{
if(IsClientInGame(iClient))
{
delete(g_hClientTimers[iClient]);
delete(g_hPunishTimers[iClient]);
delete(g_hFreqTimers[iClient]);
g_numRepeats[iClient] = 0;
}
}
}
}


public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon) {
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon) {
BeamBox_OnPlayerRunCmd(client);
BeamBox_OnPlayerRunCmd(client);
}
}


public Action Command_CampZones(int client, int args) {
public Action Command_CampZones(int client, int args) {
ZoneMenu(client);
ZoneMenu(client);
}
}


public void getZoneTeamColor(int team, int color[4]) {
public void getZoneTeamColor(int team, int color[4]) {
switch (team)
switch (team)
{
{
case 1:
case 1:
{
{
color = beamColorM;
color = beamColorM;
}
}
case 2:
case 2:
{
{
color = beamColorT;
color = beamColorT;
}
}
case 3:
case 3:
{
{
color = beamColorCT;
color = beamColorCT;
}
}
default:
default:
{
{
color = beamColorN;
color = beamColorN;
}
}
}
}
}
}


public void ReadZones() {
public void ReadZones() {

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
if(size > 0)
if(size > 0)
{
{
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
CloseHandle(GetArrayCell(g_Zones, i));
CloseHandle(GetArrayCell(g_Zones, i));
}
}
}
}
ClearArray(g_Zones);
ClearArray(g_Zones);
char Path[512];
char Path[512];
BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones");
BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones");
if (!DirExists(Path))
if (!DirExists(Path))
CreateDirectory(Path, 0777);
CreateDirectory(Path, 0777);

char map[64];
char map[64];
GetCurrentMap(map, sizeof(map));
GetCurrentMap(map, sizeof(map));
if (StrContains(map, "workshop") != -1) {
if (StrContains(map, "workshop") != -1) {
char mapPart[3][64];
char mapPart[3][64];
ExplodeString(map, "/", mapPart, 3, 64);
ExplodeString(map, "/", mapPart, 3, 64);
strcopy(map, sizeof(map), mapPart[2]);
strcopy(map, sizeof(map), mapPart[2]);
}
}
BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones/%s.zones.txt", map);
BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones/%s.zones.txt", map);
if (!FileExists(Path))
if (!FileExists(Path))
{
{
//Handle file = OpenFile(Path, "w");
//Handle file = OpenFile(Path, "w");
//CloseHandle(file);
//CloseHandle(file);
Handle kv = CreateKeyValues("Zones");
Handle kv = CreateKeyValues("Zones");
KeyValuesToFile(kv, Path);
KeyValuesToFile(kv, Path);
}
}


Handle kv = CreateKeyValues("Zones");
Handle kv = CreateKeyValues("Zones");
FileToKeyValues(kv, Path);
FileToKeyValues(kv, Path);
if (!KvGotoFirstSubKey(kv))
if (!KvGotoFirstSubKey(kv))
{
{
PrintToServer("[ERROR] Config file is corrupted: %s", Path);
PrintToServer("[ERROR] Config file is corrupted: %s", Path);
return;
return;
}
}
float pos1[3];
float pos1[3];
float pos2[3];
float pos2[3];
char nombre[64];
char nombre[64];
do
do
{
{
KvGetVector(kv, "cordinate_a", pos1);
KvGetVector(kv, "cordinate_a", pos1);
KvGetVector(kv, "cordinate_b", pos2);
KvGetVector(kv, "cordinate_b", pos2);
KvGetString(kv, "name", nombre, 64);
KvGetString(kv, "name", nombre, 64);
Handle trie = CreateTrie();
Handle trie = CreateTrie();
SetTrieArray(trie, "corda", pos1, 3);
SetTrieArray(trie, "corda", pos1, 3);
SetTrieArray(trie, "cordb", pos2, 3);
SetTrieArray(trie, "cordb", pos2, 3);
SetTrieValue(trie, "team", KvGetNum(kv, "team", 0));
SetTrieValue(trie, "team", KvGetNum(kv, "team", 0));
SetTrieValue(trie, "vis", KvGetNum(kv, "vis", 0));
SetTrieValue(trie, "vis", KvGetNum(kv, "vis", 0));
SetTrieString(trie, "name", nombre);
SetTrieString(trie, "name", nombre);
PushArrayCell(g_Zones, trie);
PushArrayCell(g_Zones, trie);
//CloseHandle(trie);
//CloseHandle(trie);
} while (KvGotoNextKey(kv));
} while (KvGotoNextKey(kv));
CloseHandle(kv);
CloseHandle(kv);
}
}


public void SaveZones(int client) {
public void SaveZones(int client) {
char Path[512];
char Path[512];
char map[64];
char map[64];
GetCurrentMap(map, sizeof(map));
GetCurrentMap(map, sizeof(map));
if (StrContains(map, "workshop") != -1) {
if (StrContains(map, "workshop") != -1) {
char mapPart[3][64];
char mapPart[3][64];
ExplodeString(map, "/", mapPart, 3, 64);
ExplodeString(map, "/", mapPart, 3, 64);
strcopy(map, sizeof(map), mapPart[2]);
strcopy(map, sizeof(map), mapPart[2]);
}
}
BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones/%s.zones.txt", map);
BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones/%s.zones.txt", map);
Handle file = OpenFile(Path, "w+");
Handle file = OpenFile(Path, "w+");
CloseHandle(file);
CloseHandle(file);
float pos1[3];
float pos1[3];
float pos2[3];
float pos2[3];
char SectName[64];
char SectName[64];
int Team;
int Team;
int Vis;
int Vis;
char nombre[64];
char nombre[64];

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
Handle kv = CreateKeyValues("Zones");
Handle kv = CreateKeyValues("Zones");
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
IntToString(i, SectName, sizeof(SectName));
IntToString(i, SectName, sizeof(SectName));

Handle trie = GetArrayCell(g_Zones, i);
Handle trie = GetArrayCell(g_Zones, i);
GetTrieArray(trie, "corda", pos1, sizeof(pos1));
GetTrieArray(trie, "corda", pos1, sizeof(pos1));
GetTrieArray(trie, "cordb", pos2, sizeof(pos2));
GetTrieArray(trie, "cordb", pos2, sizeof(pos2));
GetTrieValue(trie, "team", Team);
GetTrieValue(trie, "team", Team);
GetTrieValue(trie, "vis", Vis);
GetTrieValue(trie, "vis", Vis);
GetTrieString(trie, "name", nombre, 64);
GetTrieString(trie, "name", nombre, 64);
//Format(Nombre, 64, "Zone %i", i);
//Format(Nombre, 64, "Zone %i", i);
//SetTrieString(trie, "name", Nombre, true);
//SetTrieString(trie, "name", Nombre, true);

KvJumpToKey(kv, SectName, true);
KvJumpToKey(kv, SectName, true);
KvSetString(kv, "name", nombre);
KvSetString(kv, "name", nombre);
KvSetVector(kv, "cordinate_a", pos1);
KvSetVector(kv, "cordinate_a", pos1);
KvSetVector(kv, "cordinate_b", pos2);
KvSetVector(kv, "cordinate_b", pos2);
KvSetNum(kv, "vis", Vis);
KvSetNum(kv, "vis", Vis);
KvSetNum(kv, "team", Team);
KvSetNum(kv, "team", Team);
KvGoBack(kv);
KvGoBack(kv);
}
}
KeyValuesToFile(kv, Path);
KeyValuesToFile(kv, Path);
CloseHandle(kv);
CloseHandle(kv);
if (client != 0)
if (client != 0)
PrintToChat(client, "All zones are saved in file.");
PrintToChat(client, "All zones are saved in file.");
}
}


public bool TraceRayDontHitSelf(int entity, int mask, any data) {
public bool TraceRayDontHitSelf(int entity, int mask, any data) {
if (entity == data)
if (entity == data)
return false;
return false;
return true;
return true;
}
}


public Action fnHookSay(int client, int args) {
public Action fnHookSay(int client, int args) {
if (!g_bFixName[client])return;
if (!g_bFixName[client])return;

char sArgs[192];
char sArgs[192];
GetCmdArgString(sArgs, sizeof(sArgs));
GetCmdArgString(sArgs, sizeof(sArgs));

StripQuotes(sArgs);
StripQuotes(sArgs);

ReplaceString(sArgs, 192, "'", ".");
ReplaceString(sArgs, 192, "'", ".");
ReplaceString(sArgs, 192, "<", ".");
ReplaceString(sArgs, 192, "<", ".");
//ReplaceString(sArgs, 192, "\"", ".");
//ReplaceString(sArgs, 192, "\"", ".");
if (strlen(sArgs) > 45)
if (strlen(sArgs) > 45)
{
{
PrintToChat(client, "the name is too long, try other name");
PrintToChat(client, "the name is too long, try other name");
return;
return;
}
}
if (StrEqual(sArgs, "!cancel"))
if (StrEqual(sArgs, "!cancel"))
{
{
PrintToChat(client, "Set name action canceled");
PrintToChat(client, "Set name action canceled");
EditorMenu(client);
EditorMenu(client);
return;
return;
}
}
char ZoneId[64];
char ZoneId[64];
int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
Handle trie = GetArrayCell(g_Zones, i);
Handle trie = GetArrayCell(g_Zones, i);
GetTrieString(trie, "name", ZoneId, 64);
GetTrieString(trie, "name", ZoneId, 64);
if (StrEqual(ZoneId, sArgs))
if (StrEqual(ZoneId, sArgs))
{
{
PrintToChat(client, "The name already exist, write other name");
PrintToChat(client, "The name already exist, write other name");
return;
return;
}
}
}
}

Format(g_CurrentZoneName[client], 64, sArgs);
Format(g_CurrentZoneName[client], 64, sArgs);
PrintToChat(client, "Zone name set to %s", sArgs);
PrintToChat(client, "Zone name set to %s", sArgs);
g_bFixName[client] = false;
g_bFixName[client] = false;
EditorMenu(client);
EditorMenu(client);
}
}


public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
hOnClientEntry = CreateGlobalForward("Zone_OnClientEntry", ET_Ignore, Param_Cell, Param_String);
hOnClientEntry = CreateGlobalForward("Zone_OnClientEntry", ET_Ignore, Param_Cell, Param_String);
hOnClientLeave = CreateGlobalForward("Zone_OnClientLeave", ET_Ignore, Param_Cell, Param_String);
hOnClientLeave = CreateGlobalForward("Zone_OnClientLeave", ET_Ignore, Param_Cell, Param_String);
hOnZoneCreated = CreateGlobalForward("Zone_OnCreated", ET_Ignore, Param_String);
hOnZoneCreated = CreateGlobalForward("Zone_OnCreated", ET_Ignore, Param_String);
CreateNative("Zone_IsClientInZone", Native_InZone);
CreateNative("Zone_IsClientInZone", Native_InZone);
CreateNative("Zone_GetZonePosition", Native_Teleport);
CreateNative("Zone_GetZonePosition", Native_Teleport);
CreateNative("Zone_CheckIfZoneExists", Native_ZoneExist);
CreateNative("Zone_CheckIfZoneExists", Native_ZoneExist);
CreateNative("Zone_isPositionInZone", Native_isPositionInZone);
CreateNative("Zone_isPositionInZone", Native_isPositionInZone);
/*
/*
@Param1 -> int client
@Param1 -> int client
@Param2 -> char[64] zoneBuffer
@Param2 -> char[64] zoneBuffer

@return true if zone found false if not
@return true if zone found false if not
*/
*/
CreateNative("Zone_getMostRecentActiveZone", Native_getMostRecentActiveZone);
CreateNative("Zone_getMostRecentActiveZone", Native_getMostRecentActiveZone);

return APLRes_Success;
return APLRes_Success;
}
}


public int Native_InZone(Handle plugin, int argc) {
public int Native_InZone(Handle plugin, int argc) {
char name[64];
char name[64];
GetNativeString(2, name, 64);
GetNativeString(2, name, 64);
int client = GetNativeCell(1);
int client = GetNativeCell(1);
bool same = GetNativeCell(3);
bool same = GetNativeCell(3);
bool sensitive = GetNativeCell(4);
bool sensitive = GetNativeCell(4);

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
if (same)
if (same)
{
{
if (StrEqual(g_iZones[client][i][liName], name, sensitive) && g_iZones[client][i][liThis])
if (StrEqual(g_iZones[client][i].liName, name, sensitive) && g_iZones[client][i].liThis)
return true;
return true;
}
}
else
else
{
{
if (StrContains(g_iZones[client][i][liName], name, sensitive) == 0 && g_iZones[client][i][liThis])
if (StrContains(g_iZones[client][i].liName, name, sensitive) == 0 && g_iZones[client][i].liThis)
return true;
return true;
}
}

}
}
return false;
return false;
}
}


public int Native_getMostRecentActiveZone(Handle plugin, int argc) {
public int Native_getMostRecentActiveZone(Handle plugin, int argc) {
int client = GetNativeCell(1);
int client = GetNativeCell(1);

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
for (int i = 0; i < size; ++i) {
for (int i = 0; i < size; ++i) {
if (g_iZones[client][i][liThis]) {
if (g_iZones[client][i].liThis) {
SetNativeString(2, g_iZones[client][i][liName], 64);
SetNativeString(2, g_iZones[client][i].liName, 64);
return true;
return true;
}
}
}
}
return false;
return false;
}
}


public int Native_Teleport(Handle plugin, int argc) {
public int Native_Teleport(Handle plugin, int argc) {
char name[64];
char name[64];
char namezone[64];
char namezone[64];
float posA[3];
float posA[3];
float posB[3];
float posB[3];

GetNativeString(1, name, 64);
GetNativeString(1, name, 64);
bool sensitive = GetNativeCell(2);
bool sensitive = GetNativeCell(2);

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
if (size > 0)
if (size > 0)
{
{
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
GetTrieString(GetArrayCell(g_Zones, i), "name", namezone, 64);
GetTrieString(GetArrayCell(g_Zones, i), "name", namezone, 64);
if (StrEqual(name, namezone, sensitive))
if (StrEqual(name, namezone, sensitive))
{
{
GetTrieArray(GetArrayCell(g_Zones, i), "corda", posA, sizeof(posA));
GetTrieArray(GetArrayCell(g_Zones, i), "corda", posA, sizeof(posA));
GetTrieArray(GetArrayCell(g_Zones, i), "cordb", posB, sizeof(posB));
GetTrieArray(GetArrayCell(g_Zones, i), "cordb", posB, sizeof(posB));
float ZonePos[3];
float ZonePos[3];
AddVectors(posA, posB, ZonePos);
AddVectors(posA, posB, ZonePos);
ZonePos[0] = FloatDiv(ZonePos[0], 2.0);
ZonePos[0] = ZonePos[0]/2.0;
ZonePos[1] = FloatDiv(ZonePos[1], 2.0);
ZonePos[1] = ZonePos[1]/2.0;
ZonePos[2] = FloatDiv(ZonePos[2], 2.0);
ZonePos[2] = ZonePos[2]/2.0;
SetNativeArray(3, ZonePos, 3);
SetNativeArray(3, ZonePos, 3);
return true;
return true;
}
}
}
}
}
}
return false;
return false;
}
}


public int Native_ZoneExist(Handle plugin, int argc) {
public int Native_ZoneExist(Handle plugin, int argc) {
char name[64];
char name[64];
char namezone[64];
char namezone[64];

GetNativeString(1, name, 64);
GetNativeString(1, name, 64);
bool same = GetNativeCell(2);
bool same = GetNativeCell(2);
bool sensitive = GetNativeCell(3);
bool sensitive = GetNativeCell(3);

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
if (size > 0)
if (size > 0)
{
{
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
GetTrieString(GetArrayCell(g_Zones, i), "name", namezone, 64);
GetTrieString(GetArrayCell(g_Zones, i), "name", namezone, 64);
if (same)if (StrEqual(name, namezone, sensitive))return true;
if (same)if (StrEqual(name, namezone, sensitive))return true;
else if (StrContains(name, namezone, sensitive) == 0)return true;
else if (StrContains(name, namezone, sensitive) == 0)return true;
}
}
}
}
return false;
return false;
}
}


public int Native_isPositionInZone(Handle plugin, int numParams) {
public int Native_isPositionInZone(Handle plugin, int numParams) {
char zonename[64];
char zonename[64];
float pos[3];
float pos[3];
GetNativeString(1, zonename, 64);
GetNativeString(1, zonename, 64);
pos[0] = view_as<float>(GetNativeCell(2));
pos[0] = view_as<float>(GetNativeCell(2));
pos[1] = view_as<float>(GetNativeCell(3));
pos[1] = view_as<float>(GetNativeCell(3));
pos[2] = view_as<float>(GetNativeCell(4));
pos[2] = view_as<float>(GetNativeCell(4));

int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
if (size > 0) {
if (size > 0) {
for (int i = 0; i < size; ++i) {
for (int i = 0; i < size; ++i) {
char name[64];
char name[64];
GetTrieString(GetArrayCell(g_Zones, i), "name", name, sizeof(name));
GetTrieString(GetArrayCell(g_Zones, i), "name", name, sizeof(name));
if (StrEqual(name, zonename)) {
if (StrEqual(name, zonename)) {
float posA[3];
float posA[3];
float posB[3];
float posB[3];
GetTrieArray(GetArrayCell(g_Zones, i), "corda", posA, sizeof(posA));
GetTrieArray(GetArrayCell(g_Zones, i), "corda", posA, sizeof(posA));
GetTrieArray(GetArrayCell(g_Zones, i), "cordb", posB, sizeof(posB));
GetTrieArray(GetArrayCell(g_Zones, i), "cordb", posB, sizeof(posB));
return IsbetweenRect(pos, posA, posB, 0);
return IsbetweenRect(pos, posA, posB, 0);
}
}
}
}
}
}
return 0;
return 0;
}
}


public void DrawBeamBox(int client) {
public void DrawBeamBox(int client) {
int zColor[4];
int zColor[4];
getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 1.0, 5.0, 5.0, 2, 1.0, zColor, 0);
TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 1.0, 5.0, 5.0, 2, 1.0, zColor, 0);
CreateTimer(1.0, BeamBox, client, TIMER_REPEAT);
CreateTimer(1.0, BeamBox, client, TIMER_REPEAT);
}
}


public Action BeamBox(Handle timer, any client) {
public Action BeamBox(Handle timer, any client) {
if (IsClientInGame(client))
if (IsClientInGame(client))
{
{
if (g_Editing[client] == 2)
if (g_Editing[client] == 2)
{
{
int zColor[4];
int zColor[4];
getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 1.0, 5.0, 5.0, 2, 1.0, zColor, 0);
TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 1.0, 5.0, 5.0, 2, 1.0, zColor, 0);
return Plugin_Continue;
return Plugin_Continue;
}
}
}
}
return Plugin_Stop;
return Plugin_Stop;
}
}


public Action BeamBoxAll(Handle timer, any data) {
public Action BeamBoxAll(Handle timer, any data) {
int size = GetArraySize(g_Zones);
int size = GetArraySize(g_Zones);
float posA[3];
float posA[3];
float posB[3];
float posB[3];
int zColor[4];
int zColor[4];
int Team;
int Team;
int Vis;
int Vis;
char nombre[64];
char nombre[64];
for (int i = 0; i < size; ++i)
for (int i = 0; i < size; ++i)
{
{
Handle trie = GetArrayCell(g_Zones, i);
Handle trie = GetArrayCell(g_Zones, i);
GetTrieArray(trie, "corda", posA, sizeof(posA));
GetTrieArray(trie, "corda", posA, sizeof(posA));
GetTrieArray(trie, "cordb", posB, sizeof(posB));
GetTrieArray(trie, "cordb", posB, sizeof(posB));
GetTrieValue(trie, "team", Team);
GetTrieValue(trie, "team", Team);
GetTrieValue(trie, "vis", Vis);
GetTrieValue(trie, "vis", Vis);
GetTrieString(trie, "name", nombre, 64);
GetTrieString(trie, "name", nombre, 64);
//CloseHandle(trie);
//CloseHandle(trie);
for (int p = 1; p <= MaxClients; p++)
for (int p = 1; p <= MaxClients; p++)
{
{
if (IsClientInGame(p))
if (IsClientInGame(p))
{
{
if (g_ClientSelectedZone[p] != i && (Vis == 1 || GetClientTeam(p) == Vis)) {
if (g_ClientSelectedZone[p] != i && (Vis == 1 || GetClientTeam(p) == Vis)) {
getZoneTeamColor(Team, zColor);
getZoneTeamColor(Team, zColor);
TE_SendBeamBoxToClient(p, posA, posB, g_BeamSprite, g_HaloSprite, 0, 30, checker, 5.0, 5.0, 2, 1.0, zColor, 0);
TE_SendBeamBoxToClient(p, posA, posB, g_BeamSprite, g_HaloSprite, 0, 30, checker, 5.0, 5.0, 2, 1.0, zColor, 0);
}
}

if (mode_plugin)continue;
if (mode_plugin)continue;

if (IsPlayerAlive(p))
if (IsPlayerAlive(p))
{
{
if (IsbetweenRect(NULL_VECTOR, posA, posB, p))
if (IsbetweenRect(NULL_VECTOR, posA, posB, p))
{
{
if (!g_iZones[p][i][liThis])
if (!g_iZones[p][i].liThis)
{
{
// entra
// entra
g_iZones[p][i][liThis] = true;
g_iZones[p][i].liThis = true;
Format(g_iZones[p][i][liName], 64, nombre);
Format(g_iZones[p][i].liName, 64, nombre);
Call_StartForward(hOnClientEntry);
Call_StartForward(hOnClientEntry);
Call_PushCell(p);
Call_PushCell(p);
Call_PushString(g_iZones[p][i][liName]);
Call_PushString(g_iZones[p][i].liName);
Call_Finish();
Call_Finish();
}
}
}
}
else
else
{
{
if (g_iZones[p][i][liThis])
if (g_iZones[p][i].liThis)
{
{
// sale
// sale
g_iZones[p][i][liThis] = false;
g_iZones[p][i].liThis = false;
Format(g_iZones[p][i][liName], 64, nombre);
Format(g_iZones[p][i].liName, 64, nombre);
Call_StartForward(hOnClientLeave);
Call_StartForward(hOnClientLeave);
Call_PushCell(p);
Call_PushCell(p);
Call_PushString(g_iZones[p][i][liName]);
Call_PushString(g_iZones[p][i].liName);
Call_Finish();
Call_Finish();
}
}
}
}
}
}
}
}
}
}
}
}
return Plugin_Continue;
return Plugin_Continue;
}
}


public void BeamBox_OnPlayerRunCmd(int client) {
public void BeamBox_OnPlayerRunCmd(int client) {
if (g_Editing[client] == 1 || g_Editing[client] == 3)
if (g_Editing[client] == 1 || g_Editing[client] == 3)
{
{
float pos[3];
float pos[3];
float ang[3];
float ang[3];
int zColor[4];
int zColor[4];
getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
if (g_Editing[client] == 1)
if (g_Editing[client] == 1)
{
{
GetClientEyePosition(client, pos);
GetClientEyePosition(client, pos);
GetClientEyeAngles(client, ang);
GetClientEyeAngles(client, ang);
TR_TraceRayFilter(pos, ang, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitSelf, client);
TR_TraceRayFilter(pos, ang, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitSelf, client);
TR_GetEndPosition(g_Positions[client][1]);
TR_GetEndPosition(g_Positions[client][1]);
}
}
TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 0.1, 5.0, 5.0, 2, 1.0, zColor, 0);
TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 0.1, 5.0, 5.0, 2, 1.0, zColor, 0);
}
}
}
}


stock void TE_SendBeamBoxToClient(int client, float uppercorner[3], const float bottomcorner[3], int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, float Width, float EndWidth, int FadeLength, float Amplitude, const int Color[4], int Speed) {
stock void TE_SendBeamBoxToClient(int client, float uppercorner[3], const float bottomcorner[3], int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, float Width, float EndWidth, int FadeLength, float Amplitude, const int Color[4], int Speed) {
// Create the additional corners of the box
// Create the additional corners of the box
float tc1[3];
float tc1[3];
AddVectors(tc1, uppercorner, tc1);
AddVectors(tc1, uppercorner, tc1);
tc1[0] = bottomcorner[0];
tc1[0] = bottomcorner[0];

float tc2[3];
float tc2[3];
AddVectors(tc2, uppercorner, tc2);
AddVectors(tc2, uppercorner, tc2);
tc2[1] = bottomcorner[1];
tc2[1] = bottomcorner[1];

float tc3[3];
float tc3[3];
AddVectors(tc3, uppercorner, tc3);
AddVectors(tc3, uppercorner, tc3);
tc3[2] = bottomcorner[2];
tc3[2] = bottomcorner[2];

float tc4[3];
float tc4[3];
AddVectors(tc4, bottomcorner, tc4);
AddVectors(tc4, bottomcorner, tc4);
tc4[0] = uppercorner[0];
tc4[0] = uppercorner[0];

float tc5[3];
float tc5[3];
AddVectors(tc5, bottomcorner, tc5);
AddVectors(tc5, bottomcorner, tc5);
tc5[1] = uppercorner[1];
tc5[1] = uppercorner[1];

float tc6[3];
float tc6[3];
AddVectors(tc6, bottomcorner, tc6);
AddVectors(tc6, bottomcorner, tc6);
tc6[2] = uppercorner[2];
tc6[2] = uppercorner[2];

// Draw all the edges
// Draw all the edges
TE_SetupBeamPoints(uppercorner, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(uppercorner, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(uppercorner, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(uppercorner, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(uppercorner, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(uppercorner, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc6, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc6, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc6, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc6, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc6, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc6, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc4, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc4, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc5, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc5, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc5, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc5, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc5, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc5, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc4, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc4, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);
TE_SetupBeamPoints(tc4, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SetupBeamPoints(tc4, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToClient(client);
TE_SendToClient(client);

}
}


public bool IsbetweenRect(float Pos[3], float Corner1[3], float Corner2[3], int client)
public bool IsbetweenRect(float Pos[3], float Corner1[3], float Corner2[3], int client)
{
{
float Entity[3];
float Entity[3];
float field1[2];
float field1[2];
float field2[2];
float field2[2];
float field3[2];
float field3[2];

if (!client)
if (!client)
{
{
Entity = Pos;
Entity = Pos;
}
}
else
else
GetClientAbsOrigin(client, Entity);
GetClientAbsOrigin(client, Entity);

Entity[2] = FloatAdd(Entity[2], 25.0);
Entity[2] = Entity[2]+25.0;

// Sort Floats...
// Sort Floats...
if (FloatCompare(Corner1[0], Corner2[0]) == -1)
if (FloatCompare(Corner1[0], Corner2[0]) == -1)
{
{
field1[0] = Corner1[0];
field1[0] = Corner1[0];
field1[1] = Corner2[0];
field1[1] = Corner2[0];
}
}
else
else
{
{
field1[0] = Corner2[0];
field1[0] = Corner2[0];
field1[1] = Corner1[0];
field1[1] = Corner1[0];
}
}
if (FloatCompare(Corner1[1], Corner2[1]) == -1)
if (FloatCompare(Corner1[1], Corner2[1]) == -1)
{
{
field2[0] = Corner1[1];
field2[0] = Corner1[1];
field2[1] = Corner2[1];
field2[1] = Corner2[1];
}
}
else
else
{
{
field2[0] = Corner2[1];
field2[0] = Corner2[1];
field2[1] = Corner1[1];
field2[1] = Corner1[1];
}
}
if (FloatCompare(Corner1[2], Corner2[2]) == -1)
if (FloatCompare(Corner1[2], Corner2[2]) == -1)
{
{
field3[0] = Corner1[2];
field3[0] = Corner1[2];
field3[1] = Corner2[2];
field3[1] = Corner2[2];
}
}
else
else
{
{
field3[0] = Corner2[2];
field3[0] = Corner2[2];
field3[1] = Corner1[2];
field3[1] = Corner1[2];
}
}

// Check the Vectors ...
// Check the Vectors ...

if (Entity[0] < field1[0] || Entity[0] > field1[1])
if (Entity[0] < field1[0] || Entity[0] > field1[1])
{
{
//PrintToChat(client, "first");
//PrintToChat(client, "first");
return false;
return false;
}
}
if (Entity[1] < field2[0] || Entity[1] > field2[1])
if (Entity[1] < field2[0] || Entity[1] > field2[1])
{
{
//PrintToChat(client, "second");
//PrintToChat(client, "second");
return false;
return false;
}
}
if (Entity[2] < field3[0] || Entity[2] > field3[1])
if (Entity[2] < field3[0] || Entity[2] > field3[1])
{
{
//PrintToChat(client, "third");
//PrintToChat(client, "third");
return false;
return false;
}
}

return true;
return true;
}
}


// menus.sp
// menus.sp


public void ZoneMenu(int client)
public void ZoneMenu(int client)
{
{
g_ClientSelectedZone[client] = -1;
g_ClientSelectedZone[client] = -1;
g_Editing[client] = 0;
g_Editing[client] = 0;
Handle Menu2 = CreateMenu(Handle_ZoneMenu);
Handle Menu2 = CreateMenu(Handle_ZoneMenu);
SetMenuTitle(Menu2, "Zones");
SetMenuTitle(Menu2, "Zones");
AddMenuItem(Menu2, "", "Create Zone");
AddMenuItem(Menu2, "", "Create Zone");
AddMenuItem(Menu2, "", "Edit Zones");
AddMenuItem(Menu2, "", "Edit Zones");
AddMenuItem(Menu2, "", "Save Zones");
AddMenuItem(Menu2, "", "Save Zones");
AddMenuItem(Menu2, "", "Reload Zones");
AddMenuItem(Menu2, "", "Reload Zones");
AddMenuItem(Menu2, "", "Clear Zones");
AddMenuItem(Menu2, "", "Clear Zones");
SetMenuExitBackButton(Menu2, true);
SetMenuExitBackButton(Menu2, true);
DisplayMenu(Menu2, client, MENU_TIME_FOREVER);
DisplayMenu(Menu2, client, MENU_TIME_FOREVER);
}
}


public int Handle_ZoneMenu(Handle tMenu, MenuAction action, int client, int item) {
public int Handle_ZoneMenu(Handle tMenu, MenuAction action, int client, int item) {
switch (action)
switch (action)
{
{
case MenuAction_Select:
case MenuAction_Select:
{
{
switch (item)
switch (item)
{
{
case 0:
case 0:
{
{
EditorMenu(client);
EditorMenu(client);
}
}
case 1:
case 1:
{
{
ListZones(client, MenuHandler_ZoneModify);
ListZones(client, MenuHandler_ZoneModify);
}
}
case 2:
case 2:
{
{
SaveZones(client);
SaveZones(client);
ZoneMenu(client);
ZoneMenu(client);
}
}
case 3:
case 3:
{
{
ReadZones();
ReadZones();
PrintToChat(client, "Zones are reloaded");
PrintToChat(client, "Zones are reloaded");
ZoneMenu(client);
ZoneMenu(client);
}
}
case 4:
case 4:
{
{
ClearZonesMenu(client);
ClearZonesMenu(client);
}
}
}
}
}
}
case MenuAction_End:
case MenuAction_End:
{
{
CloseHandle(tMenu);
CloseHandle(tMenu);
}
}
}
}
}
}


public void ListZones(int client, MenuHandler handler)
public void ListZones(int c
{
Handle Menu2 = CreateMenu(handler);
SetMenuTitle(Menu2, "Avaliable Zones");
char ZoneName[256];
char ZoneId[64];
char Id[64];
int TeamId;
int size = GetArraySize(g_Zones);
if (size > 0)
{
for (int i = 0; i < size; ++i)
{
GetTrieValue(GetArrayCell(g_Zones, i), "team", TeamId);
GetTrieString(GetArrayCell(g_Zones, i), "name", ZoneId, 64);
IntToString(i, Id, sizeof(Id));
Format(ZoneName, sizeof(ZoneName), ZoneId);
AddMenuItem(Menu2, Id, ZoneId);
}
} else {
AddMenuItem(Menu2, "", "No zones are avaliable", ITEMDRAW_DISABLED);
}
SetMen