SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --Function to be called every 4 seconds |
| 1 | + | -- Function to be called every 4 seconds |
| 2 | - | function MoleDamage |
| 2 | + | function MoleDamage() |
| 3 | - | --get all players |
| 3 | + | -- Gets all players |
| 4 | - | local players = player.GetAll() |
| 4 | + | local players = player.GetAll() |
| 5 | - | -- if no players, don't bother |
| 5 | + | -- If no players, don't bother. |
| 6 | - | if table.Counter(players) > 0 then |
| 6 | + | if table.Count(players) > 0 then |
| 7 | - | --does it to all players |
| 7 | + | -- Does it to all players |
| 8 | - | for i = 1, table.Count(players) do |
| 8 | + | for i = 1, table.Count(players) do |
| 9 | - | local v = players[i] |
| 9 | + | local v = players[i] |
| 10 | - | if v:IsValid() then |
| 10 | + | if v:IsValid() then |
| 11 | - | -- if they are a mole, and a player, and alive |
| 11 | + | -- If they are a mole, and a player, and alive |
| 12 | - | if v:team() == TEAM_MOLE and v:IsPlayer() and v:IsAlive() then |
| 12 | + | if v:Team() == TEAM_MOLE and v:IsPlayer() and v:IsAlive() then |
| 13 | - | --get location |
| 13 | + | --Get location |
| 14 | - | location position = v:LocalToWorld(v:OBBCenter()) |
| 14 | + | local position = v:LocalToWorld(v:OBBCenter()) |
| 15 | - | -- check location, if itis less than 65 |
| 15 | + | -- Check location, if it is less than 65 |
| 16 | - | if position.z =< 65 then |
| 16 | + | if position.z =< 65 then |
| 17 | - | -- take 5 dmg |
| 17 | + | --Take 5 damage |
| 18 | - | v:TakeDamage(5) |
| 18 | + | v:TakeDamage(5) |
| 19 | - | -- inform player |
| 19 | + | -- Inform player |
| 20 | - | v:PrintMessage( HUD_PRINTCENTER, "You are soffocating! Get back underground!" ) |
| 20 | + | v:PrintMessage( HUD_PRINTCENTER, "You are suffocating! Get back underground!" ) |
| 21 | - | elseif v:health() != v:GetMaxHealth() then |
| 21 | + | elseif v:Health() != v:GetMaxHealth() then |
| 22 | - | -- heal 5 dmg |
| 22 | + | -- Heal 5 damage |
| 23 | - | v:TakeDamage(-5) |
| 23 | + | v:TakeDamage(-5) |
| 24 | - | end |
| 24 | + | end |
| 25 | - | elseif v:Team() != TEAM_MOLE and v:IsPlayer() and v:IsAlive() then |
| 25 | + | elseif v:Team() != TEAM_MOLE and v:IsPlayer() and v:IsAlive() then |
| 26 | - | --get location |
| 26 | + | --Get location |
| 27 | - | local position = v:LocalToWorld(v:OBBCenter()) |
| 27 | + | local position = v:LocalToWorld(v:OBBCenter()) |
| 28 | - | -- check location, if it is less than 65 |
| 28 | + | -- Check location, if it is less than 65 |
| 29 | - | if position.z =< 65 then |
| 29 | + | if position.z =< 65 then |
| 30 | - | --inform player |
| 30 | + | -- Inform player |
| 31 | - | v:PrintMessage( HUD_PRINTCENTER, "You are entering mole territory; beware!" ) |
| 31 | + | v:PrintMessage( HUD_PRINTCENTER, "You are entering mole territory; beware!" ) |
| 32 | - | end |
| 32 | + | end |
| 33 | - | end |
| 33 | + | end |
| 34 | - | end |
| 34 | + | end |
| 35 | - | end |
| 35 | + | end |
| 36 | - | end |
| 36 | + | end |
| 37 | end | |
| 38 | - | -- calls function ever 4 seoncs |
| 38 | + | -- Calls function every 4 seconds |
| 39 | timer.Simple( 4, MoleDamage()) |