Raised This Month: $51 Target: $400
 12% 

Set client airaccelerate


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
farawayf
Senior Member
Join Date: Jan 2019
Old 03-17-2019 , 14:06   Set client airaccelerate
Reply With Quote #1

is it possible to set airaccelerate for a specific player, not globally ?
if yes, how ?

Last edited by farawayf; 03-17-2019 at 14:06.
farawayf is offline
Cruze
Veteran Member
Join Date: May 2017
Old 03-17-2019 , 20:44   Re: Set client airaccelerate
Reply With Quote #2

SendConVarValue
__________________
Taking paid private requests! Contact me
Cruze is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 03-18-2019 , 01:28   Re: Set client airaccelerate
Reply With Quote #3

Quote:
Originally Posted by Cruze View Post
This will just make the client think the airaccelerate is different and cause prediction errors.


This should work though:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

ConVar g_hAirAcceleration;

public 
void OnPluginStart()
{
    
g_hAirAcceleration FindConVar("sv_airaccelerate");
    
g_hAirAcceleration.Flags &= ~FCVAR_NOTIFY;
    
g_hAirAcceleration.Flags &= ~FCVAR_REPLICATED;

    
RegConsoleCmd("sm_airaccelerate"CommandRandomAirAccelerate);
}

int AirAcceleratePerClient[MAXPLAYERS+1] = {1000.0};

public 
void OnClientPutInServer(int client)
{
    if(!
IsFakeClient(client))
    {
        
SDKHook(clientSDKHook_PreThinkPostHook_PreThink);
        
        
char sAirAccelerate[16];
        
IntToString(AirAcceleratePerClient[client], sAirAcceleratesizeof(sAirAccelerate));
        
SendConVarValue(clientg_hAirAccelerationsAirAccelerate);
    }
}

public 
void Hook_PreThink(int client)
{
    if(
IsFakeClient(client) || !IsPlayerAlive(client))
        return;
    
    
SetConVarInt(g_hAirAccelerationAirAcceleratePerClient[client]);
}

public 
Action CommandRandomAirAccelerate(int clientint args)
{       
    if(!
IsValidClient(client))
        return 
Plugin_Continue;
    
    
AirAcceleratePerClient[client] = GetRandomInt(12000);    

    
char sAirAccelerate[16];
    
IntToString(AirAcceleratePerClient[client], sAirAcceleratesizeof(sAirAccelerate));
    
SendConVarValue(clientg_hAirAccelerationsAirAccelerate);    

    
PrintToChat(client"Your AirAccelerate has been changed to %i."AirAcceleratePerClient[client]);

    return 
Plugin_Continue;
}
 
bool IsValidClient(int client)
{
    if (!(
<= client <= MaxClients) || !IsClientConnected(client) || !IsClientInGame(client) || IsClientSourceTV(client) || IsClientReplay(client))
        return 
false;
        
    return 
true;

__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Reply



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 22:44.


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