I need help again

The speed item funktion doesn't work.
If i make a item:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
[408] = { name = "Wings V3[60]", r = 255, g = 255, b = 255, action = "ride", slot = 7, ground = true, water = true, fimage = "gfx/weiwen/fallenangelwings.png", eimage = "gfx/weiwen/fallenangelwings.png", speed = 75, <--- This don't work :/ level = 60, func = equip, },
Idk why this doesn't work
Here my funktion.lua(EQUIP)
Spoiler 

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
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
function eat(id, itemslot, itemid, equip) radiusmsg("©255000000" .. player(id,"name") .. " eats " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. ".", player(id,"x"), player(id,"y"), 384) local health = player(id, "health") + ITEMS[itemid].food() parse("sethealth " .. id .. " " .. health) PLAYERS[id].HP = health destroyitem(id, itemslot) end function explosion(x, y, size, damage, id) for _, m in ipairs(MONSTERS) do if math.sqrt((m.x-player(id,'x'))^2+(m.y-player(id,'y'))^2) <= size then m:damage(id, math.floor(damage*math.random(60,140)/100), 251) end end parse("explosion " .. x .. " " .. y .. " " .. size .. " " .. damage .. " " .. id) end function equip(id, itemslot, itemid, equip) local index = equip and "Equipment" or "Inventory" local previtems, newitems = {}, {} if equip then if not additem(id, itemid) then return end previtems[itemslot] = PLAYERS[id].Equipment[itemslot] or 0 PLAYERS[id].Equipment[itemslot] = nil newitems[itemslot] = 0 else if ITEMS[itemid].level and PLAYERS[id].Level < ITEMS[itemid].level then message(id, "You need to be level " .. ITEMS[itemid].level .. " or above to equip it.", "255000000") return end newitems[ITEMS[itemid].slot] = itemid if ITEMS[itemid].slot == 4 then if PLAYERS[id].Equipment[3] then if ITEMS[PLAYERS[id].Equipment[3]].twohand then if not additem(id, PLAYERS[id].Equipment[3]) then return end previtems[3] = PLAYERS[id].Equipment[3] or 0 PLAYERS[id].Equipment[3] = nil newitems[3] = 0 end end elseif ITEMS[itemid].slot == 3 then if ITEMS[itemid].twohand then if PLAYERS[id].Equipment[4] then if not additem(id, PLAYERS[id].Equipment[4]) then return end previtems[4] = PLAYERS[id].Equipment[4] or 0 PLAYERS[id].Equipment[4] = nil newitems[4] = 0 end end end destroyitem(id, itemslot) if PLAYERS[id].Equipment[ITEMS[itemid].slot] then previtems[ITEMS[itemid].slot] = PLAYERS[id].Equipment[ITEMS[itemid].slot] additem(id, PLAYERS[id].Equipment[ITEMS[itemid].slot]) else previtems[ITEMS[itemid].slot] = 0 end PLAYERS[id].Equipment[ITEMS[itemid].slot] = itemid end updateEQ(id, newitems, previtems) end function updateEQ(id, newitems, previtems) if not previtems then previtems = {} end if not newitems then return end parse("equip " .. id .. " 50;setweapon " .. id .. " 50") local hp, spd, atk, def = 0, 0, 0, 0 local equip, strip = playerweapons(id), {50, 41} for i, v in pairs(newitems) do if previtems[i] then if PLAYERS[id].tmp.equip[i].image then freeimage(PLAYERS[id].tmp.equip[i].image) PLAYERS[id].tmp.equip[i].image = nil end if PLAYERS[id].tmp.equip[i].equip then parse("strip " .. id .. " " .. PLAYERS[id].tmp.equip[i].equip) table.insert(strip, PLAYERS[id].tmp.equip[i].equip) PLAYERS[id].tmp.equip[i].equip = nil end if ITEMS[previtems[i]].hp then hp=hp-ITEMS[previtems[i]].hp end if ITEMS[previtems[i]].speed then spd=spd-ITEMS[previtems[i]].speed end if ITEMS[previtems[i]].atk then atk=atk-ITEMS[previtems[i]].atk end if ITEMS[previtems[i]].def then def=def-ITEMS[previtems[i]].def end end if newitems[i] ~= 0 then if ITEMS[newitems[i]].hp then hp=hp+ITEMS[newitems[i]].hp end if ITEMS[newitems[i]].speed then spd=spd+ITEMS[newitems[i]].speed end if ITEMS[newitems[i]].atk then atk=atk+ITEMS[newitems[i]].atk end if ITEMS[newitems[i]].def then def=def+ITEMS[newitems[i]].def end if ITEMS[newitems[i]].equip then PLAYERS[id].tmp.equip[i].equip = ITEMS[newitems[i]].equip parse("equip " .. id .. " " .. ITEMS[newitems[i]].equip) table.insert(equip, ITEMS[newitems[i]].equip) end if ITEMS[newitems[i]].eimage then if not PLAYERS[id].tmp.equip[i].image then PLAYERS[id].tmp.equip[i].image = image(ITEMS[newitems[i]].eimage, ITEMS[newitems[i]].static and 0 or 1, 0, (ITEMS[newitems[i]].ground and 100 or 200)+id) if ITEMS[newitems[i]].r then imagecolor(PLAYERS[id].tmp.equip[i].image, ITEMS[newitems[i]].r, ITEMS[newitems[i]].g, ITEMS[newitems[i]].b) end local scalex, scaley = ITEMS[newitems[i]].escalex or 1, ITEMS[newitems[i]].escaley or 1 scalex = scalex * -1 imagescale(PLAYERS[id].tmp.equip[i].image, scalex, scaley) if ITEMS[newitems[i]].blend then imageblend(PLAYERS[id].tmp.equip[i].image, ITEMS[newitems[i]].blend) end end end end end for i, v in ipairs(equip) do if not inarray(strip, v) then parse("setweapon " .. id .. " " .. v .. ";strip " .. id .. " 50") end end PLAYERS[id].tmp.atk = PLAYERS[id].tmp.atk+atk PLAYERS[id].tmp.def = PLAYERS[id].tmp.def+def PLAYERS[id].tmp.spd = PLAYERS[id].tmp.spd+spd PLAYERS[id].tmp.hp = PLAYERS[id].tmp.hp+hp parse("setmaxhealth " .. id .. " " .. PLAYERS[id].tmp.hp .. "; speedmod " .. id .. " " .. PLAYERS[id].tmp.spd .. "; sethealth " .. id .. " " .. player(id, "health")) end
funktion.lua (ITEMS)
Spoiler 

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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
function clearinventory(id, slot) if slot then table.remove(PLAYERS[id].Inventory, slot) else PLAYERS[id].Inventory = {} end return true end function itemcount(id, itemid) local amount, items = 0, {} for k, v in ipairs(PLAYERS[id].Inventory) do if v == itemid then amount = amount + 1 table.insert(items, k) end end return amount, items end function additem(id, itemid, amount, tell) if not ITEMS[itemid] or itemid == 0 then return false end amount = amount and math.floor(amount) or 1 if amount == 1 then if #PLAYERS[id].Inventory < CONFIG.MAXITEMS then table.insert(PLAYERS[id].Inventory, itemid) if tell then message(id, "©255000000You have received " .. fullname(itemid) .. ".") end return true end return false else local added = 0 while #PLAYERS[id].Inventory < CONFIG.MAXITEMS and added < amount do table.insert(PLAYERS[id].Inventory, itemid) added = added + 1 end local remaining = amount - added local dropped = 0 while dropped < remaining do spawnitem(itemid, PLAYERS[id].x, PLAYERS[id].y) dropped = dropped + 1 end if tell then if remaining == 0 then message(id, "©255000000You have received " .. fullname(itemid, added) .. ".") else message(id, "©255000000You have received " .. fullname(itemid, added) .. ". " .. remaining .. " are dropped due to lack of space.") end end return true end end function removeitem(id, itemid, amount, tell) if not ITEMS[itemid] or itemid == 0 then return false end amount = amount and math.floor(amount) or 1 local removed = 0 local removed = 0 local has, toremove = itemcount(id, itemid) if has >= amount then for k, v in ipairs(toremove) do if removed < amount then table.remove(PLAYERS[id].Inventory, v+1-k) removed = removed + 1 end if removed == amount then if tell then message(id, "©255000000You have lost " .. fullname(itemid, amount) .. ".") end return true end end end return false end function destroyitem(id, itemslot, equip) if equip then PLAYERS[id].Equipment[itemslot] = nil else table.remove(PLAYERS[id].Inventory, itemslot) end return true end function spawnitem(itemid, x, y, amount) if not ITEMS[itemid] then return false end local ground = GROUNDITEMS[y][x] local tile = gettile(x, y) local height = #ground+1 local x = ITEMS[itemid].offsetx and x*32+16+ITEMS[itemid].offsetx or x*32+16 local y = ITEMS[itemid].offsety and y*32+16+ITEMS[itemid].offsety or y*32+16 local heightoffset = math.min(height-1, 10)*3 local item = {itemid} if itemid == 1337 then --[[ alternate money item[2] = image("gfx/weiwen/money.png", 0, 0, height > 3 and 1 or 0) item[3] = amount if amount > 9999 then imagecolor(item[2], 255, 255, 0) elseif amount > 999 then imagecolor(item[2], 255, 85, 0) elseif amount > 99 then imagecolor(item[2], 0, 128, 255) else imagecolor(item[2], 0, 150, 0) end ]] item[3] = amount if amount < 5 then item[2] = image("gfx/weiwen/money/1.png", 0, 0, height > 3 and 1 or 0) elseif amount < 10 then item[2] = image("gfx/weiwen/money/2.png", 0, 0, height > 3 and 1 or 0) elseif amount < 20 then item[2] = image("gfx/weiwen/money/3.png", 0, 0, height > 3 and 1 or 0) elseif amount < 100 then item[2] = image("gfx/weiwen/money/4.png", 0, 0, height > 3 and 1 or 0) elseif amount < 500 then item[2] = image("gfx/weiwen/money/5.png", 0, 0, height > 3 and 1 or 0) elseif amount < 1000 then item[2] = image("gfx/weiwen/money/6.png", 0, 0, height > 3 and 1 or 0) elseif amount < 5000 then item[2] = image("gfx/weiwen/money/7.png", 0, 0, height > 3 and 1 or 0) elseif amount < 10000 then item[2] = image("gfx/weiwen/money/8.png", 0, 0, height > 3 and 1 or 0) elseif amount < 20000 then item[2] = image("gfx/weiwen/money/9.png", 0, 0, height > 3 and 1 or 0) else item[2] = image("gfx/weiwen/money/10.png", 0, 0, height > 3 and 1 or 0) end else item[2] = image(ITEMS[itemid].fimage or "gfx/weiwen/circle.png", 0, 0, height > 3 and 1 or 0) if ITEMS[itemid].r then imagecolor(item[2], ITEMS[itemid].r, ITEMS[itemid].g, ITEMS[itemid].b) end if ITEMS[itemid].heal then tile.HEAL = (tile.HEAL or 0) + ITEMS[itemid].heal end end imagepos(item[2], x - heightoffset, y - heightoffset, ITEMS[itemid].rot or 0) local scalex, scaley = ITEMS[itemid].fscalex or 1, ITEMS[itemid].fscaley or 1 local magnification = math.min(height, 10)/20+0.95 imagescale(item[2], scalex*magnification, scaley*magnification) ground[height] = item return true end function pickitem(id) local ground = GROUNDITEMS[PLAYERS[id].y][PLAYERS[id].x] local height = #ground if height > 0 then local item = ground[height] if item[1] == 1337 then freeimage(item[2]) addmoney(id, item[3]) message(id, "You have picked up $" .. item[3] .. ".", "255000000") GROUNDITEMS[PLAYERS[id].y][PLAYERS[id].x][height] = nil elseif additem(id, item[1]) then local tile = gettile(PLAYERS[id].x, PLAYERS[id].y) if tile.HEAL and ITEMS[item[1]].heal then tile.HEAL = tile.HEAL - ITEMS[item[1]].heal if tile.HEAL == 0 then tile.HEAL = nil end end freeimage(item[2]) message(id, "You have picked up " .. fullname(item[1]) .. ".", "255000000") GROUNDITEMS[PLAYERS[id].y][PLAYERS[id].x][height] = nil end end return true end function dropitem(id, itemslot, equip) local removed = false local inv = (equip and PLAYERS[id].Equipment or PLAYERS[id].Inventory) if spawnitem(inv[itemslot], PLAYERS[id].x, PLAYERS[id].y) then message(id, "You have dropped " .. fullname(inv[itemslot]) .. ".", "255000000", "255000000") if equip then updateEQ(id, {[itemslot] = 0}, {[itemslot] = inv[itemslot]}) inv[itemslot] = nil else table.remove(inv, itemslot) end else message(id, "You may not drop something here.", "255000000", "255000000") end end function fullname(itemid, amount) if not amount or amount == 1 then return ITEMS[itemid].article .. " " .. ITEMS[itemid].name else return amount .. " " .. ITEMS[itemid].plural end end function inventory(id, page) page = page or 0 local text = "Inventory" .. string.rep(" ", page) .. "," for i = page*5+1, (page+1)*5 do local name if ITEMS[PLAYERS[id].Inventory[i]] then name = ITEMS[PLAYERS[id].Inventory[i]].name else name = PLAYERS[id].Inventory[i] or "" end text = text .. name .. "|" .. i .. "," end text = text .. ',,Prev Page,Next Page|Page ' .. page+1 menu(id, text) end function equipment(id) local text = "Equipment" for i, v in ipairs(CONFIG.SLOTS) do text = text .. "," .. (ITEMS[PLAYERS[id].Equipment[i] or 0].name or ("ITEM ID " .. PLAYERS[id].Equipment[i])) .. "|" .. v end menu(id, text) end function itemactions(id, itemslot, equip) local itemid local text = (equip and "Equip" or "Item") .. " Actions" .. string.rep(" ", itemslot-1) .. "," if equip then itemid = PLAYERS[id].Equipment[itemslot] or 0 else itemid = PLAYERS[id].Inventory[itemslot] or 0 end for i, v in ipairs(ITEMS[itemid].action) do text = text .. v .. "," end text = text .. string.rep(",", 7-#ITEMS[itemid].action) .. "Examine,Drop" menu(id, text) end