• Underwater damage
    5 replies, posted
You dont lose health being underwater in sandbox and my gamemode is derived from it so i was wondering if there was something out there to take like, 5% health for every 3 seconds underwater. Something like that. Thanks!
now I'm not sure how you would call this so it was efficient but Entity:WaterLevel() returns 3 if the player is fully underwater. you may have to hack it in or there might be something I'm missing for drowning dsmage.
why do you need so much help? no offence, but I see tons of threads by you that are asking for help. for this you would probably need to do a for loop count, then if the total occurs then kill the player
[QUOTE=tyguy;39290227]why do you need so much help? no offence, but I see tons of threads by you that are asking for help. for this you would probably need to do a for loop count, then if the total occurs then kill the player[/QUOTE] He's allowed to ask questions. It's up to people to either answer him or not. So truly, it is none of your business if he asks a lot of questions.
You really should try to find something out for yourself, for once. You want something you've seen before. [i]Okay, where have I see this before?[/i] For one, TTT. It comes with GMod, and obviously you can see the source. [i]Okay, I know generally where this is, but not where specifically it is.[/i] As tyguy said, you would check player.WaterLevel. One quick search later, lines 1025-1092 of player.lua. [lua] -- Drowning and such local tm = nil local ply = nil local plys = nil function GM:Tick() -- three cheers for micro-optimizations plys = player.GetAll() for i= 1, #plys do ply = plys[i] tm = ply:Team() if tm == TEAM_TERROR and ply:Alive() then -- Drowning if ply:WaterLevel() == 3 then if ply:IsOnFire() then ply:Extinguish() end if ply.drowning then if ply.drowning < CurTime() then local dmginfo = DamageInfo() dmginfo:SetDamage(15) dmginfo:SetDamageType(DMG_DROWN) dmginfo:SetAttacker(game.GetWorld()) dmginfo:SetInflictor(game.GetWorld()) dmginfo:SetDamageForce(Vector(0,0,1)) ply:TakeDamageInfo(dmginfo) -- have started drowning properly ply.drowning = CurTime() + 1 end else -- will start drowning soon ply.drowning = CurTime() + 8 end else ply.drowning = nil end -- Slow down ironsighters local wep = ply:GetActiveWeapon() if IsValid(wep) and wep:GetIronsights() then ply:SetSpeed(true) else ply:SetSpeed(false) end -- Run DNA Scanner think also when it is not deployed if IsValid(ply.scanner_weapon) and wep != ply.scanner_weapon then ply.scanner_weapon:Think() end elseif tm == TEAM_SPEC then if ply.propspec then PROPSPEC.Recharge(ply) if IsValid(ply:GetObserverTarget()) then ply:SetPos(ply:GetObserverTarget():GetPos()) end end -- if spectators are alive, ie. they picked spectator mode, then -- DeathThink doesn't run, so we have to SpecThink here if ply:Alive() then self:SpectatorThink(ply) end end end end[/lua]
Thanks for the help. Ive been too lazy lately. I guess i should do more research!
Sorry, you need to Log In to post a reply to this thread.