Currently trying to investigate some issues with FindTarget/ProcessTargetString in two plugins, one being the Timer !spec plugin, the other one selfMute (related issue
https://forums.alliedmods.net/showpo...3&postcount=18).
In both cases, if a non-admin tries to self-mute/spectate another player, they will be presented the error message "[SM] You cannot target this player".
If any admin tries to use any of those commands, it works flawlessly.
This happens with both FindTarget and ProcessTargetString (seeing how FindTarget is only a wrapper).
Digging a bit into SM's source code, I came across this:
https://github.com/alliedmodders/sou...ache.cpp#L1494 which is called from
https://github.com/alliedmodders/sou...ager.cpp#L1503.
In both cases, the pAdmin object's Adminid is always -1 (as the caller isn't an admin), thus the check in AdminCache fails and the players get a "You cannot target" error.
Now, the fourth argument for FindTarget() allows disabling the immunity checks, which I tried - but with that enabled, the target filter doesn't properly work anymore.
Example:
Player - "Do you even Bitcoin"
sm_spec do - Multiple clients matched [..]
sm_spec "do you" - No matching targets found.
sm_spec "Do you even Bitcoin" - No matching targets found.
Each of the above commands work fine for admin commands (such as sm_who).
The command in general also work without the "" if the targeted player has a unique name.
Code used:
PHP Code:
// client = argument from RegConsoleCmd callback
new String:arg1[64];
GetCmdArgString(arg1, sizeof(arg1));
new target = FindTarget(client, arg1, true, false);
if (target == -1)
{
return Plugin_Handled;
}
SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", target);
Am I (and the author of self-mute) using these functions wrong, or what could be the cause?
__________________
Stopped hosting servers as of November 2018, no longer active around here.