Switch to userid, add "slap"

This commit is contained in:
Jackzie 2022-11-22 09:56:17 -06:00
parent 69f7b916da
commit 54be62bfb0

View file

@ -5,6 +5,7 @@
#define PLUGIN_VERSION "1.0" #define PLUGIN_VERSION "1.0"
#define MAX_PLAYER_HISTORY 25 #define MAX_PLAYER_HISTORY 25
#define MAX_NOTES_TO_SHOW 10
#define DATABASE_CONFIG_NAME "stats" #define DATABASE_CONFIG_NAME "stats"
#include <sourcemod> #include <sourcemod>
@ -254,16 +255,14 @@ public void DB_FindNotes(Database db, DBResultSet results, const char[] error, a
if(client > 0 && results.RowCount > 0) { if(client > 0 && results.RowCount > 0) {
static char noteCreator[32]; static char noteCreator[32];
CPrintChatToAdmins("{yellow}> Notes for %N", client); CPrintChatToAdmins("{yellow}> Notes for %N", client);
// PrintChatToAdmins("> Notes for %N", client);
int actions = 0; int actions = 0;
while(results.FetchRow()) { while(results.FetchRow()) {
results.FetchString(0, reason, sizeof(reason)); results.FetchString(0, reason, sizeof(reason));
results.FetchString(1, noteCreator, sizeof(noteCreator)); results.FetchString(1, noteCreator, sizeof(noteCreator));
if(ParseActions(client, reason)) { if(ParseActions(data, reason)) {
actions++; actions++;
} else { } else {
CPrintChatToAdmins(" {olive}%s: {default}%s", noteCreator, reason); CPrintChatToAdmins(" {olive}%s: {default}%s", noteCreator, reason);
// PrintChatToAdmins("%s: %s", noteCreator, reason);
} }
} }
@ -275,7 +274,7 @@ public void DB_FindNotes(Database db, DBResultSet results, const char[] error, a
#define ACTION_DESTINATOR '!' #define ACTION_DESTINATOR '!'
#define ACTION_SEPERATOR "." #define ACTION_SEPERATOR "."
bool ParseActions(int client, const char[] input) { bool ParseActions(int userid, const char[] input) {
if(input[0] != ACTION_DESTINATOR) return false; if(input[0] != ACTION_DESTINATOR) return false;
char piece[64], key[32], value[16]; char piece[64], key[32], value[16];
@ -302,14 +301,16 @@ bool ParseActions(int client, const char[] input) {
} else { } else {
value[0] = '\0'; value[0] = '\0';
} }
ApplyAction(client, piece[1], key, value); ApplyAction(userid, piece[1], key, value);
// } while((index = SplitString(input[prevIndex], " ", piece, sizeof(piece))) != -1); // } while((index = SplitString(input[prevIndex], " ", piece, sizeof(piece))) != -1);
return true; return true;
} }
void ApplyAction(int target, const char[] action, const char[] key, const char[] value) { bool ApplyAction(int targetUserId, const char[] action, const char[] key, const char[] value) {
// If action is 'fta*' or 'ftas' // If action is 'fta*' or 'ftas'
int target = GetClientOfUserId(targetUserId);
if(target == 0) return false;
if(strncmp(action, "fta", 4) >= 0) { if(strncmp(action, "fta", 4) >= 0) {
#if defined _ftt_included_ #if defined _ftt_included_
// Replace under scores with spaces // Replace under scores with spaces
@ -320,8 +321,9 @@ void ApplyAction(int target, const char[] action, const char[] key, const char[]
ApplyTroll(target, newKey, TrollMod_Invalid, flags, 0, action[4] == 's'); ApplyTroll(target, newKey, TrollMod_Invalid, flags, 0, action[4] == 's');
#else #else
PrintToServer("[PlayerNotes] Warn: Action \"%s\" for %N has missing plugin: Feed The Trolls", action, target); PrintToServer("[PlayerNotes] Warn: Action \"%s\" for %N has missing plugin: Feed The Trolls", action, target);
return false;
#endif #endif
} else if(StrEqual(action, "ignore")) { } else if(strncmp(action, "ignore", 6) == 0) {
#if defined _tkstopper_included_ #if defined _tkstopper_included_
if(StrEqual(key, "rff")) { if(StrEqual(key, "rff")) {
SetImmunity(target, TKImmune_ReverseFriendlyFire, true); SetImmunity(target, TKImmune_ReverseFriendlyFire, true);
@ -332,10 +334,25 @@ void ApplyAction(int target, const char[] action, const char[] key, const char[]
} }
#else #else
PrintToServer("[PlayerNotes] Warn: Action \"%s\" for %N has missing plugin: TKStopper", action, target); PrintToServer("[PlayerNotes] Warn: Action \"%s\" for %N has missing plugin: TKStopper", action, target);
return false;
#endif #endif
} else if(strncmp(action, "slap", 4) == 0) {
float delay = StringToFloat(key);
CreateTimer(delay, SlapPlayer, targetUserId);
} else { } else {
PrintToServer("[PlayerNotes] Warn: Action (\"%s\") for %N is not valid", action, target); PrintToServer("[PlayerNotes] Warn: Action (\"%s\") for %N is not valid", action, target);
return false;
} }
return true;
}
Action SlapPlayer(Handle h, int userid) {
int client = GetClientOfUserId(userid);
if(client > 0) {
SlapPlayer(client, 0, true);
}
return Plugin_Handled;
} }
public void DB_ListNotesForPlayer(Database db, DBResultSet results, const char[] error, DataPack pack) { public void DB_ListNotesForPlayer(Database db, DBResultSet results, const char[] error, DataPack pack) {