Created
November 28, 2016 19:06
-
-
Save fakuivan/16c4a0fc9bef658adc77299943c12a2c to your computer and use it in GitHub Desktop.
A function that greatly simplifies the use of a target filter on sourcemod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if defined _ui_common_included | |
#endinput | |
#endif | |
#define _ui_common_included | |
typedef ActOnTarget = function void (int i_admin, int i_target, any a_data); | |
stock int Simplified_ProcessTargets(int i_admin, char[] s_target, ActOnTarget f_action, char[] s_format, char[] s_ml_phrase, char[] s_phrase, a_data, int i_flags = 0) | |
{ | |
char s_target_name[MAX_TARGET_LENGTH]; | |
int i_target_list[MAXPLAYERS], i_target_count; | |
bool b_tn_is_ml; | |
if ((i_target_count = ProcessTargetString( | |
s_target, | |
i_admin, | |
i_target_list, | |
sizeof(i_target_list), | |
i_flags, | |
s_target_name, | |
sizeof(s_target_name), | |
b_tn_is_ml)) <= 0) | |
{ | |
ReplyToTargetError(i_admin, i_target_count); | |
return i_target_count; | |
} | |
for (int i = 0; i < i_target_count; i++) | |
{ | |
Call_StartFunction(INVALID_HANDLE, f_action); | |
Call_PushCell(i_admin); | |
Call_PushCell(i_target_list[i]); | |
Call_PushCell(a_data); | |
Call_Finish(); | |
} | |
if (b_tn_is_ml) | |
{ | |
ReplyToCommand(i_admin, s_format, s_ml_phrase, s_target_name); | |
} | |
else | |
{ | |
ReplyToCommand(i_admin, s_format, s_phrase, s_target_name); | |
} | |
return i_target_count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment