Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dronelektron committed Feb 24, 2022
2 parents a740da1 + 230e832 commit 0334f75
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 169 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ Allows you to perform various actions with objects at the beginning of the round

### Notes

To identify objects, their **index** is used, which can change when the number of slots on the server changes. In a future version of the plugin, it is planned to use a more secure method for identifying objects.
To identify objects, their **index** is used, which can change, when:

* The number of slots on the server changes
* Other plugins are creating/removing entities

In a future version of the plugin, it is planned to use a more secure method for identifying objects.
3 changes: 1 addition & 2 deletions scripting/entity-manager.sp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "em/menu"
#include "em/message"
#include "em/storage"
#include "em/use-case"

#include "modules/console-command.sp"
#include "modules/console-variable.sp"
Expand All @@ -24,7 +23,7 @@ public Plugin myinfo = {
name = "Entity manager",
author = "Dron-elektron",
description = "Allows you to perform various actions with objects at the beginning of the round",
version = "0.2.0",
version = "1.0.0",
url = ""
};

Expand Down
5 changes: 0 additions & 5 deletions scripting/include/em/message.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@

#define PREFIX "[Entity manager] "
#define CONSOLE 0

enum MessageType {
MessageType_Reply,
MessageType_Log
};
12 changes: 0 additions & 12 deletions scripting/include/em/use-case.inc

This file was deleted.

60 changes: 4 additions & 56 deletions scripting/modules/console-command.sp
Original file line number Diff line number Diff line change
Expand Up @@ -15,89 +15,37 @@ public Action Command_Menu(int client, int args) {
}

public Action Command_Freeze(int client, int args) {
int entity;
UseCaseResult result = UseCase_FreezeEntity(client, entity);

if (result == UseCaseResult_Success) {
Message_EntityFrozen(client, entity);
} else if (result == UseCaseResult_EntityNotFound) {
Message_EntityNotFound(client);
} else if (result == UseCaseResult_AlreadyHasAction) {
Message_EntityAlreadyHasAction(client, entity);
}
UseCase_FreezeEntity(client);

return Plugin_Handled;
}

public Action Command_Unfreeze(int client, int args) {
int entity;
UseCaseResult result = UseCase_UnfreezeEntity(client, entity);

if (result == UseCaseResult_Success) {
Message_EntityUnfrozen(client, entity);
} else if (result == UseCaseResult_EntityNotFound) {
Message_EntityNotFound(client);
} else if (result == UseCaseResult_NotFrozen) {
Message_EntityNotFrozen(client, entity);
}
UseCase_UnfreezeEntity(client);

return Plugin_Handled;
}

public Action Command_Delete(int client, int args) {
int entity;
UseCaseResult result = UseCase_DeleteEntity(client, entity);

if (result == UseCaseResult_Success) {
Message_EntityDeleted(client, entity);
} else if (result == UseCaseResult_EntityNotFound) {
Message_EntityNotFound(client);
} else if (result == UseCaseResult_AlreadyHasAction) {
Message_EntityAlreadyHasAction(client, entity);
}
UseCase_DeleteEntity(client);

return Plugin_Handled;
}

public Action Command_Restore(int client, int args) {
int entity;
UseCaseResult result = UseCase_RestoreEntity(client, entity);

if (result == UseCaseResult_Success) {
Message_EntityRestored(client, entity);
} else if (result == UseCaseResult_EntityNotFound) {
Message_EntityNotFound(client);
} else if (result == UseCaseResult_NotDeleted) {
Message_EntityNotDeleted(client, entity);
}
UseCase_RestoreEntity(client);

return Plugin_Handled;
}

public Action Command_Save(int client, int args) {
UseCase_SaveEntities(client);

int entitiesAmount = EntityList_Size();

if (entitiesAmount == 0) {
Message_ListOfEntitiesCleared(client);
} else {
Message_EntitiesSaved(client, entitiesAmount);
}

return Plugin_Handled;
}

public Action Command_Load(int client, int args) {
UseCase_LoadEntities(client);

int entitiesAmount = EntityList_Size();

if (entitiesAmount == 0) {
Message_NoEntitiesForLoading(client);
} else {
Message_EntitiesLoaded(client, entitiesAmount);
}

return Plugin_Handled;
}
9 changes: 4 additions & 5 deletions scripting/modules/menu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ void Menu_EntityManager(int client) {
public int MenuHandler_EntityManager(Menu menu, MenuAction action, int param1, int param2) {
if (action == MenuAction_Select) {
char info[MENU_TEXT_MAX_SIZE];
int entity;

menu.GetItem(param2, info, sizeof(info));

if (strcmp(info, ITEM_ENTITY_FREEZE) == 0) {
UseCase_FreezeEntity(param1, entity);
UseCase_FreezeEntity(param1);
} else if (strcmp(info, ITEM_ENTITY_UNFREEZE) == 0) {
UseCase_UnfreezeEntity(param1, entity);
UseCase_UnfreezeEntity(param1);
} else if (strcmp(info, ITEM_ENTITY_DELETE) == 0) {
UseCase_DeleteEntity(param1, entity);
UseCase_DeleteEntity(param1);
} else if (strcmp(info, ITEM_ENTITY_RESTORE) == 0) {
UseCase_RestoreEntity(param1, entity);
UseCase_RestoreEntity(param1);
} else if (strcmp(info, ITEM_ENTITIES_SAVE) == 0) {
UseCase_SaveEntities(param1);
} else if (strcmp(info, ITEM_ENTITIES_LOAD) == 0) {
Expand Down
110 changes: 58 additions & 52 deletions scripting/modules/message.sp
Original file line number Diff line number Diff line change
@@ -1,83 +1,89 @@
void Message_EntityNotFound(int client) {
void MessageReply_EntityNotFound(int client) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity not found");
}

void Message_EntityAlreadyHasAction(int client, int entity) {
void MessageReply_EntityAlreadyHasAction(int client, int entity) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity already has an action", entity);
}

void Message_EntityNotFrozen(int client, int entity) {
void MessageReply_EntityNotFrozen(int client, int entity) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity not frozen", entity);
}

void Message_EntityNotDeleted(int client, int entity) {
void MessageReply_EntityNotDeleted(int client, int entity) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity not deleted", entity);
}

void Message_EntityFrozen(int client, int entity, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity has been frozen", entity);
} else if (type == MessageType_Log) {
LogMessage("\"%L\" froze entity %d", client, entity);
}
void MessageActivity_EntityFrozen(int client, int entity) {
ShowActivity2(client, PREFIX, "%t", "Entity has been frozen", entity);
}

void Message_EntityUnfrozen(int client, int entity, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity has been unfrozen", entity);
} else if (type == MessageType_Log) {
LogMessage("\"%L\" unfroze entity %d", client, entity);
}
void MessageLog_EntityFrozen(int client, int entity) {
LogMessage("\"%L\" froze entity %d", client, entity);
}

void Message_EntityDeleted(int client, int entity, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity deleted", entity);
} else if (type == MessageType_Log) {
LogMessage("\"%L\" deleted entity %d", client, entity);
}
void MessageActivity_EntityUnfrozen(int client, int entity) {
ShowActivity2(client, PREFIX, "%t", "Entity has been unfrozen", entity);
}

void Message_EntityRestored(int client, int entity, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "Entity restored", entity);
} else if (type == MessageType_Log) {
LogMessage("\"%L\" restored entity %d", client, entity);
}
void MessageLog_EntityUnfrozen(int client, int entity) {
LogMessage("\"%L\" unfroze entity %d", client, entity);
}

void Message_ListOfEntitiesCleared(int client, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "List of entities cleared");
} else if (type == MessageType_Log) {
LogMessage("\"%L\" cleared the list of entities", client);
}
void MessageActivity_EntityDeleted(int client, int entity) {
ShowActivity2(client, PREFIX, "%t", "Entity has been deleted", entity);
}

void Message_EntitiesSaved(int client, int entitiesAmount, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "Entities saved", entitiesAmount);
} else if (type == MessageType_Log) {
LogMessage("\"%L\" saved %d entities", client, entitiesAmount);
}
void MessageLog_EntityDeleted(int client, int entity) {
LogMessage("\"%L\" deleted entity %d", client, entity);
}

void MessageActivity_EntityRestored(int client, int entity) {
ShowActivity2(client, PREFIX, "%t", "Entity has been restored", entity);
}

void MessageLog_EntityRestored(int client, int entity) {
LogMessage("\"%L\" restored entity %d", client, entity);
}

void MessageActivity_ListOfEntitiesCleared(int client) {
ShowActivity2(client, PREFIX, "%t", "List of entities cleared");
}

void Message_NoEntitiesForLoading(int client, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
void MessageLog_ListOfEntitiesCleared(int client) {
LogMessage("\"%L\" cleared the list of entities", client);
}

void MessageActivity_EntitiesSaved(int client, int entitiesAmount) {
ShowActivity2(client, PREFIX, "%t", "Entities saved", entitiesAmount);
}

void MessageLog_EntitiesSaved(int client, int entitiesAmount) {
LogMessage("\"%L\" saved %d entities", client, entitiesAmount);
}

void MessageReply_NoEntitiesForLoading(int client) {
if (client != CONSOLE) {
ReplyToCommand(client, "%s%t", PREFIX, "No entities for loading");
} else if (type == MessageType_Log && client == CONSOLE) {
}
}

void MessageLog_NoEntitiesForLoading(int client) {
if (client == CONSOLE) {
LogMessage("No entities for this map");
}
}

void Message_EntitiesLoaded(int client, int entitiesAmount, MessageType type = MessageType_Reply) {
if (type == MessageType_Reply) {
ReplyToCommand(client, "%s%t", PREFIX, "Entities loaded", entitiesAmount);
} else if (type == MessageType_Log) {
if (client == CONSOLE) {
LogMessage("Loaded %d entities", entitiesAmount);
} else {
LogMessage("\"%L\" loaded %d entities", client, entitiesAmount);
}
void MessageActivity_EntitiesLoaded(int client, int entitiesAmount) {
if (client != CONSOLE) {
ShowActivity2(client, PREFIX, "%t", "Entities loaded", entitiesAmount);
}
}

void MessageLog_EntitiesLoaded(int client, int entitiesAmount) {
if (client == CONSOLE) {
LogMessage("Loaded %d entities", entitiesAmount);
} else {
LogMessage("\"%L\" loaded %d entities", client, entitiesAmount);
}
}
Loading

0 comments on commit 0334f75

Please sign in to comment.