Raised This Month: $ Target: $400
 0% 

Apply cvars for a single client or flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tinke
New Member
Join Date: Apr 2024
Old 04-14-2024 , 15:08   Apply cvars for a single client or flag
Reply With Quote #1

Is there a way I can apply a cvar (that usually would apply to all player), to a single player or flag (vip for example)

example:
in the hidenseek chasemod plugin: (https://forums.alliedmods.net/showthread.php?t=239132)

the radius of the freezenade is defined in hidenseek.cfg by 'hns_freeze_radius' and what I want is change this cvar for a single player/flag, is that possible? if yes, how can I do that.

obs: i have little to no sourcepawn/csgo server knowledge, so take easy on me
tinke is offline
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
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode