forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspawn.lua
More file actions
39 lines (28 loc) · 1.17 KB
/
spawn.lua
File metadata and controls
39 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function HandleSpawnCommand(Split, Player)
local WorldIni = cIniFile()
WorldIni:ReadFile(Player:GetWorld():GetIniFileName())
local SpawnX = WorldIni:GetValue("SpawnPosition", "X")
local SpawnY = WorldIni:GetValue("SpawnPosition", "Y")
local SpawnZ = WorldIni:GetValue("SpawnPosition", "Z")
World = Player:GetWorld()
SetBackCoordinates(Player)
Player:TeleportToCoords(SpawnX, SpawnY, SpawnZ)
SendMessageSuccess( Player, "Returned to world spawn" )
return true
end
function HandleSetSpawnCommand(Split, Player)
local WorldIni = cIniFile()
WorldIni:ReadFile(Player:GetWorld():GetIniFileName())
local PlayerX = Player:GetPosX()
local PlayerY = Player:GetPosY()
local PlayerZ = Player:GetPosZ()
WorldIni:DeleteValue("SpawnPosition", "X")
WorldIni:DeleteValue("SpawnPosition", "Y")
WorldIni:DeleteValue("SpawnPosition", "Z")
WorldIni:SetValue("SpawnPosition", "X", PlayerX)
WorldIni:SetValue("SpawnPosition", "Y", PlayerY)
WorldIni:SetValue("SpawnPosition", "Z", PlayerZ)
WorldIni:WriteFile(Player:GetWorld():GetIniFileName())
SendMessageSuccess( Player, string.format("Changed spawn position to [X:%i Y:%i Z:%i]", PlayerX, PlayerY, PlayerZ) )
return true
end