View Single Post
Peter Brev
Member
Join Date: Aug 2023
Old 04-29-2024 , 05:02   Re: Apply cvars for a single client or flag
Reply With Quote #2

I don't have a CSS server to test this, but try the following.

At the top of the file, add the following global variables:
PHP Code:
bool    g_bRadiusPlayer[MAXPLAYERS 1];
float     g_fFreezeOverride[MAXPLAYERS 1]; 
Those will be used as our override value whenever a player gets frozen.

In the OnPluginStart section, under all the CreateConVar stuff, add:
PHP Code:
RegAdminCmd("hns_freeze_radius_player"hns_freeze_playerADMFLAG_ROOT"Override the freeze radius of a player"); 
This adds an admin command with root privileges to set a custom freeze radius to a player.

Add the following block of code somewhere:
PHP Code:
Action hns_freeze_player(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"[HNS] Usage: hns_freeze_radius_player <name|#userid> <radius>");
        return 
Plugin_Handled;
    }

    
char arg1[MAX_NAME_LENGTH];
    
char arg2[12];

    
GetCmdArg(1arg1sizeof(arg1));
    
GetCmdArg(2arg2sizeof(arg2));

    
int Target FindTarget(clientarg1truefalse);

    if (
Target == -1)
        return 
Plugin_Handled;

    
int arg2int StringToFloat(arg2);

    if (
arg2int 0)
    {
        
ReplyToCommand(client"[HNS] Invalid radius amount.");
        return 
Plugin_Handled;
    }

    if (
arg2int != GetConVarFloat(g_hFreezeRadius))
    {
        
g_bRadiusPlayer[client]      = true;
        
g_fFreezeOverride[client] = arg2int;

        
ReplyToCommand(client"[HNS] Freeze radius set to %d for %N."arg2intTarget);
    }

    else
    {
        
g_bRadiusPlayer[client]      = false;
        
ReplyToCommand(client"[HNS] Value %d is already the global freeze radius value.");
        return 
Plugin_Handled;
    }

    return 
Plugin_Handled;

This is the function of our new admin command.

Finally, find the following line (around the 1100):

PHP Code:
if (GetVectorDistance(faDecoyCoordtargetCoord) <= g_fFreezeRadius)
                        
Freeze(iClientg_fFreezeDurationFROSTNADEiThrower); 
Replace with:
PHP Code:
if (g_bRadiusPlayer[iClient] && GetVectorDistance(faDecoyCoordtargetCoord) <= g_fFreezeOverride[iClient])
                        
Freeze(iClientg_fFreezeDurationFROSTNADEiThrower);
                    else if (
GetVectorDistance(faDecoyCoordtargetCoord) <= g_fFreezeRadius)
                        
Freeze(iClientg_fFreezeDurationFROSTNADEiThrower); 
Again, this is untested. It may very need some tweaking. Try it and see what happens.

Last edited by Peter Brev; 04-29-2024 at 05:08.
Peter Brev is offline