Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/scripting/include/sourcepunish.inc b/scripting/include/sourcepunish.inc
- index 7a00511..65d6dff 100644
- --- a/scripting/include/sourcepunish.inc
- +++ b/scripting/include/sourcepunish.inc
- @@ -23,6 +23,7 @@ native Handle:GetRegisteredPunishmentTypeStrings();
- native GetPunishmentTypeDisplayName(String:type[], String:buffer[], maxlen);
- native GetPunishmentTypeFlags(String:type[]);
- native GetPunishmentTypeAdminFlag(String:type[]);
- +native Handle:FindDisconnectedSteamIDFromName(String:target[], String:buffer[], maxlen);
- #define SP_SUCCESS 1
- #define SP_ERROR_TARGET_ALREADY_PUNISHED 2
- diff --git a/scripting/sourceirc-sourcepunish.sp b/scripting/sourceirc-sourcepunish.sp
- index 0e7906a..b346c8e 100644
- --- a/scripting/sourceirc-sourcepunish.sp
- +++ b/scripting/sourceirc-sourcepunish.sp
- @@ -195,9 +195,19 @@ public Action:IRCCommand_Punish(String:nick[], args) {
- sizeof(target_name),
- tn_is_ml
- )) <= 0) {
- - // Reply to the admin with a failure message
- - IRC_ReplyToTargetError(nick, target_count);
- - return Plugin_Handled;
- + decl String:disconnectedAuth[64];
- + FindDisconnectedSteamIDFromName(target, disconnectedAuth, sizeof(disconnectedAuth));
- + if (StrEqual(disconnectedAuth, "")) {
- + IRC_ReplyToTargetError(nick, target_count); // Reply to the admin with a failure message
- + return Plugin_Handled;
- + } else {
- + if (commandType == 0) {
- + commandType = 2;
- + } else if (commandType == 1) {
- + commandType = 3;
- + }
- + strcopy(target, sizeof(target), disconnectedAuth);
- + }
- }
- if (commandType == 0) {
- diff --git a/scripting/sourcepunish.sp b/scripting/sourcepunish.sp
- index 98a1b1a..e85070d 100644
- --- a/scripting/sourcepunish.sp
- +++ b/scripting/sourcepunish.sp
- @@ -54,6 +54,11 @@ enum punishmentType {
- Handle:pluginHandle,
- }
- +enum disconnectedPlayer {
- + String:playerName[64],
- + String:playerAuth[64],
- +}
- +
- new Handle:punishments = INVALID_HANDLE;
- new Handle:punishmentTypes = INVALID_HANDLE;
- new Handle:punishmentRemovalTimers[MAXPLAYERS + 1];
- @@ -76,6 +81,7 @@ new Handle:steamIDRegex;
- new Handle:punishmentRegisteredForward = INVALID_HANDLE;
- new Handle:punishmentPluginUnloadedForward = INVALID_HANDLE;
- new ReplySource:commandReplySources[MAXPLAYERS + 1];
- +new Handle:disconnectedPlayerCache = INVALID_HANDLE;
- public OnPluginStart() {
- decl String:error[64];
- @@ -121,6 +127,8 @@ public OnPluginStart() {
- punishmentRegisteredForward = CreateGlobalForward("PunishmentRegistered", ET_Ignore, Param_String, Param_String, Param_Cell);
- punishmentPluginUnloadedForward = CreateGlobalForward("PunishmentPluginUnloaded", ET_Ignore);
- +
- + disconnectedPlayerCache = CreateArray();
- }
- public SMCResult:SMC_KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes) {
- @@ -332,11 +340,20 @@ public Action:Command_Punish(client, args) {
- sizeof(target_name),
- tn_is_ml
- )) <= 0) {
- - // Reply to the admin with a failure message
- - ReplyToTargetError(client, target_count);
- - return Plugin_Handled;
- + decl String:disconnectedAuth[64];
- + FindDisconnectedSteamIDFromName(target, disconnectedAuth, sizeof(disconnectedAuth));
- + if (StrEqual(disconnectedAuth, "")) {
- + ReplyToTargetError(client, target_count); // Reply to the admin with a failure message
- + return Plugin_Handled;
- + } else {
- + if (commandType == 0) {
- + commandType = 2;
- + } else if (commandType == 1) {
- + commandType = 3;
- + }
- + strcopy(target, sizeof(target), disconnectedAuth);
- + }
- }
- -
- commandReplySources[client] = GetCmdReplySource();
- if (commandType == 0) {
- for (new i = 0; i < target_count; i++) {
- @@ -465,6 +482,15 @@ public OnClientDisconnect(client) {
- }
- punishmentRemovalTimers[client] = INVALID_HANDLE;
- }
- +
- + // Add the player to the disconnected list in case we want to punish them after they leave
- + decl disconnectedPlayerEnum[disconnectedPlayer];
- + GetClientName(client, disconnectedPlayerEnum[playerName], sizeof(disconnectedPlayerEnum[playerName]));
- + GetClientAuthString(client, disconnectedPlayerEnum[playerAuth], sizeof(disconnectedPlayerEnum[playerAuth]));
- + PushArrayArray(disconnectedPlayerCache, disconnectedPlayerEnum, sizeof(disconnectedPlayerEnum));
- + if (GetArraySize(disconnectedPlayerCache) > 10) { // If we've got more than 10 in the cache
- + RemoveFromArray(disconnectedPlayerCache, 0); // Remove the first so we remain at 10
- + }
- }
- public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) {
- @@ -475,6 +501,7 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
- CreateNative("GetPunishmentTypeDisplayName", Native_GetPunishmentTypeDisplayName);
- CreateNative("GetPunishmentTypeFlags", Native_GetPunishmentTypeFlags);
- CreateNative("GetPunishmentTypeAdminFlag", Native_GetPunishmentTypeAdminFlag);
- + CreateNative("FindDisconnectedSteamIDFromName", Native_FindDisconnectedSteamIDFromName);
- CreateNative("PunishClient", Native_PunishClient);
- CreateNative("PunishIdentity", Native_PunishIdentity);
- CreateNative("UnpunishClient", Native_UnpunishClient);
- @@ -1096,6 +1123,23 @@ public Native_GetPunishmentTypeAdminFlag(Handle:plugin, numParams) {
- return pmethod[adminflag];
- }
- +public Native_FindDisconnectedSteamIDFromName(Handle:plugin, numParams) {
- + decl String:target[64];
- + GetNativeString(1, target, sizeof(target));
- +
- + for (new i = 0; i < GetArraySize(disconnectedPlayerCache); i++) {
- + decl disconnectedPlayerEnum[disconnectedPlayer];
- + GetArrayArray(disconnectedPlayerCache, i, disconnectedPlayerEnum, sizeof(disconnectedPlayerEnum));
- + if (StrContains(disconnectedPlayerEnum[playerName], target)) {
- + PrintToServer(disconnectedPlayerEnum[playerName]);
- + PrintToServer(disconnectedPlayerEnum[playerAuth]);
- + SetNativeString(2, disconnectedPlayerEnum[playerAuth], GetNativeCell(3)); // Copy string into buffer (param 2). maxlen is param 3.
- + return;
- + }
- + }
- + SetNativeString(2, "", GetNativeCell(3)); // Copy blank string into buffer (param 2). maxlen is param 3.
- +}
- +
- public Native_RegisterPunishment(Handle:plugin, numParams) {
- decl String:type[64];
- GetNativeString(1, type, sizeof(type));
Advertisement
Add Comment
Please, Sign In to add comment