I'm sure most of you know once you go into water and start swimming then get out of the water, it never switches the animation back. Long story short has anyone made a fix for this? I attempted to do one myself but I couldn't get it working.
[code]
function WaterAnimFix( ply )
if ( ply:IsOnGround() && ply:WaterLevel() >= 0 ) then
ply:AnimRestartGesture ( ACT_MP_RUN )
end
end
[/code]
The problem with WaterLevel >= 0 is that this is what it approx. means:
0 = not in water
1 = ankle to chest deep
2 = chest to head deep
3 = fully submerged
Detect that it's < 3 then use walk animation.
Is it that big of a deal? It rarely occurs and I think it's quite funny actually.
[QUOTE=Gamz365;41043631]Is it that big of a deal? It rarely occurs and I think it's quite funny actually.[/QUOTE]
Well the hit boxes being fucked up is kind of a big deal, and by rarely happening you mean EVERY time someone goes into water.
This happens because the waterlevel value seems to rarely work for other players client-side.
I have a shitty fix on my servers.
Server-side
[lua]hook.Add( "Tick", "Breakpoint - Player Water Fix", function()
for _, ply in pairs( player.GetAll() ) do
local level = ply:WaterLevel()
if level ~= ply:GetDTInt( 2 ) then -- Only update if the value changed
ply:SetDTInt( 2, level )
end
end
end )[/lua]
Client-side
[lua]local PLAYER = FindMetaTable("Player")
function PLAYER:WaterLevel()
return self:GetDTInt( 2 )
end[/lua]
sick thanks dude
Where did you stick this bit of code?
Put the serverside bit in a serverside file, like init.lua
Put the clientside bit in a clientside file, like cl_init.lua
[img]http://4st.me/1gj7f.png[/img] In that folder.
To make it easier, save the following code as [I]garrymod/lua/autorun/ttt_waterfix.lua[/I]
[code]-- Swimming Animation Fix
-- by BlackAwps
-- http://facepunch.com/showthread.php?t=1278671&p=41047702&viewfull=1#post41047702
if SERVER then
AddCSLuaFile()
hook.Add( "Tick", "Breakpoint - Player Water Fix", function()
for _, ply in pairs( player.GetAll() ) do
local level = ply:WaterLevel()
if level ~= ply:GetDTInt( 2 ) then -- Only update if the value changed
ply:SetDTInt( 2, level )
end
end
end )
else
local PLAYER = FindMetaTable("Player")
function PLAYER:WaterLevel()
return self:GetDTInt( 2 )
end
end[/code]
TY samm5506 thats what I did but I guess my addon is broken.
Sorry, you need to Log In to post a reply to this thread.