Advertisement
Guest User

EventSystem

a guest
Apr 17th, 2013
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. --[[
  2.   _____                        ____              
  3.  |  ___| __ ___ _______ _ __  / ___|___  _ __ ___
  4.  | |_ | '__/ _ \_  / _ \ '_ \| |   / _ \| '__/ _ \
  5.  |  _|| | | (_) / /  __/ | | | |__| (_) | | |  __/
  6.  |_|  |_|  \___/___\___|_| |_|\____\___/|_|  \___|
  7.      Lightning speed and strength
  8.          conjured directly from the depths of logic!  
  9.             Prismatic-Network 2013 (C) by Psykko
  10. <--------------------------------------------------------------------------->
  11.  - Developer(s): Psykko
  12.  - Complete: 100%
  13.  - ScriptName: 'CheckpointSystem'
  14.  - Comment: N/A
  15. <--------------------------------------------------------------------------->
  16. ]]
  17.  
  18. LOC = {}
  19.  
  20. local CD = 20 -- 20 sec
  21.  
  22. function LOC.Options(event, player, message)
  23.     if (message == "#save") then -- command to save location
  24.         if (LOC[tostring(player)] == nil) then
  25.             LOC[tostring(player)] = {cooldown = 0, map = player:GetMapId(), x = player:GetX(),y = player:GetY(),z = player:GetZ()}
  26.             player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYour Location has been Saved.") -- text on save
  27.         else
  28.             if (GetCooldown(player).cooldown ~= 0) then
  29.                 LOC[tostring(player)] = {cooldown = GetCooldown(player).cooldown, map = player:GetMapId(), x = player:GetX(),y = player:GetY(),z = player:GetZ()}
  30.             else
  31.                 LOC[tostring(player)] = {cooldown = 0, map = player:GetMapId(), x = player:GetX(),y = player:GetY(),z = player:GetZ()}
  32.             end
  33.             player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYour Checkpoint has been changed to his Location.") -- text on save the next point
  34.         end
  35.         return 0;
  36.     end
  37.     if (message == "#go") then  -- command to teleport to checkpoint
  38.         if (GetCoords(player) ~= false) then
  39.             if (GetCooldown(player).cooldown == 0) then
  40.                 player:Teleport(GetCoords(player))
  41.                 player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYou have been Teleported to your Checkpoint. You can use this Command in 10seconds again.") -- text on teleport
  42.                 GetCooldown(player).cooldown = os.time() + CD
  43.             else
  44.                 player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffPlease wait "..GetCooldown(player).cooldown - os.time().." seconds to teleport again.") -- text on cooldown
  45.             end
  46.         else
  47.             player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYou havent set a Checkpoint yet.") -- text on no saved location
  48.         end
  49.         return 0;
  50.     end
  51. end
  52.  
  53. function GetCoords(player) -- Get player coordinations
  54.     for k, v in pairs(LOC) do
  55.         if (k == tostring(player)) then
  56.             return v.map, v.x, v.y, v.z
  57.         end
  58.     end
  59.     return false
  60. end
  61.  
  62. function GetCooldown(player)    -- Get player cooldowns
  63.     for k, v in pairs(LOC) do
  64.         if (k == tostring(player)) then
  65.             return v
  66.         end
  67.     end
  68.     return false
  69. end
  70.        
  71. function ClearCooldown() -- Clear Cooldowns
  72.     for _, v in pairs(GetPlayersInWorld()) do
  73.         if (GetCooldown(v) ~= false) and (GetCooldown(v).cooldown ~= 0) and (GetCooldown(v).cooldown <= os.time()) then
  74.             GetCooldown(v).cooldown = 0
  75.         end
  76.     end
  77.     RegisterTimedEvent("ClearCooldown", 1000, 1)
  78. end
  79.  
  80. RegisterServerHook(16, "LOC.Options")
  81. RegisterTimedEvent("ClearCooldown", 1000, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement