Supporting playertargeters

Supporting player targeters is easy:

in the function testsecond:

first we define empty array of CBasePlayers to hold targets

then we do a if with the gettargetplayers command

after that we define a empty CBasePlayer and start looping thru the array, even if your command only allows targeting one player its good practice to loop thru them or use pTargets[0]

we assign the empty CBasePlayer one player from the array and now you can use the CBasePlayer as normal


GetTargetPlayers explained:


first parameter is usually AFArgs.User, this is passed to the function so that in case it errors, the user will see the message


second parameter is your print target, usually you would use HUD_PRINTCONSOLE or HUD_PRINTTALK here


third parameter is your "search" string, usually this is one of the arguments in the command


fourth parameter is the flags, leave it at 0 if you dont want any filtering or use one of the PlayerTargeters enums, you can assign multiple filtering enums by using the "|" character

examples: 0, TARGETS_NOALL, TARGETS_NOAIM|TARGETS_NORANDOM


fifth parameter is the array the function spews targets to