Forum

> > CS2D > Scripts > If you press E then menu appears!
Forums overviewCS2D overview Scripts overviewLog in to reply

English If you press E then menu appears!

14 replies
To the start Previous 1 Next To the start

old If you press E then menu appears!

Obviously Exactly Myself
User Off Offline

Quote
Can one of you make me script of when you "use" or press E in a specific spot, a menu appears and I can put parses and stuff.

Just tell me where to put:
If X, put "mom"
If Y, put "dad"
For the menu title, put "children"
For items, put "son"
For items description (the gray text), put "daughter"
And just tell me where I'll put the parse commands like equip,sethealth,etc.
lol, I'm not making fun of those above.

Sorry for too many lua requests because I suck at lua but I know it a bit.

EDIT: Changed the title...
edited 1×, last 22.12.11 11:22:28 am

Admin/mod comment

do not use pointless more or spoiler tags please.. thanks. removed

old Re: If you press E then menu appears!

Obviously Exactly Myself
User Off Offline

Quote
I REPEAT:

Can one of you make me script of when you "use" or press E in a specific spot, a menu appears and I can put parses and stuff.

Just tell me where to put:
If X, put "mom"
If Y, put "dad"
For the menu title, put "children"
For items, put "son"
For items description (the gray text), put "daughter"
And just tell me where I'll put the parse commands like equip,sethealth,etc.
lol, I'm not making fun of those above.

Sorry for too many lua requests because I suck at lua but I know it a bit.

old This?

EP
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
dadx=1 --Tile X
momy=1 --Tile Y

addhook("use","son")
function son(id)
	if player(id,"tilex")==dadx and player(id,"tiley")==momy then
menu(id,"Grandmother,Grandfather,Mom,Son,Daughter,Dad")
end -- Close IF
end -- Close Function
Good luck.

old Re: If you press E then menu appears!

Obviously Exactly Myself
User Off Offline

Quote
I mean when you use E while standing on a spot, it will show up a menu, and I know how the menu appears but I don't know where to put the commands after pressing an item in the menu.

By spot I mean:
1
if player(id, 'tilex') == 42 and player(id, 'tiley') == 21 then

--EDIT--

I got this but it won't work
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
addhook('use','zj_use')
function zj_use(id,x,y)
	if player(id, 'tilex') == 42 and player(id, 'tiley') == 21 then
		menu(id,"Restaurant,Food (+10hp)|$10,Meat (Gut Bomb)|$10")
	elseif player(id, 'tilex') == 59 and player(id, 'tiley') == 143 then
		menu(id,"Buy Handgun,Pistol|$55,Deagle|$60")
	end
end

addhook("menu", "zj_buy")
function zj_buy(id,title,button)
	if (title=="Restaurant") then
		if button == 1 then
			if player(id, 'money') >= 10 then
				parse('sethealth '.. id ..' '.. (player(id, 'health') + 10))
				parse('setmoney '.. id ..' '.. (player(id, 'money') - 10))
				msg2(id,'You successfully bought food for $10!')
			else
				msg2(id,'You need at least $10 to buy food!')
			end
		elseif button == 2 then
			if player(id, 'money') >= 10 then
				parse('equip '..id..' 86')
				parse('setweapon '..id..' 86')
				parse('setmoney '.. id ..' '.. (player(id, 'money') - 10))
				msg2(id,'You successfully bought meat for $10!')
			else
				msg2(id,'You need at least $10 to buy meat!')
			end
	elseif (title=="Buy Handgun") then
		if button == 1 then
			if player(id, 'money') >= 55 then
				parse('equip '..id..' 6')
				parse('setweapon '..id..' 6')
				parse('setmoney '.. id ..' '.. (player(id, 'money') - 55))
				msg2(id,'You successfully bought this weapon for $55!')
			else
				msg2(id,'You need at least $55 to buy this weapon!')
			end
		elseif button == 2 then
			if player(id, 'money') >= 60 then
				parse('equip '..id..' 3')
				parse('setweapon '..id..' 3')
				parse('setmoney '.. id ..' '.. (player(id, 'money') - 60))
				msg2(id,'You successfully bought this weapon for $60!')
			else
				msg2(id,'You need at least $60 to buy this weapon!')
			end
		end
	end
end

LUA ERROR: maps/ZJ's City.lua:82: 'end' expected (to close 'function' at line 17) near '<eof>'
edited 3×, last 22.12.11 10:23:32 am

old E = MENU "Response"

Dovahkin
User Off Offline

Quote
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
addhook('use','zj_use')
function zj_use(id,x,y)
     if (x == 42 and y == 21) then
          menu(id,"Restaurant,Food (+10hp)|$10,Meat (Gut Bomb)|$10")
     if (x == 59 and  == 143) then
          menu(id,"Buy Handgun,Pistol|$55,Deagle|$60")
     end
end

addhook("menu", "zj_buy")
function zj_buy(id,title,button)
	if (title=="Restaurant") then
	if button == 1 then
		if player(id, 'money')>= 10 then
                    parse("sethealth ".. id .." ".. (player(id, "health|) + 10))
                    parse("setmoney ".. id .." ".. (player(id, "money") - 10))
                    msg2(id,'You successfully bought food for $10!')
               else
                    msg2(id,"You need at least $10 to buy food")
               end
	elseif button == 2 then
               if player(id, 'money') >= 10 then
                    parse('equip '..id..' 86')
                    parse('setweapon '..id..' 86')
                    parse('setmoney '.. id ..' '.. (player(id, 'money') - 10))
                    msg2(id,'You successfully bought meat for $10!')
               else
                    msg2(id,'You need at least $10 to buy meat!')
               end
	end

     	if(title=="Buy Handgun") then
          	if button == 1 then
               	if player(id, 'money') >= 55 then
                    parse('equip '..id..' 6')
                    parse('setweapon '..id..' 6')
                    parse('setmoney '.. id ..' '.. (player(id, 'money') - 55))
                    msg2(id,'You successfully bought this weapon for $55!')
               else
                    msg2(id,'You need at least $55 to buy this weapon!')
               end
		elseif button == 2 then
               		if player(id, 'money') >= 60 then
                    parse('equip '..id..' 3')
                    parse('setweapon '..id..' 3')
                    parse('setmoney '.. id ..' '.. (player(id, 'money') - 60))
                    msg2(id,'You successfully bought this weapon for $60!')
               else
                    msg2(id,'You need at least $60 to buy this weapon!')
			end
		end
	end
end


Try this i fixed alot of things :))

old LOL

Dovahkin
User Off Offline

Quote
Phew! I repeated it and so many errors! here its cool for now!

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
addhook("use","useme")
function useme(id,event,data,x,y)
	if (x == 42 and y == 21) then
		menu(id,"Restaurant,Food (+10hp)|$10,Meat (Gut Bomb)|$10")
	elseif (x == 59 and y == 143) then
		menu(id,"Buy Handgun,Pistol|$55,Deagle|$60")
	end
end

addhook("menu", "zj_buy")
	function zj_buy(id,title,button)
	if title == "Restaurant" then
		if button == 1 then
         		if player(id, 'money')>= 10 then
			parse("sethealth ".. id .." ".. (player(id, "health") + 10))
			parse("setmoney ".. id .." ".. (player(id, "money") - 10))
			msg2(id,'You successfully bought food for $10!')
			else
			msg2(id,"You need at least $10 to buy food")
		end
		elseif button == 2 then
		if player(id, 'money') >= 10 then
			parse('equip '..id..' 86')
			parse('setweapon '..id..' 86')
			parse('setmoney '.. id ..' '.. (player(id, 'money') - 10))
			msg2(id,'You successfully bought meat for $10!')
			else
			msg2(id,'You need at least $10 to buy meat!')
		end
	end

     		if title == "Buy Handgun" then
     		if button == 1 then
			if player(id, 'money') >= 55 then
				parse('equip '..id..' 6')
				parse('setweapon '..id..' 6')
				parse('setmoney '.. id ..' '.. (player(id, 'money') - 55))
				msg2(id,'You successfully bought this weapon for $55!')
				else
				msg2(id,'You need at least $55 to buy this weapon!')
			end

          			elseif button == 2 then
          			if player(id, 'money') >= 60 then
				parse('equip '..id..' 3')
				parse('setweapon '..id..' 3')
				parse('setmoney '.. id ..' '.. (player(id, 'money') - 60))
				msg2(id,'You successfully bought this weapon for $60!')
				else
				msg2(id,'You need at least $60 to buy this weapon!')
			end
		end
	end
end
end
edited 1×, last 22.12.11 02:15:31 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview