Show the mistake! Please!
2 replies



22.02.20 02:52:09 pm
I want to use this to equip my players, but nothing comes out ... A message appears in the console:
Attempt to index field "select" (a function value)
Error on line 12! Thanks in advance!
Attempt to index field "select" (a function value)
Error on line 12! Thanks in advance!
Code:
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
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
if usebutton==nil then usebutton={} end
usebutton.select={}
addhook("usebutton","usebutton.select")
function usebutton.select(id)
if (x==3)and(y==1) then
menu(id,"SelectEquipment,LightArmor|25%,MediumArmor|50%,M4A1|Rifle")
end
end
addhook("menu","usebutton.select.menu")
function usebutton.select.menu(id,menu,sel)
if (menu=="SelectEquipment") then
if (sel>=0 and sel<=3) then
usebutton.select[id]=sel
end
end
end
addhook("spawn","usebutton.select.equip")
function usebutton.select.equip(id)
if (usebutton.select.equip[id]==1) then
parse ("speedmod "..id.." 0")
parse ("equip "..id.." 79")
msg(player(id,"name").."LightArmor")
end
if (usebutton.select.equip[id]==2) then
parse ("speedmod "..id.." -5")
parse ("equip "..id.." 80")
msg(player(id,"name").."MediumArmor")
end
if (usebutton.select.equip[id]==3) then
parse ("equip "..id.." 32")
msg(player(id,"name").."M4A1")
end
end
usebutton.select={}
addhook("usebutton","usebutton.select")
function usebutton.select(id)
if (x==3)and(y==1) then
menu(id,"SelectEquipment,LightArmor|25%,MediumArmor|50%,M4A1|Rifle")
end
end
addhook("menu","usebutton.select.menu")
function usebutton.select.menu(id,menu,sel)
if (menu=="SelectEquipment") then
if (sel>=0 and sel<=3) then
usebutton.select[id]=sel
end
end
end
addhook("spawn","usebutton.select.equip")
function usebutton.select.equip(id)
if (usebutton.select.equip[id]==1) then
parse ("speedmod "..id.." 0")
parse ("equip "..id.." 79")
msg(player(id,"name").."LightArmor")
end
if (usebutton.select.equip[id]==2) then
parse ("speedmod "..id.." -5")
parse ("equip "..id.." 80")
msg(player(id,"name").."MediumArmor")
end
if (usebutton.select.equip[id]==3) then
parse ("equip "..id.." 32")
msg(player(id,"name").."M4A1")
end
end
edited 1×, last 22.02.20 03:31:58 pm
Akseonow
Once your usebutton.select is a table (line 2) and then you want to declare it as a function (line 4).
Therefore usebutton.select is not a table anymore (suggested by the error)
Rename your function to something else (similar to your other functions) or rename your table.
Therefore usebutton.select is not a table anymore (suggested by the error)
Rename your function to something else (similar to your other functions) or rename your table.
Share time limited free games here

BowLingHead, it seems in general you solved my problem! Thanks!
edited 1×, last 22.02.20 03:58:16 pm
Akseonow



