Forum

> > CS2D > Scripts > need menu shop humain/zombie
Forums overviewCS2D overview Scripts overviewLog in to reply

English need menu shop humain/zombie

4 replies
To the start Previous 1 Next To the start

old need menu shop humain/zombie

thesk5tera
User Off Offline

Quote
function table.find(tab,value)
for i = 1, #tab do
if tab[i] == value then
return true
end
end
end

function table.find(t,v)
for _k,_v in pairs(t) do
if _v == v then
return _k
end
end
end

function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
ammos=initArray(32)

addhook("ms100","save_hud")
function save_hud()
for id = 1,32 do
          if (player(id,"exists")) then
                    parse('hudtxt2 '..id..' 47 "Ammo: '..ammos[id]..' " 60 395')
               end
          end
end

addhook("kill","_kill")
function _kill(id,victim,killer)
     if ammos[id] <= 100 then
          ammos[id] = ammos[id] + 10
     elseif ammos[id] >= 100 then
          ammos[id] = ammos[id] + 0
     end
end

addhook("serveraction","_serveraction")
function _serveraction(id,action)
     if action == 1 then
          if (team == 2) then
          menu(id,"Humain Shop,Laser Mine| 10ammos,Mine| 10ammos,Satchel charger| 20ammos,,Armor| 20ammos,Heavy Armor| 30ammos,FnF2000| 30ammos,SG-552| 15 ammos")
          end
     end
end

addhook("menu","menuuus")
function menuuus(id,title,button)
     if title == "Humain Shop" then
          if button == 1 then
               if ammos[id] >= 10 then
                    if table.find(playerweapons(id),87) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 87")
                         msg2(id,"©000255000You bought Laser Mine!")
                         ammos[id] = ammos[id] - 10
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 2 then
               if ammos[id] >= 10 then
                    if table.find(playerweapons(id),77) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 77")
                         msg2(id,"©000255000You bought Mine!")
                         ammos[id] = ammos[id] - 10
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 3 then
               if ammos[id] >= 20 then
                    if table.find(playerweapons(id),89) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 89")
                         msg2(id,"©000255000You bought Shatchel Charger!")
                         ammos[id] = ammos[id] - 20
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 5 then
               if ammos[id] >= 20 then
                    if table.find(playerweapons(id),80) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 80")
                         msg2(id,"©000255000You bought Armor!")
                         ammos[id] = ammos[id] - 20
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 6 then
               if ammos[id] >= 30 then
                    if table.find(playerweapons(id),81) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 81")
                         msg2(id,"©000255000You bought Heavy Armor!")
                         ammos[id] = ammos[id] - 30
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 7 then
               if ammos[id] >= 30 then
                    if table.find(playerweapons(id),91) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 91")
                         msg2(id,"©000255000You bought FnF2000!")
                         ammos[id] = ammos[id] - 30
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 8 then
               if ammos[id] >= 15 then
                    if table.find(playerweapons(id),31) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 31")
                         msg2(id,"©000255000You bought SG-552!")
                         ammos[id] = ammos[id] - 15
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          end
     end
end

addhook("serveraction","_serveraction")
function serveraction(id,action)
     if action == 1 then
          if (team == 1) then
               menu(id,"Zombie Shop,Chainsaw| 20ammos,Gas Grenade| 10 ammos,Molotov| 10 ammos")
          end
     end
end

addhook("menu","menuuus")
function menuuus(id,title,button)
     if title == "Zombie Shop" then
          if button == 1 then
               if ammos[id] >= 20 then
                    if table.find(playerweapons(id),85) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 85")
                         msg2(id,"©000255000You bought Chainsaw!")
                         ammos[id] = ammos[id] - 20
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 2 then
               if ammos[id] >= 10 then
                    if table.find(playerweapons(id),72) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 72")
                         msg2(id,"©000255000You bought Gas Grenade!")
                         ammos[id] = ammos[id] - 10
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          elseif button == 3 then
               if ammos[id] >= 10 then
                    if table.find(playerweapons(id),73) then
                         msg2(id,"©255000000You already own this item!")
                    else
                         parse("equip "..id.." 73")
                         msg2(id,"©000255000You bought Molotov!")
                         ammos[id] = ammos[id] - 10
                    end
               else
                    msg2(id,"©255000000You don't have enough ammos!")
               end
          end
     end
end




not work i need if team humain shop /and zombie shop in menu

old Re: need menu shop humain/zombie

Rainoth
Moderator Off Offline

Quote
1. Tab your code
2. use code tags for your code
3. I don't know if this is just spelling fail or it's in your language but it writes as "Human" not "Humain"
4. Your team check is bad :
Yours
1
if (team==2) then
How it should be
1
if player(id,"team")==2 then

old Re: need menu shop humain/zombie

Rainoth
Moderator Off Offline

Quote
It's really easy to understand what's wrong when you tell me "Doesn't work" --"

Could you paste whole script in "more" and "code" tags and provide the error with it's line ?

old Re: need menu shop humain/zombie

thesk5tera
User Off Offline

Quote
ok this is my script
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
dofile("sys/lua/mapvote.lua")





function table.find(tab,value)
    for i = 1, #tab do
        if tab[i] == value then
            return true
        end
    end
end

function table.find(t,v)
     for _k,_v in pairs(t) do
          if _v == v then
               return _k
          end
     end
end

function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
ammos=initArray(32)

addhook("ms100","save_hud")
function save_hud()
     for id = 1,32 do
		if (player(id,"exists")) then
				parse('hudtxt2 '..id..' 47 "Ammo: '..ammos[id]..' " 65 420')
			end
		end
end


if pbs==nil then pbs={} end

--// CFG

HUD = {
     ["USGN"] = {x = 65, y = 365, a = 0}
}

function hudtxt2(player,id,text,x,y,align)
     parse('hudtxt2 '..player..' '..id..' "'..text..'" '..x..' '..y..' '..align)
end

function CheckUSGNStatus(id)
     local USGN = player(id,"usgn")
     if USGN ~= 0 then
          return USGN, (string.char(169)..'005116250')
     else
          return "Not Logged!", (string.char(169)..'255025000')
     end
end

addhook("second","pbs.second")
function pbs.second()
     local playerlist=player(0,"table")
     for _, id in pairs(playerlist) do
          local STATUS, KULAY = CheckUSGNStatus(id)
          hudtxt2(id, 10, (string.char(169)..(116255005).."Login as: "..KULAY..""..STATUS),HUD["USGN"].x, HUD["USGN"].y, HUD["USGN"].a)
     end
end

addhook("kill","_kill")
function _kill(id,victim,killer)
	if ammos[id] <= 100 then
		ammos[id] = ammos[id] + 10
	elseif ammos[id] >= 100 then
		ammos[id] = ammos[id] + 0
	end
end

parse('mp_building_limit "turret" 7')
parse('mp_building_limit "barricade" 50')
parse('mp_building_limit "barbed wire" 50')
parse('mp_building_limit "wall I" 100')
parse('mp_building_limit "wall II" 50')
parse('mp_building_limit "wall III" 30')
parse('mp_building_limit "gate field" 20')
parse('mp_building_limit "dispenser" 5')
parse('mp_building_limit "supply" 10')
parse('mp_building_limit "teleporter entrance" 10')
parse('mp_building_limit "teleporter exit" 10')
parse('mp_wpndmg "Gut Bomb" 100')
parse('mp_dispenser_money 16000')
parse('mp_building_price "turret" 0')
parse('mp_building_price "barricade" 0')
parse('mp_building_price "barbed wire" 0')
parse('mp_building_price "wall I" 0')
parse('mp_building_price "wall II" 0')
parse('mp_building_price "wall III" 0')
parse('mp_building_price "gate field" 0')
parse('mp_building_price "dispenser" 0')
parse('mp_building_price "supply" 0')
parse('mp_building_price "teleporter entrance" 0')
parse('mp_building_price "teleporter exit" 0')


HUDImage = image('gfx/thesk5tera/status.png', 120, 400, 2)
--imagescale(HUDImage, 130,28)
imagealpha(HUDImage, 0.7)

addhook("startround","sta")
function sta()
HUDImage = image('gfx/thesk5tera/status.png', 120, 400, 2)
--imagescale(HUDImage, 130,28)
imagealpha(HUDImage, 0.7)
end

addhook("build","nosite")
function nosite(id,type)
	if (type == 21) then
		return 0
	else
		return 1
	end
end

addhook("build","havesite")
function havesite(id,type,x,y)
	if (type == 21) then
		return 0
	else
		parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
	end
end


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

sample.spawnequip.itemlist="74";

--------------------------------------
-- SPAWN                            --
--------------------------------------
addhook("spawn","sample.spawnequip.spawn")
function sample.spawnequip.spawn()
	return sample.spawnequip.itemlist;
end

addhook("serveraction","_serveraction")
function _serveraction(id,action)
	if action == 1 then
	if player(id,"team")==2 then
		menu(id,"Humain Shop,Laser Mine| 10ammos,Mine| 10ammos,Satchel charger| 20ammos,,Armor| 20ammos,Heavy Armor| 30ammos,FnF2000| 30ammos,SG-552| 15 ammos")
		end
	end
end

addhook("menu","menuuus")
function menuuus(id,title,button)
	if title == "Humain Shop" then
		if button == 1 then
			if ammos[id] >= 10 then
				if table.find(playerweapons(id),87) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 87")
					msg2(id,"©000255000You bought Laser Mine!")
					ammos[id] = ammos[id] - 10
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 2 then
			if ammos[id] >= 10 then
				if table.find(playerweapons(id),77) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 77")
					msg2(id,"©000255000You bought Mine!")
					ammos[id] = ammos[id] - 10
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 3 then
			if ammos[id] >= 20 then
				if table.find(playerweapons(id),89) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 89")
					msg2(id,"©000255000You bought Shatchel Charger!")
					ammos[id] = ammos[id] - 20
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 5 then
			if ammos[id] >= 20 then
				if table.find(playerweapons(id),80) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 80")
					msg2(id,"©000255000You bought Armor!")
					ammos[id] = ammos[id] - 20
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 6 then
			if ammos[id] >= 30 then
				if table.find(playerweapons(id),81) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 81")
					msg2(id,"©000255000You bought Heavy Armor!")
					ammos[id] = ammos[id] - 30
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 7 then
			if ammos[id] >= 30 then
				if table.find(playerweapons(id),91) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 91")
					msg2(id,"©000255000You bought FnF2000!")
					ammos[id] = ammos[id] - 30
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 8 then
			if ammos[id] >= 15 then
				if table.find(playerweapons(id),31) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 31")
					msg2(id,"©000255000You bought SG-552!")
					ammos[id] = ammos[id] - 15
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		end
	end
end

addhook("serveraction","_serveraction")
function serveraction(id,action)
	if action == 1 then
		if player(id,"team")==1 then
			menu(id,"Zombie Shop,Chainsaw| 20ammos,Gas Grenade| 10 ammos,Molotov| 10 ammos")
		end
	end
end

addhook("menu","menuuus")
function menuuus(id,title,button)
	if title == "Zombie Shop" then
		if button == 1 then
			if ammos[id] >= 20 then
				if table.find(playerweapons(id),85) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 85")
					msg2(id,"©000255000You bought Chainsaw!")
					ammos[id] = ammos[id] - 20
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 2 then
			if ammos[id] >= 10 then
				if table.find(playerweapons(id),72) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 72")
					msg2(id,"©000255000You bought Gas Grenade!")
					ammos[id] = ammos[id] - 10
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		elseif button == 3 then
			if ammos[id] >= 10 then
				if table.find(playerweapons(id),73) then
					msg2(id,"©255000000You already own this item!")
				else
					parse("equip "..id.." 73")
					msg2(id,"©000255000You bought Molotov!")
					ammos[id] = ammos[id] - 10
				end
			else
				msg2(id,"©255000000You don't have enough ammos!")
			end
		end
	end
end

but not work
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview