I created a table to store zombie classes, their names, health, speed, etc. In the menu, you get the zombie classes based on their names in the table.
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
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
zombieClassList = {
[1] = {
name = "Classic Zombie",
health = 250, -- normal health
speed = 0, -- normal speed
armor = 0, -- no armor
weapon = {78}, -- claw
knockback = 7, -- normal knockback
fastBuilding = 0, -- change to 1 to make building faster
description = "Basic zombie with normal health and speed"
},
[2] = {
name = "Fat Zombie",
health = 800, -- very high health
speed = -12, -- very low speed
armor = 202, -- medium armor
weapon = {78},
knockback = 4, -- low knockback
fastBuilding = 0,
description = "Fat zombie with extremely high health and low knockback"
},
[3] = {
name = "Runner Zombie",
health = 100, -- very low health
speed = 4, -- very high speed
armor = 0,
weapon = {78},
knockback = 10, -- high knockback
fastBuilding = 0,
description = "Fast-moving zombie with low health but high speed"
},
[4] = {
name = "Brute Zombie",
health = 400, -- high health
speed = -2, -- low speed
armor = 0,
weapon = {69}, -- machete
knockback = 7,
fastBuilding = 0,
description = "Tough zombie with a deadly machete"
},
[5] = {
name = "Shield Zombie",
health = 100,
speed = 0,
armor = 0,
weapon = {41}, -- shield
knockback = 7,
fastBuilding = 0,
description = "Zombie equipped with a shield for added protection"
},
[6] = {
name = "Glock Zombie",
health = 250,
speed = -4,
armor = 0,
weapon = {2}, -- glock pistol
knockback = 7,
fastBuilding = 0,
description = "Armed zombie with a pistol for ranged attacks"
},
[7] = {
name = "Builder Zombie",
health = 100, -- very low health
speed = 0,
armor = 0,
weapon = {74}, -- wrench
knockback = 7,
fastBuilding = 0,
description = "Zombie that constructs defense using a wrench"
},
[8] = {
name = "Chainsaw Zombie",
health = 250,
speed = 0,
armor = 0,
weapon = {85}, -- chainsaw
knockback = 7,
fastBuilding = 0,
description = "Basic zombie with normal health and speed"
}
}
addhook("serveraction","_serveraction")
function _serveraction(id,action)
if action == 1 then
menu(id,"Main Menu,Choose Class|(Humans),Choose Class|(Zombies)")
end
end
addhook("menu","_menu")
function _menu(id,title,button)
if title == "Main Menu" then
if button == 2 then
local zombieMenuOptions = "Zombies Classes"
for i, zombieClass in ipairs(zombieClassList) do
zombieMenuOptions = zombieMenuOptions .. "," .. zombieClass.name
end
menu(id, zombieMenuOptions)
end
end
if title == "Zombies Classes" then
_zombiesMenu(id,title,button)
end
end
function _zombiesMenu(id,title,button)
if button > 0 then
local class = zombieClassList[button]
if fixZombieClassID[id] == button then
errorMessage[id] = "You are already "..class.name.."!"
_errorMessage(id)
else
fixZombieClassID[id] = button
serverMessage[id] = "Your new class is "..class.name.."."
_serverMessage(id)
end
end
end
Note that the table only contain 8 classes, I didn't add more because I couldn't figure out how to do that.
If anyone could provide an example of how this works, it would help me understand the concept better. Thanks.