how to make private message?
9 replies



12.04.12 06:46:39 pm
how to make private message , i want it like this
EXAMPLE :
player 1 typing !sayto 2 Hi !!
player 2 get messages Hi !!
without others can see that message
how to make it? teach me pls
EXAMPLE :
player 1 typing !sayto 2 Hi !!
player 2 get messages Hi !!
without others can see that message
how to make it? teach me pls




in case !sayto was found:




Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function string.split(str,pat)
local t={}
for word in string.gmatch(str,pat) do
if word~="" then
table.insert(t,word)
end
end
return t
end
addhook("say","pmessaging",118)
function pmessaging(id,txt)
local t=string.split(txt,"(%w+)")
if (t[1]=="!sayto") then
local ply=tonumber(t[2])
local words=txt:sub(t[1]:len()+1+t[2]:len())
msg2(ply,player(id,"name")..": "..words)
return 1
end
end
local t={}
for word in string.gmatch(str,pat) do
if word~="" then
table.insert(t,word)
end
end
return t
end
addhook("say","pmessaging",118)
function pmessaging(id,txt)
local t=string.split(txt,"(%w+)")
if (t[1]=="!sayto") then
local ply=tonumber(t[2])
local words=txt:sub(t[1]:len()+1+t[2]:len())
msg2(ply,player(id,"name")..": "..words)
return 1
end
end
Probably not the most efficient implementation, but I think it should work.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function string.split(str,pat)
local t={}
for word in string.gmatch(str,pat) do
if word~="" then
table.insert(t,word)
end
end
return t
end
addhook("say","pmessaging",118)
function pmessaging(id,txt)
local t=string.split(txt,"(%w+)")
if (t[1]=="!sayto") then
local ply=tonumber(t[2])
local words=txt:sub(t[1]:len()+1+t[2]:len())
msg2(ply,player(id,"name")..": "..words)
return 1
end
end
local t={}
for word in string.gmatch(str,pat) do
if word~="" then
table.insert(t,word)
end
end
return t
end
addhook("say","pmessaging",118)
function pmessaging(id,txt)
local t=string.split(txt,"(%w+)")
if (t[1]=="!sayto") then
local ply=tonumber(t[2])
local words=txt:sub(t[1]:len()+1+t[2]:len())
msg2(ply,player(id,"name")..": "..words)
return 1
end
end
Probably not the most efficient implementation, but I think it should work.
Engin33R , it doesn't work

More information, for fuck's sake!
What exactly do you do?
Any errors in the console?


I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
Code:
works 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
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
function totable(t,match)
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
addhook("say","pmsg")
function pmsg(id,txt)
local p = totable(txt)
local cmd = (p[1])
if cmd == "!sayto" then
local pl = tonumber(p[2])
if player(pl,"exists") then
local msg= string.sub(txt, 10, #txt)
msg2(pl,"©235143041"..player(id,"name").." (PRIVATE): "..msg)
msg2(id,"©235143041Private message to "..player(pl,"name")..": "..msg.." was sent!")
return 1
else
msg2(id,"©255000000This player doesn't exists!")
return 1
end
return 1
end
end
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
addhook("say","pmsg")
function pmsg(id,txt)
local p = totable(txt)
local cmd = (p[1])
if cmd == "!sayto" then
local pl = tonumber(p[2])
if player(pl,"exists") then
local msg= string.sub(txt, 10, #txt)
msg2(pl,"©235143041"..player(id,"name").." (PRIVATE): "..msg)
msg2(id,"©235143041Private message to "..player(pl,"name")..": "..msg.." was sent!")
return 1
else
msg2(id,"©255000000This player doesn't exists!")
return 1
end
return 1
end
end

Code:
works1
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
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
function totable(t,match)
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
addhook("say","pmsg")
function pmsg(id,txt)
local p = totable(txt)
local cmd = (p[1])
if cmd == "!sayto" then
local pl = tonumber(p[2])
if player(pl,"exists") then
local msg= string.sub(txt, 10, #txt)
msg2(pl,"©235143041"..player(id,"name").." (PRIVATE): "..msg)
msg2(id,"©235143041Private message to "..player(pl,"name")..": "..msg.." was sent!")
return 1
else
msg2(id,"©255000000This player doesn't exists!")
return 1
end
return 1
end
end
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
addhook("say","pmsg")
function pmsg(id,txt)
local p = totable(txt)
local cmd = (p[1])
if cmd == "!sayto" then
local pl = tonumber(p[2])
if player(pl,"exists") then
local msg= string.sub(txt, 10, #txt)
msg2(pl,"©235143041"..player(id,"name").." (PRIVATE): "..msg)
msg2(id,"©235143041Private message to "..player(pl,"name")..": "..msg.." was sent!")
return 1
else
msg2(id,"©255000000This player doesn't exists!")
return 1
end
return 1
end
end
or
Code:
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
addhook("say","action43")
function action43(id,txt)
if string.sub(txt,0,3) == "@pm" then
local pl = string.sub(txt,5,6)
if player(pl,"exists") then
local msg = string.sub(txt,7,99)
msg2(pl,"©235143041"..player(id,"name").." (PRIVATE): "..msg)
msg2(id,"©000255000Your message has been succesful sent!")
return 1
end
end
end
function action43(id,txt)
if string.sub(txt,0,3) == "@pm" then
local pl = string.sub(txt,5,6)
if player(pl,"exists") then
local msg = string.sub(txt,7,99)
msg2(pl,"©235143041"..player(id,"name").." (PRIVATE): "..msg)
msg2(id,"©000255000Your message has been succesful sent!")
return 1
end
end
end
by @


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("say"privatemsg")
function privatemsg(id,txt)
if txt:sub(1,6)=="!sayto" then
pl = 0
msg = ""
if txt:sub(9,9)~=" " then
pl = tonumber(txt:sub(8,9))
msg = txt:sub(11)
else
pl = tonumber(txt:sub(8,8))
msg = txt:sub(10)
end
if player(pl,"exists") then
msg2(id,string.char(169).."255255255Private message "..player(pl,"name")..": "..msg)
msg2(pl,string.char(169).."255255255"..player(id,"name").."(Private): "..msg)
end
return 1
end
end
function privatemsg(id,txt)
if txt:sub(1,6)=="!sayto" then
pl = 0
msg = ""
if txt:sub(9,9)~=" " then
pl = tonumber(txt:sub(8,9))
msg = txt:sub(11)
else
pl = tonumber(txt:sub(8,8))
msg = txt:sub(10)
end
if player(pl,"exists") then
msg2(id,string.char(169).."255255255Private message "..player(pl,"name")..": "..msg)
msg2(pl,string.char(169).."255255255"..player(id,"name").."(Private): "..msg)
end
return 1
end
end
say: !sayto <id> <message>
tested!
http://i39.tinypic.com/16lgx94.png
edited 1×, last 13.04.12 03:22:32 am
Hello? Are you there, Tae Hanazono?



