Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to be called every 4 seconds
- function MoleDamage()
- -- Gets all players
- local players = player.GetAll()
- -- If no players, don't bother.
- if table.Count(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
- local position = v:LocalToWorld(v:OBBCenter())
- -- Check location, if it is less than 65
- if position.z =< 65 then
- --Take 5 damage
- v:TakeDamage(5)
- -- Inform player
- v:PrintMessage( HUD_PRINTCENTER, "You are suffocating! Get back underground!" )
- elseif v:Health() != v:GetMaxHealth() then
- -- Heal 5 damage
- 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 every 4 seconds
- timer.Simple( 4, MoleDamage())
Advertisement
Add Comment
Please, Sign In to add comment