-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustom_boss_template.nut
44 lines (38 loc) · 1.12 KB
/
custom_boss_template.nut
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
local spots = ["will spawn at 1","will spawn at 2","will spawn at 3","will spawn at 4","will spawn at 5","will spawn at 6","will spawn at 7","will spawn at 8","will spawn at 9","will spawn at 10"]
local chosen_spot = -1
local chat_prefix = "The Tank "
SayTankSpot <- function(spot_num){
Say(null,chat_prefix + spots[spot_num-1],false)
chosen_spot = spot_num-1
}
local function IsCommand(msg,ent,command){
local message = ""
local found_start = false
local found_end = false
local last_char = 0
foreach(char in msg){
if(char != 32 && char != 10){
if(!found_start){
found_start = true
}
message += char.tochar()
} else if(char == 32){
if(last_char != 32){
found_end = true
}
if(found_start && !found_end){
message += char.tochar()
}
}
}
return message == command
}
function OnGameEvent_player_say(params)
{
local userid = params.userid
local text = params.text
if(IsCommand(text,GetPlayerFromUserID(userid),"!tank")){
SayTankSpot(chosen_spot+1)
}
}
__CollectEventCallbacks(this, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener)