Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Function to be called every 4 seconds
- function MoleDamage
- --get all players
- local players = player.GetAll()
- -- if no players, don't bother
- if table.Counter(players) > 0 then
- --does it to all players
- for i = 1, table.Count(players) do
- local v = players[i]
- if v:IsValid() then
- -- if they are a mole, and a player, and alive
- if v:team() == TEAM_MOLE and v:IsPlayer() and v:IsAlive() then
- --get location
- location position = v:LocalToWorld(v:OBBCenter())
- -- check location, if itis less than 65
- if position.z =< 65 then
- -- take 5 dmg
- v:TakeDamage(5)
- -- inform player
- v:PrintMessage( HUD_PRINTCENTER, "You are soffocating! Get back underground!" )
- elseif v:health() != v:GetMaxHealth() then
- -- heal 5 dmg
- v:TakeDamage(-5)
- end
- elseif v:Team() != TEAM_MOLE and v:IsPlayer() and v:IsAlive() then
- --get location
- local position = v:LocalToWorld(v:OBBCenter())
- -- check location, if it is less than 65
- if position.z =< 65 then
- --inform player
- v:PrintMessage( HUD_PRINTCENTER, "You are entering mole territory; beware!" )
- end
- end
- end
- end
- end
- end
- -- calls function ever 4 seoncs
- timer.Simple( 4, MoleDamage())
Advertisement
Add Comment
Please, Sign In to add comment