mirror of
https://github.com/SpaxscE/simfphys_base.git
synced 2025-03-04 03:13:26 -05:00
Further optimize simfphys_mousesteer
net usage
This commit is contained in:
parent
39eaf3733c
commit
fa44e180b3
@ -98,9 +98,6 @@ ms_deadzone = GetConVar( "cl_simfphys_ms_deadzone" ):GetFloat()
|
||||
ms_exponent = GetConVar( "cl_simfphys_ms_exponent" ):GetFloat()
|
||||
ms_key_freelook = GetConVar( "cl_simfphys_ms_keyfreelook" ):GetInt()
|
||||
|
||||
local ms_pos_x = 0
|
||||
local sm_throttle = 0
|
||||
|
||||
local function DrawCircle( X, Y, radius )
|
||||
local segmentdist = 360 / ( 2 * math.pi * radius / 2 )
|
||||
|
||||
@ -109,6 +106,11 @@ local function DrawCircle( X, Y, radius )
|
||||
end
|
||||
end
|
||||
|
||||
local ms_pos_x = 0
|
||||
local sm_throttle = 0
|
||||
local s_smoothrpm = 0
|
||||
local lastMouseSteer = 0
|
||||
|
||||
hook.Add( "StartCommand", "simfphysmove", function( ply, cmd )
|
||||
if ply ~= LocalPlayer() then return end
|
||||
if not isMouseSteer then return end
|
||||
@ -132,11 +134,14 @@ hook.Add( "StartCommand", "simfphysmove", function( ply, cmd )
|
||||
|
||||
end
|
||||
|
||||
if lastMouseSteer == SteerVehicle then return end
|
||||
lastMouseSteer = SteerVehicle
|
||||
|
||||
net.Start( "simfphys_mousesteer" )
|
||||
net.WriteEntity( vehicle )
|
||||
net.WriteFloat( SteerVehicle )
|
||||
net.WriteInt( SteerVehicle * 255, 9 )
|
||||
net.SendToServer()
|
||||
end)
|
||||
end )
|
||||
|
||||
local function drawsimfphysHUD(vehicle,SeatCount)
|
||||
if isMouseSteer and ShowHud_ms then
|
||||
|
@ -1,16 +1,18 @@
|
||||
util.AddNetworkString( "simfphys_mousesteer" )
|
||||
util.AddNetworkString( "simfphys_blockcontrols" )
|
||||
|
||||
net.Receive( "simfphys_mousesteer", function( length, ply )
|
||||
net.Receive( "simfphys_mousesteer", function( _, ply )
|
||||
if not ply:IsDrivingSimfphys() then return end
|
||||
|
||||
local vehicle = net.ReadEntity()
|
||||
local Steer = net.ReadFloat()
|
||||
|
||||
local Steer = net.ReadInt( 9 )
|
||||
|
||||
Steer = Steer / 255
|
||||
|
||||
if not IsValid( vehicle ) or ply:GetSimfphys() ~= vehicle:GetParent() then return end
|
||||
|
||||
|
||||
vehicle.ms_Steer = Steer
|
||||
end)
|
||||
end )
|
||||
|
||||
net.Receive( "simfphys_blockcontrols", function( length, ply )
|
||||
if not IsValid( ply ) then return end
|
||||
|
Loading…
Reference in New Issue
Block a user