English I want to make a roleplay chat.

9 replies
Goto Page
To the start Previous 1 Next To the start
Up
ZaibatsuTEAM
User
Offline Off
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
The Zaibatsu Networking Service™
19.08.15 08:44:39 pm
Up
Talented Doge
User
Offline Off
I've got this from user Oops321:

Code:
1
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


Take it and extend it to usage for your script.
Talented Doge
19.08.15 08:59:24 pm
Up
ZaibatsuTEAM
User
Offline Off
@user 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
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
The Zaibatsu Networking Service™
19.08.15 09:02:36 pm
Up
Talented Doge
User
Offline Off
You messed the code up. That's why.
Talented Doge
19.08.15 09:03:11 pm
Up
ZaibatsuTEAM
User
Offline Off
well that doesn't tell me much
The Zaibatsu Networking Service™
19.08.15 09:08:39 pm
Up
Talented Doge
User
Offline Off
For example, normal chat:

Code:
1
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


It should work now.
edited 2×, last 19.08.15 09:40:33 pm
Talented Doge
19.08.15 09:21:18 pm
Up
ZaibatsuTEAM
User
Offline Off
Ah thank you so much Yuki! You made my evening. Thank you!
The Zaibatsu Networking Service™
19.08.15 09:28:19 pm
Up
mafia_man
User
Offline Off
Your message is parsed as command by cs2d if first character of your message is /
19.08.15 09:31:35 pm
Up
JeeewNazi
User
Offline Off
Learn with ur mistake!
The only error i found is the msg command

Code:
1
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
19.08.15 09:38:18 pm
Up
Talented Doge
User
Offline Off
Oh yea I forgot about that / parsing thing...
Talented Doge
To the start Previous 1 Next To the start