Forum

> > CS2D > Scripts > inserting a particular txt in msg!
Forums overviewCS2D overview Scripts overviewLog in to reply

English inserting a particular txt in msg!

4 replies
To the start Previous 1 Next To the start

old inserting a particular txt in msg!

Ajmin
User Off Offline

Quote
how to insert a txt in a msg?
i mean:

"on" is a variable.

if on[id]==1 then

then if a player type any msg it should contain "By Player" in every end of the msg.

example :- i typed "hi"
then it should be displayed as "hi by player"

i need to do it with txt:sub.

old Re: inserting a particular txt in msg!

VADemon
User Off Offline

Quote
You should really read a tutorial on Lua basics.
1
2
3
4
5
6
7
addhook("say", "test_say")

function testsay(id, txt)
msg("\"" .. txt .. "\" by player " .. player(id, "name"))

return 1
end
Once you can tell me what every thing inside msg( ... ) does, you understood it.

cs2d lua hook say also cs2d lua hook sayteam & cs2d lua cmd msg also cs2d lua cmd msg2 & cs2d lua cmd player

old Re: inserting a particular txt in msg!

Ajmin
User Off Offline

Quote
i knew this!
i need to do it with txt:sub if possible!

My aim:
theres a button (create new pm)
if player press it then:
then there comes a list of player's id.
if player select any id then:
there comes a msg2 (type ur msg now)
then if player type any txt
it should be delivered to that selected id.

if i add !pm (id) before player's msg using txt:sub it will be succesfully done!
cuz i already installed pm system with cmd.

old Re: inserting a particular txt in msg!

Joni And Friends
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
pm={}
function listm(id)
men="list player"
for g=1,32 do
if player(g,"exists") then
men=men..','..player(g,"name")
else
men=men..','
end
end
menu(id,men)
end

addhook("serveraction","s")
function s(id,a)
if a==1 then
listm(id)
end
end

addhook("menu","mk")
function mk(id,title,button)
if title=="list player" then
if button>0 then
pm[id]=button
msg2(id,"write massage now")
end
end
end

addhook("say","ss")
functions ss(id,txt)
if pm[id]==nil then
pm[id]=0
elseif pm[id]>0 then
msg2(pm[id],txt.." by "..player(id,"name"))
pm[id]=0
return 1
end
end
And maybe this you mean about x:sub(charx,charn)
1
2
3
4
5
6
7
addhook("say","sa")
function sa(id,txt)
          if txt:sub(1,2)=="hi" then ----- checked char1 until char2
                msg(txt:sub(1,2).." by "..player(id,"name"))
         return 1
         end
end
edited 3×, last 25.12.14 02:36:08 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview