English Open a menu when you say hello on a specific spot

18 replies
Goto Page
To the start Previous 1 Next To the start
Up
NeptooN
User
Offline Off
Hi all, I need help how to make a script that would say Hello and open a menu.
IMG:file:///E:/Counter-Strike%202D/screens/Test_Maps_00003.jpg
edited 1×, last 26.01.17 11:33:13 am

Admin/mod comment:

Please use a more detailed title in the future
26.01.17 11:33:10 am
Up
Yates
Reviewer
Offline Off
Maybe this can help you:
file:///home/yates/games/cs2d/sys/lua/menu.lua

Edit: Good, you figured it out. Upload your screenshot to an image hosting website such as imgur.com then share that link.
26.01.17 11:41:20 am
Up
NeptooN
User
Offline Off
26.01.17 11:42:10 am
Up
THEMUD
User
Offline Off
Follow these links and I guarantee you will know how to write it by yourself.

Lua Scripting in CS2D
Lua Tutorial
I don't know what I'm doing with my life.
26.01.17 11:44:08 am
Up
NeptooN
User
Offline Off
This program without virus?
26.01.17 12:05:23 pm
Up
kerker
User
Offline Off
@user NeptooN: This is the official CS2D website. Can be almost certain that viruses are not there.
26.01.17 12:15:33 pm
Up
NeptooN
User
Offline Off
Well, to be honest there will have to pay but I will not do that.
edited 1×, last 26.01.17 04:16:15 pm
26.01.17 04:38:24 pm
Up
Scott
BANNED
Offline Off
It can be something like that ? this is something simple.

Code:
1
2
3
4
5
6
7
8
9
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
26.01.17 04:59:50 pm
Up
NeptooN
User
Offline Off
http://i.imgur.com/cx4zXOA.jpg
Here's something more go to the link
26.01.17 05:43:55 pm
Up
kerker
User
Offline Off
Like talk with humans in tibia script?
26.01.17 07:55:06 pm
Up
Bowlinghead
User
Offline Off
Code:
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
-- 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


Its just an example, you have to edit it to your likes.
If you find bugs, post your console log in here (especially the lua error).

EDIT: Fixed code syntax mistakes. Still shitty code because its written in the textfield of the website (NO TABS
edited 4×, last 27.01.17 03:46:17 pm
Share time limited free games here
26.01.17 10:31:38 pm
Up
Rainoth
Moderator
Offline Off
@user Bowlinghead:
']' @ 5
',' @ 6
double menu call @ 19

65/100 an okay code for an example.
MAL • DeviantArt • For Wallpaper Engine users • Check YT for playlists... •
27.01.17 10:33:59 am
Up
NeptooN
User
Offline Off
@user Bowlinghead: Bowlinghead Does not work.
27.01.17 11:52:50 am
Up
kerker
User
Offline Off
@user 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.
27.01.17 12:07:03 pm
Up
NeptooN
User
Offline Off
Well damn it all I don't know I'm Russian.
27.01.17 12:10:32 pm
Up
Rainoth
Moderator
Offline Off
@user Bowlinghead: You fixed two and yet forgot the comma @ line 6
@user 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.
MAL • DeviantArt • For Wallpaper Engine users • Check YT for playlists... •
27.01.17 12:37:42 pm
Up
NeptooN
User
Offline Off
@user Rainoth: Thank you!
27.01.17 03:29:33 pm
Up
Bowlinghead
User
Offline Off
@user Rainoth:
The comma is valid on line 6.
But line 16 declares "pos" again
Fixed code now

@user NeptooN:
me has written:
If you find bugs, post your console log in here (especially the lua error).

you has written:
@user Bowlinghead: Bowlinghead Does not work.

You find your console log by pressing your console button (default: ^ the key next to ESC and 1).
You can then right click -> copy all.
This will copy the text that you see in your clipboard.
Now you can paste that text with CTRL + V or rightclick onto the textfield and choose "Paste".

Note that this will only call a menu. The menu itself does not do anything! You have to program that in in the lines 36 and so on. Please look at the whole code to be able to edit code properly.

EDIT:
@user NeptooN:
Please try again. I changed the code and it works now
edited 2×, last 27.01.17 03:47:12 pm
Share time limited free games here
27.01.17 03:36:35 pm
Up
NeptooN
User
Offline Off
I have no errors.

Thank you everything works.

http://i.imgur.com/clvh4Gq.jpg
http://i.imgur.com/3KrIkf7.jpg

Code:
1
2
3
4
5
6
-- 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
}
edited 2×, last 27.01.17 04:27:18 pm
To the start Previous 1 Next To the start