Guest User

Untitled

a guest
May 20th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. --Function to be called every 4 seconds
  2. function MoleDamage
  3. --get all players
  4. local players = player.GetAll()
  5. -- if no players, don't bother
  6. if table.Counter(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. location position = v:LocalToWorld(v:OBBCenter())
  15. -- check location, if itis less than 65
  16. if position.z =< 65 then
  17. -- take 5 dmg
  18. v:TakeDamage(5)
  19. -- inform player
  20. v:PrintMessage( HUD_PRINTCENTER, "You are soffocating! Get back underground!" )
  21. elseif v:health() != v:GetMaxHealth() then
  22. -- heal 5 dmg
  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 ever 4 seoncs
  39. timer.Simple( 4, MoleDamage())
Advertisement
Add Comment
Please, Sign In to add comment