Forum

> > CS2D > Scripts > Show the mistake! Please!
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Show the mistake! Please!

2 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Show the mistake! Please!

lAksl
User Off Offline

Zitieren
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
1× editiert, zuletzt 22.02.20 15:31:58

alt Re: Show the mistake! Please!

Bowlinghead
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht