I want to make a roleplay chat.
9 replies



19.08.15 08:23:14 pm
Well, since I'm not one of the best scripters in this world, I would like to ask if someone can make a roleplay-like chat for cs2d.
now, what i mean is, for example, If you type normally, you will only be heard by players in range. if you type /y which is yell, you will be heard from longer distances. if you type // which is OOC, everyone can hear you. etc etc..
Can someone help me with this? It would be very appreciated. Thanks
now, what i mean is, for example, If you type normally, you will only be heard by players in range. if you type /y which is yell, you will be heard from longer distances. if you type // which is OOC, everyone can hear you. etc etc..
Can someone help me with this? It would be very appreciated. Thanks

The Zaibatsu Networking Service™
I've got this from
_oops:
Take it and extend it to usage for your script.

Code:
1
2
3
4
5
6
7
2
3
4
5
6
7
function sv_sound3(file,x,y,radius)
for _, id in pairs(player(0,"table")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
parse("sv_sound2 "..id.." "..file)
end
end
end
for _, id in pairs(player(0,"table")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
parse("sv_sound2 "..id.." "..file)
end
end
end
Take it and extend it to usage for your script.
19.08.15 08:59:24 pm
@
Talented Doge: Thanks but this is sv_sound2? uhm.. lol i wanted it to be chat. i did try and convert it to chat but didn't work too well.

Code:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("say","chatshit")
function chatshit(txt,x,y,radius)
for _, id in pairs(player(0,"table")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
msg("©255255255"..player(id,"name")..": "..txt)
end
end
end
function chatshit(txt,x,y,radius)
for _, id in pairs(player(0,"table")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
msg("©255255255"..player(id,"name")..": "..txt)
end
end
end
The Zaibatsu Networking Service™
For example, normal chat:
It should work now.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say", "_say")
function _say(p, t)
if t:sub(1, 2) ~= "-y" and t:sub(1, 2) ~= "-w" then msg3(p, t, player(p, "x"), player(p, "y"), 320) return 1 end
end
function msg3(p, t, x, y, radius)
for _, id in pairs(player(0,"table")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
msg2(id, player(p, "name")..": "..t)
end
end
end
function _say(p, t)
if t:sub(1, 2) ~= "-y" and t:sub(1, 2) ~= "-w" then msg3(p, t, player(p, "x"), player(p, "y"), 320) return 1 end
end
function msg3(p, t, x, y, radius)
for _, id in pairs(player(0,"table")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
msg2(id, player(p, "name")..": "..t)
end
end
end
It should work now.
edited 2×, last 19.08.15 09:40:33 pm
Learn with ur mistake!
The only error i found is the msg command
The only error i found is the msg command
Code:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("say","chatshit")
function chatshit(txt,x,y,radius)
for _, id in pairs(player(0, TABLE")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
msg("©255255255"..player(id,"name")..": "..txt) -- this msg command should be changed to msg2 that is : msg2(id,"©255255255"..player(id,"name")..": "..txt)
end
end
end
function chatshit(txt,x,y,radius)
for _, id in pairs(player(0, TABLE")) do
if math.sqrt((x-player(id,"x"))^2 + (y-player(id,"y"))^2) < radius then
msg("©255255255"..player(id,"name")..": "..txt) -- this msg command should be changed to msg2 that is : msg2(id,"©255255255"..player(id,"name")..": "..txt)
end
end
end



