Forum

> > CS2D > Scripts > Local chat
Forums overviewCS2D overview Scripts overviewLog in to reply

English Local chat

1 reply
To the start Previous 1 Next To the start

old Local chat

Armaros
User Off Offline

Quote
I'm not really avid in lua, so if there's anyone who could assist me, I'd be grateful.

I'm basically searching for a script that allows the server to enter some sort of local-chat mode, only people nearby can hear each other and nobody else can hear them unless they get too close.

I tried searching for this but it didn't work... could anyone point me towards the right direction?

old Re: Local chat

Rainoth
Moderator Off Offline

Quote
To explain how it works, here's a few steps
1. Use say hook
2. When a person talks, loop through the list of all people alive
3. Check if the distance of person is close enough to distance of other players
4. Send them a message
5. use return 1 to prevent message from acting like it's supposed to and being shown global

In case you need a bit help with distance (since it involves math knowledge a little), here's the code for it:
1
2
3
Distance = function(x1, y1, x2, y2)
    return math.floor(math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2)))
end
The example of such a function call would be
1
Distance(playerA_x,playerA_y,playerB_x,playerB_y)
where playerA would be your player and playerB would be currently looped player.

It's not hard to write but I'm afraid I'm busy with what I'm working on myself and this isn't rocket science so I believe you can do it yourself.

If there's anything you don't know, feel free to write it and we'll help you out
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview