Forum

> > CS2D > Scripts > Whats Wrong with my Lua?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Whats Wrong with my Lua?

2 replies
To the start Previous 1 Next To the start

old Whats Wrong with my Lua?

Hunter162
User Off Offline

Quote
Pls i donno whats wrong with this script
i wanna make 1 working script
i compared my script with other classes script and i find not much difference

i press F2 alot of times but menu wont pop up

pls tell me whats the problem
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
-------------------------------------------------------------
-------  Class   Fight   Script  Made   By  ---------------
-----------------   Hunter162  -----------------------------
--------------------------------------------------------------

if sample==nil then sample={} end
sample.classes={}


-- INITIAL SETUP
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=y
	end
	return array
end
sample.classes.class=initArray(32)
function sample.classes.classmenu(id)
          menu(id,"Class Menu,Soldier|Machinegun,Defender|Shield,Pyro|Flamethrower,Spy|Stealth,Enginer|Wrench,Equipment Master|All Equipments")
     end
end



-- TEAM -> CLASS
addhook("team","sample.classes.team")
function sample.classes.team(id,team)
	if (team>0) then
		sample.classes.classmenu(id)
	end
end


-- SERVERACTION
addhook("serveraction","sample.classes.serveraction")
function sample.classes.serveraction(id)
	sample.classes.classmenu(id)
end



-- CLASS SELECTION
addhook("menu","sample.classes.menu")
function sample.classes.menu(id,menu,sel)
	if (menu=="Select your Class") then
		if (sel>=0 and sel<=9) then
			sample.classes.class[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	end
end


-- SPAWN
addhook("spawn","sample.classes.spawn")
function sample.classes.spawn(id)
	-- Soldier
	if (sample.classes.class[id]<=1) then
                parse("equip "..id.." 40)
                parse("equip "..id.." 81)
                parse("equip "..id.." 76)
                parse("equip "..id.." 5)
                parse("equip "..id.." 85)                
                parse("setmaxhealth "..id.." 250)
                parse ("speedmod "..id.." 1")
        end
        -- Defender
	if (scriptclassmenu[id]==2) then
                parse("equip "..id.." 41)
                parse("equip "..id.." 83)
                parse("equip "..id.." 3)
                parse("equip "..id.." 85)
                parse ("speedmod "..id.." 1")
                parse ("setmaxhealth "..id.." 100")
        end
        -- Pyro
	if (scriptclassmenu[id]==3) then
                parse("equip "..id.." 46)
                parse("equip "..id.." 4)
                parse("equip "..id.." 69)
                parse("equip "..id.." 82)
                parse("equip "..id.." 73)
                parse ("speedmod "..id.." 1")
                parse ("setmaxhealth "..id.." 100")
        end
        -- Spy
	if (scriptclassmenu[id]==4) then
                parse("equip "..id.." 45)
                parse("equip "..id.." 84)
                parse("equip "..id.." 6)
                parse("equip "..id.." 69)
                parse("equip "..id.." 77)
                parse("equip "..id.." 87)
                parse("speedmod "..id.." 100)
                parse ("setmaxhealth "..id.." 100")
        end
        -- Enginer
	if (scriptclassmenu[id]==5) then
                parse("equip "..id.." 74)
                parse("setmaxhealth "..id.." 250)
                parse("setarmor "..id.." 250)
                parse("equip "..id.." 10)
                parse("equip "..id.." 11)
                parse("speedmod "..id.." 40)
                parse("equip "..id.." 5)
        end
        -- Equipment Master
	if (scriptclassmenu[id]==6) then
                parse("equip "..id.." 88)
                parse("equip "..id.." 69)
                parse("equip "..id.." 85)
                parse("equip "..id.." 78)
                parse("equip "..id.." 51)
                parse("equip "..id.." 52)
                parse("equip "..id.." 53)
                parse("equip "..id.." 54)
                parse("equip "..id.." 55)
                parse("equip "..id.." 56)
                parse("equip "..id.." 58)
                parse("equip "..id.." 59)
                parse("equip "..id.." 72)
                parse("equip "..id.." 73)
                parse("equip "..id.." 75)
                parse("equip "..id.." 76)
                parse("equip "..id.." 77)
                parse("equip "..id.." 86)
                parse("equip "..id.." 87)
                parse ("speedmod "..id.." 1")
                parse ("setmaxhealth "..id.." 100")
	end
end




-- NO BUYING
addhook("buy","sample.classes.buy")
function sample.classes.buy()
	return 1
end


-- NO COLLECTING
addhook("walkover","sample.classes.walkover")
function sample.classes.walkover(id,iid,type)
	if (type>=61 and type<=68) then
		return 0
	end
	return 1
end


-- NO DROPPING
addhook("drop","sample.classes.drop")
function sample.classes.drop()
	return 1
end


-- NO DEAD DROPPING
addhook("die","sample.classes.die")
function sample.classes.die()
	return 1
end
edited 1×, last 01.02.11 10:45:58 am

old Re: Whats Wrong with my Lua?

Ridho
User Off Offline

Quote
Maybe in

-- SPAWN
addhook("spawn","sample.classes.spawn")
function sample.classes.spawn(id)
-- Soldier
if (sample.classes.class[id]<=1) then
parse("equip "..id.." 40)
parse("equip "..id.." 81)
parse("equip "..id.." 76)
parse("equip "..id.." 5)
parse("equip "..id.." 85)
parse("setmaxhealth "..id.." 250)
parse ("speedmod "..id.." 1")
end
-- Defender
if (scriptclassmenu[id]==2) then
parse("equip "..id.." 41)
parse("equip "..id.." 83)
parse("equip "..id.." 3)
parse("equip "..id.." 85)
parse ("speedmod "..id.." 1")
parse ("setmaxhealth "..id.." 100")
end
-- Pyro
if (scriptclassmenu[id]==3) then
parse("equip "..id.." 46)
parse("equip "..id.." 4)
parse("equip "..id.." 69)
parse("equip "..id.." 82)
parse("equip "..id.." 73)
parse ("speedmod "..id.." 1")
parse ("setmaxhealth "..id.." 100")
end

old Re: Whats Wrong with my Lua?

DannyDeth
User Off Offline

Quote
It's your menu calling fail, here is a correction I do believe will work:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- SERVERACTION
addhook("serveraction","sample.classes.serveraction")
function sample.classes.serveraction(id)
     menu(id,"Select your class,ENTER_UR_CLASSES_HERE,WITH_COMMAS_INBETWEEN"
end



-- CLASS SELECTION
addhook("menu","sample.classes.menu")
function sample.classes.menu(id,menu,sel)
     if (menu=="Select your Class") then
          sample.classes.class[id]=button
          if (player(id,"health")>0) then
               parse("killplayer "..id)
          end
     end
end

You called the function which was made to handle what happens after each button is pressed!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview