View Single Post
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-25-2014 , 20:43   Re: [ANY] Distance Target Filters
Reply With Quote #7

Command_SetDistance can be simplified to this:

PHP Code:
public Action:Command_SetDistance(clientargs)
{
    
decl String:arg1[5];
    
GetCmdArg(1arg1sizeof(arg1));
    
    
distance[client] = FloatAbs(StringToFloat(arg1));
    
    
ReplyToCommand(client"[SM] Set distance filter to: %f"distance[client]);
    return 
Plugin_Handled;

You can also optimize this slightly, as you know exactly where the '!' would be, if it's present.

PHP Code:
    new bool:opposite;
    if(
strPattern[1] == '!'opposite true
And this:

PHP Code:
            if(!opposite
            {    
                if(
vDistance <= distance[client]) PushArrayCell(hClientsi);
            }
            else
            {
                if(
vDistance distance[client]) PushArrayCell(hClientsi);
            } 
Can be changed to this (untested!!):

PHP Code:
            if((vDistance <= distance[client]) == !oppositePushArrayCell(hClientsi); 
__________________

Last edited by ddhoward; 03-25-2014 at 20:48.
ddhoward is offline