Browse Source

Use more elegant unpacking method

Instead of strcopy and size checks, we pull the first item out with
`SplitString` and the second by the index we get from the same
`SplitString` call.
nosoop 7 years ago
parent
commit
b523aca3ab
1 changed files with 4 additions and 4 deletions
  1. 4 4
      scripting/simple-chatprocessor.sp

+ 4 - 4
scripting/simple-chatprocessor.sp

@@ -13,7 +13,7 @@
 
 #pragma newdecls required
 
-#define PLUGIN_VERSION "0.1.2"
+#define PLUGIN_VERSION "0.1.3"
 public Plugin myinfo = {
 	name = "[CSRD] Simple Chat Processor",
 	author = "nosoop (based off of Simple Plugins' implementation)",
@@ -159,9 +159,9 @@ public void OnClientThinkPost(int author) {
 			g_QueuedMessages[author].GetValue(packedMessage, clientList);
 			
 			// unpack localization and message from key
-			strcopy(localizationToken, StrContains(packedMessage, PACKED_TOKEN_DELIMITER) + 1,
-					packedMessage);
-			strcopy(message, sizeof(message), packedMessage[strlen(localizationToken) + 1]);
+			int d = SplitString(packedMessage, PACKED_TOKEN_DELIMITER, localizationToken,
+					sizeof(localizationToken));
+			strcopy(message, sizeof(message), packedMessage[d]);
 			
 			char name[MAX_NAME_LENGTH + 1];
 			GetClientName(author, name, sizeof(name));