Advertisement
HK47

SPAWNPOINTS

Oct 26th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. if CLIENT then return end
  2.  
  3. SPAWNPOINTS_TWS = {}
  4.  
  5. if not file.Exists("spawnpoints_tws", "DATA") then
  6.     file.CreateDir("spawnpoints_tws")
  7. else
  8.     local sp = file.Find("spawnpoints_tws/*.txt", "DATA")
  9.    
  10.     for i = 1, #sp do
  11.         table.insert(SPAWNPOINTS_TWS, sp[i])
  12.     end
  13. end
  14.  
  15.  
  16. hook.Add("PlayerSay", "custom_spawnp_tws", function(ply, text, team)
  17.     if not ply:IsAdmin() then return end
  18.    
  19.     local str = string.Explode(" ", text)
  20.    
  21.     if str[1] == "/addspawnpoint" then
  22.         if file.Exists("spawnpoints_tws/" .. str[2] .. ".txt", "DATA") then ply:ChatPrint("This spawnpoint is already existst!") return end
  23.    
  24.         file.Write("spawnpoints_tws/" .. str[2] .. ".txt", tostring(ply:GetEyeTrace().HitPos))
  25.    
  26.         table.insert(SPAWNPOINTS_TWS, str[2] .. ".txt")
  27.    
  28.         ply:ChatPrint(str[2] .. " spawnpoint is done!")
  29.     end
  30.    
  31.     if str[1] == "/printallsp" then
  32.         for k, v in pairs(SPAWNPOINTS_TWS) do
  33.             ply:ChatPrint(v .. " " .. file.Read("spawnpoints_tws/" .. v, "DATA"))
  34.         end
  35.     end
  36. end)
  37.  
  38. hook.Add("PlayerSpawn", "ply_spawn_tws", function(ply)
  39.     local pos = file.Read("spawnpoints_tws/" .. table.Random(SPAWNPOINTS_TWS), "DATA")
  40.     pos = string.Explode(" ", pos)
  41.    
  42.     local num = {}
  43.     for i = 1, 3 do num[i] = pos[i] end
  44.  
  45.     ply:SetPos(Vector(num[1], num[2], num[3]))
  46. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement