Hi guys !
This rain effect from weather mod has broken during a Gmod update !
Someone know what's wrong ?
Here's the code :
[Lua]
local density=CreateClientConVar("cs_raindensity","1",false,false)
function EFFECT:Init(data)
self.Particles=data:GetMagnitude()*density:GetInt()
self.DieTime=CurTime()+1
self.Emitter=ParticleEmitter(LocalPlayer():GetPos())
end
local function ParticleCollides(particle, pos, norm)
particle:SetDieTime(0)
local effectdata = EffectData()
effectdata:SetStart(pos)
effectdata:SetOrigin(pos)
effectdata:SetScale(2)
util.Effect( "watersplash", effectdata )
end
function EFFECT:Think()
if CurTime()>self.DieTime then return false end
local emitter = self.Emitter
for i=1, self.Particles do
local spawnpos = LocalPlayer():GetPos()+Vector(math.random(-1200,1200)+LocalPlayer():GetVelocity().x*2,math.random(-1200,1200)+LocalPlayer():GetVelocity().y*2,1000)
local particle = emitter:Add("particle/Water/WaterDrop_001a", spawnpos)
if (particle) then
particle:SetVelocity(Vector(math.sin(CurTime()/4)*30,50,-700))
particle:SetLifeTime(0)
particle:SetDieTime(4)
particle:SetEndAlpha(255)
particle:SetStartSize(0)
particle:SetEndSize(5)
particle:SetAirResistance(0)
particle:SetStartAlpha(128)
particle:SetCollide(true)
particle:SetBounce(0)
particle:SetCollideCallback(ParticleCollides)
end
end
return true
end
function EFFECT:Render()
end
[/lua]
as well as to, someone can explain me how to change the height position of this bar ? (I want to put it up the health)
[lua]
function FStamina_Regen()
for k, v in pairs(player.GetAll()) do
if (v:GetMoveType() ~= MOVETYPE_NOCLIP) and (!v:KeyDown(IN_SPEED)) and (!v:KeyDown(IN_JUMP)) and (!v:KeyDown(IN_FORWARD)) and (!v:KeyDown(IN_BACK)) and (!v:KeyDown(IN_MOVELEFT)) and (!v:KeyDown(IN_MOVERIGHT)) then
local Stam = v:GetNWInt("FStamina")
if v:IsOnGround() and v:WaterLevel() == 0 then
v:SetNWInt( "FStamina", math.Clamp(Stam+2, 0, 100))
elseif v:WaterLevel() == 1 then
v:SetNWInt( "FStamina", math.Clamp(Stam+3, 0, 100))
end
end
end
end
timer.Create("FStamina_Regen", 1, 0, FStamina_Regen)
if CLIENT then
if not FStaminaToggled then
function FStamina_Draw()
if LocalPlayer():GetNWInt( "FStamina" ) then
if LocalPlayer():Alive() then
local Fx = ( ScrH()/23 ) -- 23
local Fy = ( ScrH()/1 ) -- Nul
local Fx = ( ScrW()/6 ) -- 6
local Fy = ( ScrH()/140 ) -- 146
draw.RoundedBox( 4, Fx, Fy, Fx, Fy, Color( 90, 90, 90, 255 ) ) -- Arrondissement de 4 par default !
if LocalPlayer():GetNWInt( "FStamina" ) > 1 then
draw.RoundedBox( 4, Fx, Fy, Fx*( LocalPlayer():GetNWInt( "FStamina" )/100 ), Fy, Color( 255, 242, 0, 255 ) ) -- Idem
end
end
end
end
hook.Add( "HUDPaint", "FStamina_Draw", FStamina_Draw )
end
end
if SERVER then
if not FStaminaToggled then
function FStamina_Spawn( ply )
ply:SetNWInt( "FStamina", 100 )
end
hook.Add( "PlayerSpawn", "FStamina_Spawn", FStamina_Spawn )
function FStamina_MainThink()
for k, ply in pairs( player.GetAll() ) do
if ply:GetNWInt( "FStamina" ) < 0 then ply:SetNWInt( "FStamina", 0 ) end
if ply:GetNWInt( "FStamina" ) > 100 then ply:SetNWInt( "FStamina", 100 ) end
if ply.LastHealth and ply.LastHealth > ply:Health() then
local damage = ( ply.LastHealth - ply:Health() )*2
ply.LastHealth = ply:Health()
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" ) - damage )
elseif not ply.LastHealth then
ply.LastHealth = ply:Health()
end
if ply:GetMoveType() ~= MOVETYPE_NOCLIP then
if ( ply:KeyDown( IN_SPEED ) or ply:KeyPressed( IN_SPEED ) ) and ply:GetNWInt( "FStamina" ) > 0 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-( ( ply:GetRunSpeed()/12000 ) ) )
ply.LastFStamina = CurTime() + 3
if ply:KeyPressed( IN_JUMP ) and ply:GetNWInt( "FStamina" ) > 0 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-10 )
ply.LastFStamina = CurTime() + 3
end
if ply:WaterLevel() == 3 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-( ( ( ply:GetRunSpeed()/12000 )*1.6 ) ) )
end
elseif ply:KeyPressed( IN_JUMP ) and ply:GetNWInt( "FStamina" ) > 0 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-10 )
ply.LastFStamina = CurTime() + 3
if ply:WaterLevel() == 3 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-( ( ( ply:GetRunSpeed()/12000 )*1.6 ) ) )
end
elseif ( ply:KeyDown( IN_FORWARD ) or ply:KeyDown( IN_BACK ) or ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) ) and ply:GetNWInt( "MStamina" ) > 0 then
if ply:GetMoveType() == MOVETYPE_LADDER or ply:WaterLevel() == 1 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-( ( ( ply:GetRunSpeed()/12000 )*1.2 ) ) )
elseif ply:WaterLevel() == 3 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "FStamina" )-( ( ( ply:GetRunSpeed()/12000 )*1.6 ) ) )
end
elseif ply.LastMStamina and ply.LastMStamina < CurTime() then
if ply:IsOnGround() and ply:WaterLevel() == 0 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "MStamina" )+2 )
elseif ply:WaterLevel() == 1 then
ply:SetNWInt( "FStamina", ply:GetNWInt( "MStamina" )+3 )
end
ply:SetRunSpeed( ply.FRunSPeed )
ply:SetJumpPower( ply.FJumpPower )
ply.FRunSPeed = nil
ply.FJumpPower = nil
elseif ply:GetNWInt( "FStamina" ) <= 0 and ( ply:GetRunSpeed() > 0 or ply:GetJumpPower() > 0 ) then
ply.FRunSpeed = ply:GetRunSpeed()
ply.FJumpPower = ply:GetJumpPower()
ply:SetWalkSpeed( 250 )
ply:SetRunSpeed( ply:GetWalkSpeed() )
ply:SetJumpPower( 0 )
end
if ply:KeyDown( IN_SPEED ) and ply:GetNWInt( "FStamina" ) <= 0 then
ply:SetRunSpeed( ply:GetWalkSpeed() )
end
end
end
end
hook.Add( "Think", "FStamina_MainThink", FStamina_MainThink )
end
end
function FStamina_Toggle()
if FStaminaToggled then
FStaminaToggled = false
else
FStaminaToggled = true
end
end
concommand.Add( "FanStamina_toggle", FStamina_Toggle )
[/lua]
If something is broken, you need to provide us with an error, and we can try and trouble shoot your issues. Without errors we have no way of figuring out your issue, without testing it ourselves (which is unrealistic).
Sorry, you need to Log In to post a reply to this thread.