Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- _____ ____
- | ___| __ ___ _______ _ __ / ___|___ _ __ ___
- | |_ | '__/ _ \_ / _ \ '_ \| | / _ \| '__/ _ \
- | _|| | | (_) / / __/ | | | |__| (_) | | | __/
- |_| |_| \___/___\___|_| |_|\____\___/|_| \___|
- Lightning speed and strength
- conjured directly from the depths of logic!
- Prismatic-Network 2013 (C) by Psykko
- <--------------------------------------------------------------------------->
- - Developer(s): Psykko
- - Complete: 100%
- - ScriptName: 'CheckpointSystem'
- - Comment: N/A
- <--------------------------------------------------------------------------->
- ]]
- LOC = {}
- local CD = 20 -- 20 sec
- function LOC.Options(event, player, message)
- if (message == "#save") then -- command to save location
- if (LOC[tostring(player)] == nil) then
- LOC[tostring(player)] = {cooldown = 0, map = player:GetMapId(), x = player:GetX(),y = player:GetY(),z = player:GetZ()}
- player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYour Location has been Saved.") -- text on save
- else
- if (GetCooldown(player).cooldown ~= 0) then
- LOC[tostring(player)] = {cooldown = GetCooldown(player).cooldown, map = player:GetMapId(), x = player:GetX(),y = player:GetY(),z = player:GetZ()}
- else
- LOC[tostring(player)] = {cooldown = 0, map = player:GetMapId(), x = player:GetX(),y = player:GetY(),z = player:GetZ()}
- end
- player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYour Checkpoint has been changed to his Location.") -- text on save the next point
- end
- return 0;
- end
- if (message == "#go") then -- command to teleport to checkpoint
- if (GetCoords(player) ~= false) then
- if (GetCooldown(player).cooldown == 0) then
- player:Teleport(GetCoords(player))
- player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYou have been Teleported to your Checkpoint. You can use this Command in 10seconds again.") -- text on teleport
- GetCooldown(player).cooldown = os.time() + CD
- else
- player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffPlease wait "..GetCooldown(player).cooldown - os.time().." seconds to teleport again.") -- text on cooldown
- end
- else
- player:SendBroadcastMessage("|cffff6060[Prismatic-Network]: |cff00ccffYou havent set a Checkpoint yet.") -- text on no saved location
- end
- return 0;
- end
- end
- function GetCoords(player) -- Get player coordinations
- for k, v in pairs(LOC) do
- if (k == tostring(player)) then
- return v.map, v.x, v.y, v.z
- end
- end
- return false
- end
- function GetCooldown(player) -- Get player cooldowns
- for k, v in pairs(LOC) do
- if (k == tostring(player)) then
- return v
- end
- end
- return false
- end
- function ClearCooldown() -- Clear Cooldowns
- for _, v in pairs(GetPlayersInWorld()) do
- if (GetCooldown(v) ~= false) and (GetCooldown(v).cooldown ~= 0) and (GetCooldown(v).cooldown <= os.time()) then
- GetCooldown(v).cooldown = 0
- end
- end
- RegisterTimedEvent("ClearCooldown", 1000, 1)
- end
- RegisterServerHook(16, "LOC.Options")
- RegisterTimedEvent("ClearCooldown", 1000, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement