-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
200 lines (188 loc) · 4.85 KB
/
init.lua
File metadata and controls
200 lines (188 loc) · 4.85 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
-- randomize player position within the spawn plot
local function go_spawn(player)
if core.setting_get('static_spawnpoint') then
local pos = core.setting_get_pos('static_spawnpoint')
if core.setting_get('variable_spawnpoint') then
local range = tonumber(core.setting_get('variable_spawnpoint'))
if range > 0 then
pos.x = pos.x + math.random(-(range), range)
pos.z = pos.z + math.random(-(range), range)
end
end
local name = player:get_player_name()
core.log("action", '[Spawn Plus] Moving '..name..' to '..
string.format("(%0.1f, %0.1f, %0.1f)", pos.x, pos.y, pos.z)
)
core.sound_play("teleport", {
to_player=name,
gain = 0.1
})
player:setpos( pos )
end
end
core.register_chatcommand('spawn', {
description = "Teleports you to spawn",
privs = {
shout = true
},
func = function(name)
local player = core.get_player_by_name(name)
go_spawn(player)
end
})
core.register_chatcommand('arena', {
description = "Teleports you to PVP arena",
privs = {
shout = true,
interact = true
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=595, y=6, z=405 } )
end
})
core.register_chatcommand('hall', {
description = "Teleports you to City Hall",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=135, y=7, z=40 } )
end
})
core.register_chatcommand('post', {
description = "Teleports you to the Post Office",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=676, y=4, z=523 } )
end
})
core.register_chatcommand('town', {
description = "Teleports you to the town.",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=620, y=3, z=-2906 } )
end
})
core.register_chatcommand('airport', {
description = "Teleports you to the airport.",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=1395, y=33, z=-2880 } )
end
})
core.register_chatcommand('hub', {
description = "Teleports you to the hub.",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=1112, y=11, z=-544 } )
end
})
core.register_chatcommand('mine', {
description = "Teleports you to the pubic mine.",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=33, y=-72, z=235 } )
end
})
core.register_chatcommand('mall', {
description = "Teleports you to the mall.",
privs = {
shout = true,
},
func = function(name)
local player = core.get_player_by_name(name)
core.sound_play( "teleport", {
to_player=player:get_player_name(),
gain = 0.1
})
player:setpos( { x=667, y=6, z=-377 } )
end
})
local INTERVAL=3
local WARN_LIMIT=4500
local LIMIT=4528
local function check_pos_range()
local players = core.get_connected_players()
for _,p in ipairs(players) do
if p:is_player() and not core.check_player_privs(p, 'server') then
local pos = p:getpos()
local max = math.max(math.abs(pos.x), math.abs(pos.z))
if max > LIMIT then
p:set_detach()
go_spawn(p)
local name = p:get_player_name()
core.chat_send_player(name, 'You won a free ticket to spawn!')
core.after(1, function() -- kick players who won't move
if p:is_player() then
pos = p:getpos()
max = math.max(math.abs(pos.x), math.abs(pos.z))
if max > LIMIT then
core.kick_player(name, "You are too far from spawn.")
end
end
end)
elseif max > WARN_LIMIT then
local name = p:get_player_name()
core.sound_play('spawnplus_sucker_punch', {to_player=name, gain = 0.2})
p:set_hp( p:get_hp() - 4 )
core.chat_send_player(name, 'Do not travel beyond '..WARN_LIMIT..'.')
core.log("action", '[Spawn Plus] '..name..' out of bounds at '..
core.pos_to_string(pos)..', hp reduced to '..p:get_hp())
end
end
end
core.after(INTERVAL, check_pos_range)
end
core.after(INTERVAL, check_pos_range)
core.register_on_joinplayer(function (player)
local pos = player:getpos()
local max = math.max(math.abs(pos.x),math.abs(pos.z))
if max > LIMIT then
go_spawn(player)
end
end)