Forum

> > CS2D > Scripts > Show the mistake! Please!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Show the mistake! Please!

2 replies
To the start Previous 1 Next To the start

old Show the mistake! Please!

lAksl
User Off Offline

Quote
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!

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
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
edited 1×, last 22.02.20 03:31:58 pm

old Re: Show the mistake! Please!

Bowlinghead
User Off Offline

Quote
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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview