Forum

> > CS2D > Scripts > Inventory Lua script doesnt work
Forums overviewCS2D overview Scripts overviewLog in to reply

English Inventory Lua script doesnt work

2 replies
To the start Previous 1 Next To the start

old Inventory Lua script doesnt work

XeniTh
User Off Offline

Quote
Hello.. just wanted to make a script. all works fine. the whole menu and all menu buttons... but when i go to "buy items"
and choose something, it wont buy me the thing i have chosen. im stuck here, and it doesnt give me a error in console
please help... i really need help cause i was trying to fix the error, i looked at the samples and lua.org too. and doesnt work again..
here is the script
Spoiler >


and im stuck here:

Spoiler >

old Re: Inventory Lua script doesnt work

EngiN33R
Moderator Off Offline

Quote
What the hell is that 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
--Hooks:
addhook("serveraction","Inventoryserveraction")
addhook("menu","Inventorymenu")

--Functions:
function Inventoryserveraction(id,action)
	if action == 1 then
		menu(id,"Inventory,Check Inventory,Buy items")
    end
end

function Inventorymenu(id,m,s)
	if (m=="Inventory") then
		if (s == 1) then
			menu(id,"Check inventory,Radar")
		elseif (s == 2) then
			menu(id,"Buy items,Medisuit,Ring of Hp,Speed cola,Air Strike")
		end
	end
	if (m=="Buy items") then
		if (s == 1) then
			if player(id, "money")>=2000 then
				parse("setmoney "..id.." "..player(id, "money")-2000)
				parse("equip "..id.." 82")
				msg2(id,"Medisuit lasts only one life!")
			else
				msg2(id,"You dont have enough money!")
			end
		end
		if (s == 2) then
			if player(id, "money")>=6000 then
				parse("setmoney "..id.." "..player(id, "money")-6000)
				parse("setmaxhealth "..id.." 150")
			else
				msg2(id,"You dont have enough money!")
			end
		end
		if (s == 3) then
			if player(id, "money")>=2700 then
				parse("setmoney "..id.." "..player(id, "money")-2700)
				parse("speedmod "..id.." 35")
				msg2(id,"Speed cola lasts only one life!")
			else
				msg2(id,"You dont have enough money!")
			end
		end
		if (s == 4) then
			if player(id, "money")>=6000 then
				parse("setmoney "..id.." "..player(id, "money")-6000)
				parse("equip "..id.." 76")
			else
				msg2(id,"You dont have enough money!")
			end
		end
	end
end

1. To check selections in a menu, you must check if the menu is the one you're checking the selections in.
2. Ends close stuff right after them and not in the very end.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview