[ReplicateGravity] 'New' stripped version of FixPlayerGravity.
This commit is contained in:
parent
b1c5aeb89f
commit
abc69e4807
61
ReplicateGravity/scripting/ReplicateGravity.sp
Normal file
61
ReplicateGravity/scripting/ReplicateGravity.sp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
|
#include <sourcemod>
|
||||||
|
|
||||||
|
ConVar g_hCVar_Gravity;
|
||||||
|
|
||||||
|
float g_flClientGravityReplicate[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public Plugin myinfo =
|
||||||
|
{
|
||||||
|
name = "ReplicateGravity",
|
||||||
|
author = "xen, zaCade",
|
||||||
|
description = "Allow client prediction for gravity",
|
||||||
|
version = "1.0.0"
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void OnPluginStart()
|
||||||
|
{
|
||||||
|
if ((g_hCVar_Gravity = FindConVar("sv_gravity")) == null)
|
||||||
|
{
|
||||||
|
SetFailState("Unable to find ConVar \"sv_gravity\"!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void OnGameFrame()
|
||||||
|
{
|
||||||
|
float flServerGravity = g_hCVar_Gravity.FloatValue;
|
||||||
|
|
||||||
|
for (int client = 1; client < MaxClients; client++)
|
||||||
|
{
|
||||||
|
if (!IsClientInGame(client) || !IsPlayerAlive(client) || IsFakeClient(client))
|
||||||
|
{
|
||||||
|
g_flClientGravityReplicate[client] = flServerGravity;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float flClientGravity = GetEntityGravity(client);
|
||||||
|
float flClientGravityReplicate = flClientGravity * flServerGravity;
|
||||||
|
|
||||||
|
if (flClientGravityReplicate != g_flClientGravityReplicate[client])
|
||||||
|
{
|
||||||
|
char szGravity[8];
|
||||||
|
FloatToString(flClientGravityReplicate, szGravity, sizeof(szGravity));
|
||||||
|
|
||||||
|
g_hCVar_Gravity.ReplicateToClient(client, szGravity);
|
||||||
|
|
||||||
|
g_flClientGravityReplicate[client] = flClientGravityReplicate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user