-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
229 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
spcomp scripting/respawn-unlocker.sp scripting/modules/*.sp -i scripting/include -o plugins/respawn-unlocker.smx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if defined _crate_included | ||
#endinput | ||
#endif | ||
#define _crate_included | ||
|
||
#define MAX_CRATES_COUNT 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#if defined _message_included | ||
#endinput | ||
#endif | ||
#define _message_included | ||
|
||
#define PREFIX "[Respawn unlocker] " | ||
#define PREFIX_COLORED "{fuchsia}[Respawn unlocker] " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#if defined _wall_included | ||
#endinput | ||
#endif | ||
#define _wall_included | ||
|
||
#define MAX_WALLS_COUNT 32 | ||
#define ENTITY_NOT_FOUND -1 | ||
#define COLLISION_GROUP_IN_VEHICLE 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
void CreateConCmds() { | ||
RegAdminCmd("sm_respawnunlocker_reload_crates", Command_ReloadCrates, ADMFLAG_GENERIC); | ||
} | ||
|
||
public Action Command_ReloadCrates(int client, int args) { | ||
LoadCrates(); | ||
ReplyToCommand(client, "%s%t", PREFIX, "Crates reloaded"); | ||
|
||
return Plugin_Handled; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
static ConVar g_wallsEnabled = null; | ||
static ConVar g_cratesEnabled = null; | ||
static ConVar g_notificationsEnabled = null; | ||
|
||
void CreateConVars() { | ||
g_wallsEnabled = CreateConVar("sm_respawnunlocker_walls", "1", "Enable (1) or disable (0) walls removing"); | ||
g_cratesEnabled = CreateConVar("sm_respawnunlocker_crates", "1", "Enable (1) or disable (0) crates adding"); | ||
g_notificationsEnabled = CreateConVar("sm_respawnunlocker_notifications", "1", "Enable (1) or disable (0) notifications"); | ||
} | ||
|
||
bool IsWallsEnabled() { | ||
return g_wallsEnabled.IntValue == 1; | ||
} | ||
|
||
bool IsCratesEnabled() { | ||
return g_cratesEnabled.IntValue == 1; | ||
} | ||
|
||
bool IsNotificationsEnabled() { | ||
return g_notificationsEnabled.IntValue == 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
static int g_cratesCount = 0; | ||
static float g_cratePositions[MAX_CRATES_COUNT][3]; | ||
|
||
void LoadCrates() { | ||
char configPath[PLATFORM_MAX_PATH]; | ||
char mapName[256]; | ||
|
||
GetCurrentMap(mapName, sizeof(mapName)); | ||
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/respawn-unlocker.txt"); | ||
|
||
if (!FileExists(configPath)) { | ||
return; | ||
} | ||
|
||
KeyValues kv = new KeyValues("Crates"); | ||
|
||
kv.ImportFromFile(configPath); | ||
g_cratesCount = 0; | ||
|
||
if (!kv.JumpToKey(mapName) || !kv.GotoFirstSubKey()) { | ||
LogMessage("No crates for this map"); | ||
|
||
delete kv; | ||
|
||
return; | ||
} | ||
|
||
do { | ||
g_cratePositions[g_cratesCount][0] = kv.GetFloat("position_x"); | ||
g_cratePositions[g_cratesCount][1] = kv.GetFloat("position_y"); | ||
g_cratePositions[g_cratesCount][2] = kv.GetFloat("position_z"); | ||
g_cratesCount++; | ||
} while (kv.GotoNextKey()); | ||
|
||
LogMessage("Loaded %d crates for this map", g_cratesCount); | ||
|
||
delete kv; | ||
} | ||
|
||
void NotifyAboutCrates() { | ||
if (g_cratesCount == 0 || !IsCratesEnabled() || !IsNotificationsEnabled()) { | ||
return; | ||
} | ||
|
||
CPrintToChatAll("%s%t", PREFIX_COLORED, "Crates created"); | ||
} | ||
|
||
void SpawnCrates() { | ||
if (!IsCratesEnabled()) { | ||
return; | ||
} | ||
|
||
for (int crateIndex = 0; crateIndex < g_cratesCount; crateIndex++) { | ||
SpawnCrate(g_cratePositions[crateIndex]); | ||
} | ||
} | ||
|
||
void SpawnCrate(const float position[3]) { | ||
int crate = CreateEntityByName("prop_dynamic_override"); | ||
|
||
DispatchKeyValue(crate, "model", "models/props_junk/wood_crate001a.mdl"); | ||
DispatchKeyValue(crate, "disableshadows", "1"); | ||
DispatchKeyValue(crate, "solid", "6"); | ||
DispatchSpawn(crate); | ||
|
||
SetEntityRenderColor(crate, 255, 255, 255, 127); | ||
SetEntityRenderMode(crate, RENDER_TRANSCOLOR); | ||
|
||
float minBounds[3]; | ||
float newPosition[3]; | ||
|
||
GetEntPropVector(crate, Prop_Send, "m_vecMins", minBounds); | ||
|
||
newPosition[0] = position[0]; | ||
newPosition[1] = position[1]; | ||
newPosition[2] = position[2] - minBounds[2]; | ||
|
||
TeleportEntity(crate, newPosition, NULL_VECTOR, NULL_VECTOR); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
static char g_wallEntityClasses[][] = {"func_team_wall", "func_teamblocker"}; | ||
|
||
static int g_wallsCount = 0; | ||
static int g_wallEntities[MAX_WALLS_COUNT]; | ||
static int g_wallCollisionFlags[MAX_WALLS_COUNT]; | ||
|
||
void FindWallEntities() { | ||
int wallIndex = 0; | ||
int entity = ENTITY_NOT_FOUND; | ||
|
||
for (int classIndex = 0; classIndex < sizeof(g_wallEntityClasses); classIndex++) { | ||
while ((entity = FindEntityByClassname(entity, g_wallEntityClasses[classIndex])) != ENTITY_NOT_FOUND) { | ||
g_wallEntities[wallIndex++] = entity; | ||
} | ||
} | ||
|
||
g_wallsCount = wallIndex; | ||
} | ||
|
||
void SaveWallsCollisionFlags() { | ||
for (int wallIndex = 0; wallIndex < g_wallsCount; wallIndex++) { | ||
int entity = g_wallEntities[wallIndex]; | ||
|
||
g_wallCollisionFlags[wallIndex] = GetCollisionFlags(entity); | ||
} | ||
} | ||
|
||
void RemoveWallsCollisionFlags() { | ||
if (!IsWallsEnabled()) { | ||
return; | ||
} | ||
|
||
for (int wallIndex = 0; wallIndex < g_wallsCount; wallIndex++) { | ||
int entity = g_wallEntities[wallIndex]; | ||
|
||
SetCollisionFlags(entity, COLLISION_GROUP_IN_VEHICLE); | ||
} | ||
} | ||
|
||
void RestoreWallsCollisionFlags() { | ||
for (int wallIndex = 0; wallIndex < g_wallsCount; wallIndex++) { | ||
int entity = g_wallEntities[wallIndex]; | ||
|
||
SetCollisionFlags(entity, g_wallCollisionFlags[wallIndex]); | ||
} | ||
} | ||
|
||
int GetCollisionFlags(int entity) { | ||
return GetEntProp(entity, Prop_Send, "m_CollisionGroup"); | ||
} | ||
|
||
void SetCollisionFlags(int entity, int flags) { | ||
SetEntProp(entity, Prop_Send, "m_CollisionGroup", flags); | ||
} | ||
|
||
void NotifyAboutRespawnUnlocking() { | ||
if (g_wallsCount == 0 || !IsWallsEnabled() || !IsNotificationsEnabled()) { | ||
return; | ||
} | ||
|
||
CPrintToChatAll("%s%t", PREFIX_COLORED, "Respawn unlocked"); | ||
} |
Oops, something went wrong.