HungerJohnson

Untitled

May 20th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Function to be called every 4 seconds
  2. function MoleDamage()
  3.     -- Gets all players
  4.     local players = player.GetAll()
  5.     -- If no players, don't bother.
  6.     if table.Count(players) > 0 then
  7.         -- Does it to all players
  8.         for i = 1, table.Count(players) do
  9.             local v = players[i]
  10.             if v:IsValid() then
  11.                 -- If they are a mole, and a player, and alive
  12.                 if v:Team() == TEAM_MOLE and v:IsPlayer() and v:IsAlive() then
  13.                 --Get location
  14.                 local position = v:LocalToWorld(v:OBBCenter())
  15.                     -- Check location,  if it is less than 65
  16.                     if position.z =< 65 then
  17.                          --Take 5 damage
  18.                          v:TakeDamage(5)
  19.                          -- Inform player
  20.                          v:PrintMessage( HUD_PRINTCENTER, "You are suffocating! Get back underground!" )
  21.                     elseif v:Health() != v:GetMaxHealth() then
  22.                         -- Heal 5 damage
  23.                         v:TakeDamage(-5)
  24.                     end
  25.                 elseif v:Team() != TEAM_MOLE and v:IsPlayer() and v:IsAlive() then
  26.                 --Get location
  27.                 local position = v:LocalToWorld(v:OBBCenter())
  28.                     -- Check location,  if it is less than 65
  29.                     if position.z =< 65 then  
  30.                          -- Inform player
  31.                          v:PrintMessage( HUD_PRINTCENTER, "You are entering mole territory; beware!" )
  32.                     end          
  33.                 end
  34.             end
  35.         end
  36.     end
  37. end
  38. -- Calls function every 4 seconds
  39. timer.Simple( 4, MoleDamage())
Advertisement
Add Comment
Please, Sign In to add comment