Quote:
Originally Posted by Cruze
|
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(client, SDKHook_PreThinkPost, Hook_PreThink);
char sAirAccelerate[16];
IntToString(AirAcceleratePerClient[client], sAirAccelerate, sizeof(sAirAccelerate));
SendConVarValue(client, g_hAirAcceleration, sAirAccelerate);
}
}
public void Hook_PreThink(int client)
{
if(IsFakeClient(client) || !IsPlayerAlive(client))
return;
SetConVarInt(g_hAirAcceleration, AirAcceleratePerClient[client]);
}
public Action CommandRandomAirAccelerate(int client, int args)
{
if(!IsValidClient(client))
return Plugin_Continue;
AirAcceleratePerClient[client] = GetRandomInt(1, 2000);
char sAirAccelerate[16];
IntToString(AirAcceleratePerClient[client], sAirAccelerate, sizeof(sAirAccelerate));
SendConVarValue(client, g_hAirAcceleration, sAirAccelerate);
PrintToChat(client, "Your AirAccelerate has been changed to %i.", AirAcceleratePerClient[client]);
return Plugin_Continue;
}
bool IsValidClient(int client)
{
if (!(1 <= client <= MaxClients) || !IsClientConnected(client) || !IsClientInGame(client) || IsClientSourceTV(client) || IsClientReplay(client))
return false;
return true;
}
__________________