Skip to content

Commit

Permalink
Release 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dronelektron committed Jul 2, 2022
2 parents faa375f + 0297a29 commit ce1dbd4
Show file tree
Hide file tree
Showing 23 changed files with 530 additions and 312 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
PLUGIN_NAME="respawn-unlocker"

cd scripting
spcomp $PLUGIN_NAME.sp modules/*.sp -i include -o ../plugins/$PLUGIN_NAME.smx
spcomp $PLUGIN_NAME.sp -i include -o ../plugins/$PLUGIN_NAME.smx
8 changes: 0 additions & 8 deletions scripting/include/crate-editor.inc

This file was deleted.

24 changes: 0 additions & 24 deletions scripting/include/crate-storage.inc

This file was deleted.

6 changes: 6 additions & 0 deletions scripting/include/ru/crate-editor.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#if defined _ru_crate_editor_included
#endinput
#endif
#define _ru_crate_editor_included

#define CRATE_NOT_FOUND -1
17 changes: 17 additions & 0 deletions scripting/include/ru/crate-storage.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#if defined _ru_crate_storage_included
#endinput
#endif
#define _ru_crate_storage_included

#define MAP_NAME_MAX_LENGTH 256
#define CRATE_ID_MAX_LENGTH 256
#define KV_KEY_POSITION "position"

enum {
X = 0,
Y,
Z,
VECTOR_SIZE
};

typedef KeyValuesCallback = function void (KeyValues kv);
9 changes: 9 additions & 0 deletions scripting/include/ru/entity.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if defined _ru_entity_included
#endinput
#endif
#define _ru_entity_included

#define ENTITY_NOT_FOUND -1

#define COLLISION_GROUP_IN_VEHICLE 10
#define COLLISION_GROUP "m_CollisionGroup"
15 changes: 15 additions & 0 deletions scripting/include/ru/menu.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#if defined _ru_menu_included
#endinput
#endif
#define _ru_menu_included

#define RESPAWN_UNLOCKER "Respawn unlocker"

#define ITEM_EDITOR_ENABLE "Enable editor"
#define ITEM_EDITOR_DISABLE "Disable editor"
#define ITEM_EDITOR_CRATE_ADD "Add crate"
#define ITEM_EDITOR_CRATE_REMOVE "Remove crate"
#define ITEM_CRATES_LOAD "Load crates"
#define ITEM_CRATES_SAVE "Save crates"

#define ADMIN_MENU "adminmenu"
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#if defined _message_included
#if defined _ru_message_included
#endinput
#endif
#define _message_included
#define _ru_message_included

#define PREFIX "[Respawn unlocker] "
#define PREFIX_COLORED "{fuchsia}[Respawn unlocker] "

#define NO_CLIENT -1
#define CONSOLE 0
13 changes: 0 additions & 13 deletions scripting/include/wall.inc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
void CreateConCmds() {
void Command_Create() {
RegAdminCmd("sm_respawnunlocker_crates_load", Command_LoadCrates, ADMFLAG_GENERIC);
RegAdminCmd("sm_respawnunlocker_crates_save", Command_SaveCrates, ADMFLAG_GENERIC);
RegAdminCmd("sm_respawnunlocker_editor_enable", Command_EnableEditor, ADMFLAG_GENERIC);
Expand All @@ -8,54 +8,37 @@ void CreateConCmds() {
}

public Action Command_LoadCrates(int client, int args) {
ApplyToKeyValues(LoadCratesFromFile);
ReplyCratesLoaded(client);
LogCratesLoaded(client);
UseCase_LoadCrates(client);

return Plugin_Handled;
}

public Action Command_SaveCrates(int client, int args) {
ApplyToKeyValues(SaveCratesToFile);
ReplyCratesSaved(client);
LogCratesSaved(client);
UseCase_SaveCrates(client);

return Plugin_Handled;
}

public Action Command_EnableEditor(int client, int args) {
SpawnEditorCrates();
ReplyCratesEditorEnabled(client);
LogCratesEditorEnabled(client);
UseCase_EnableEditor(client);

return Plugin_Handled;
}

public Action Command_DisableEditor(int client, int args) {
DestroyEditorCrates();
ReplyCratesEditorDisabled(client);
LogCratesEditorDisabled(client);
UseCase_DisableEditor(client);

return Plugin_Handled;
}

public Action Command_AddCrate(int client, int args) {
float cratePosition[VECTOR_SIZE];

AddCrate(client, cratePosition);
ReplyCrateAdded(client, cratePosition);
LogCrateAdded(client, cratePosition);
UseCase_AddCrate(client);

return Plugin_Handled;
}

public Action Command_RemoveCrate(int client, int args) {
float cratePosition[VECTOR_SIZE];

if (RemoveCrate(client, cratePosition)) {
ReplyCrateRemoved(client, cratePosition);
LogCrateRemoved(client, cratePosition);
}
UseCase_RemoveCrate(client);

return Plugin_Handled;
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
ConVar g_wallsEnabled = null;
ConVar g_cratesEnabled = null;
ConVar g_notificationsEnabled = null;
static ConVar g_wallsEnabled = null;
static ConVar g_cratesEnabled = null;
static ConVar g_notificationsEnabled = null;

void CreateConVars() {
void Variable_Create() {
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() {
bool Variable_IsWallsEnabled() {
return g_wallsEnabled.IntValue == 1;
}

bool IsCratesEnabled() {
bool Variable_IsCratesEnabled() {
return g_cratesEnabled.IntValue == 1;
}

bool IsNotificationsEnabled() {
bool Variable_IsNotificationsEnabled() {
return g_notificationsEnabled.IntValue == 1;
}
50 changes: 24 additions & 26 deletions scripting/modules/crate-editor.sp
Original file line number Diff line number Diff line change
@@ -1,72 +1,70 @@
void CreateEditorCrateList() {
static ArrayList g_editorCrateEntities = null;

void CrateEditor_Create() {
g_editorCrateEntities = new ArrayList();
}

void DestroyEditorCrateList() {
void CrateEditor_Destroy() {
delete g_editorCrateEntities;
}

void ClearEditorCrateList() {
void CrateEditor_Clear() {
g_editorCrateEntities.Clear();
}

void SpawnEditorCrates() {
DestroyEditorCrates();
void CrateEditor_SpawnCrates() {
CrateEditor_DestroyCrates();

float cratePosition[VECTOR_SIZE];

for (int i = 0; i < g_cratePositions.Length; i++) {
g_cratePositions.GetArray(i, cratePosition);
for (int i = 0; i < CrateList_Size(); i++) {
CrateList_Get(i, cratePosition);

int crate = SpawnCrate(cratePosition);
int crate = Entity_SpawnCrate(cratePosition);

g_editorCrateEntities.Push(crate);
}
}

void DestroyEditorCrates() {
void CrateEditor_DestroyCrates() {
for (int i = 0; i < g_editorCrateEntities.Length; i++) {
int crate = g_editorCrateEntities.Get(i);

DestroyCrate(crate);
RemoveEntity(crate);
}

g_editorCrateEntities.Clear();
}

void DestroyCrate(int crate) {
AcceptEntityInput(crate, "Kill");
}
void CrateEditor_AddCrate(int client) {
float cratePosition[VECTOR_SIZE];

void AddCrate(int client, float cratePosition[VECTOR_SIZE]) {
TracePosition(client, cratePosition);
CrateEditor_TracePosition(client, cratePosition);

int crate = SpawnCrate(cratePosition);
int crate = Entity_SpawnCrate(cratePosition);

g_cratePositions.PushArray(cratePosition);
CrateList_Add(cratePosition);
g_editorCrateEntities.Push(crate);
}

bool RemoveCrate(int client, float cratePosition[VECTOR_SIZE]) {
int crate = TraceCrate(client);
bool CrateEditor_RemoveCrate(int client) {
int crate = CrateEditor_TraceCrate(client);
int crateIndex = g_editorCrateEntities.FindValue(crate);

if (crateIndex == CRATE_NOT_FOUND) {
ReplyCrateNotFound(client);
MessageReply_CrateNotFound(client);

return false;
}

DestroyCrate(crate);

g_cratePositions.GetArray(crateIndex, cratePosition);
g_cratePositions.Erase(crateIndex);
RemoveEntity(crate);
CrateList_Remove(crateIndex);
g_editorCrateEntities.Erase(crateIndex);

return true;
}

void TracePosition(int client, float position[VECTOR_SIZE]) {
void CrateEditor_TracePosition(int client, float position[VECTOR_SIZE]) {
float eyesPosition[VECTOR_SIZE];
float eyesAngles[VECTOR_SIZE];

Expand All @@ -79,7 +77,7 @@ void TracePosition(int client, float position[VECTOR_SIZE]) {
CloseHandle(trace);
}

int TraceCrate(int client) {
int CrateEditor_TraceCrate(int client) {
float eyesPosition[3];
float eyesAngles[3];

Expand Down
29 changes: 29 additions & 0 deletions scripting/modules/crate-list.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
static ArrayList g_cratePositions = null;

void CrateList_Create() {
g_cratePositions = new ArrayList(VECTOR_SIZE);
}

void CrateList_Destroy() {
delete g_cratePositions;
}

void CrateList_Clear() {
g_cratePositions.Clear();
}

int CrateList_Size() {
return g_cratePositions.Length;
}

void CrateList_Get(int index, float position[VECTOR_SIZE]) {
g_cratePositions.GetArray(index, position);
}

void CrateList_Add(float position[VECTOR_SIZE]) {
g_cratePositions.PushArray(position);
}

void CrateList_Remove(int index) {
g_cratePositions.Erase(index);
}
Loading

0 comments on commit ce1dbd4

Please sign in to comment.