edited 1×, last 26.01.17 10:33:13 am
Scripts
Open a menu when you say hello on a specific spot
Open a menu when you say hello on a specific spot
1

NeptooN: This is the official CS2D website. Can be almost certain that viruses are not there. addhook("say","_say")
function _say(p,txt)
	-- Hello
	if (txt=="hello") then menu(p,"Hello,add menu"); return 1 end
	-- Nice
	if (txt=="nice") then menu(p,"Nice,add menu"); return 1 end
	
end
-- NEW code: tested & working
-- which positions will open a menu when saying !hello ?
pos = {
[1] = {5,9}, -- stay on Tile 5|9
[2] = {12,12}, -- stay on Tile 12|12
---... as much you like
}
addhook("say","mySay")
function mySay(id,txt)
if (txt == "!hello") then
local px = player(id,"tilex")
local py = player(id,"tiley")
for iposi, posi in pairs(pos) do
if (px == posi[1]) then
if (py == posi[2]) then
		
--menu(id,tostring(iposi)..". Menu, Energy Drink, Smartphone, E-Cigs.") -- this is the same menu for all positions (probably not what you want)
if (iposi == 1) then -- look if player is standing @Market position
menu(id,"NEW MARKET, Fresh Fish|ezpz, Apples|lmsqz, Bread | without butter") -- change as you like
elseif (iposi == 2) then -- modify as you like: The "" String has to match with the names you gave in pos = {} array
menu(id,"AMMONATION, Swords, Rifles, Gunblades, Ammo")
end
end
end
end
end
end
addhook("menu", "myMenu")
function myMenu(id,txt,b) -- id, txt, button
if (txt == "NEW MARKET") then
if (b == 1) then
-- if button 1 pressed
elseif (b== 2) then
-- if button 2 pressed
elseif (b== 3) then
-- ...
end
elseif (txt =="AMMONATION") then
if (b == 1) then
-- if button 1 pressed
elseif (b== 2) then
-- if button 2 pressed
elseif (b== 3) then
-- ...
end
end
end
Bowlinghead:
Bowlinghead: Bowlinghead Does not work.
NeptooN: It is difficult to understand what you want, especially if consider that your knowledge of English is not very good, once you use an interpreter and do not notice how much has happened errors in translation.
Bowlinghead: You fixed two and yet forgot the comma @ line 6
NeptooN: If you bothered to read, you'd know that he gave you an example, not an actual working code. He did the hard part for you and now you need to fill the easy part with commands and whatnot.
Rainoth: Thank you!
Rainoth:
NeptooN:
Bowlinghead: Bowlinghead Does not work.
NeptooN:
-- which positions will open a menu when saying !hello ?
pos = {
[1] = {37,19}, -- stay on Tile 37|19
[2] = {37,20}, -- stay on Tile 37|20
---... as much you like
}
1
