Forum

> > CS2D > Scripts > Radius Chat (tibia-like)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Radius Chat (tibia-like)

8 replies
To the start Previous 1 Next To the start

old Radius Chat (tibia-like)

SeanHoca
User Off Offline

Quote
Hello, I need a script like Radius Chat in Tibia.
I need two modes in the script;
1. Radius Chat
2. Global Chat (@) or (@g)

If you didn't understand;

old Re: Radius Chat (tibia-like)

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
addhook("say","_s")
function _s(id,t)
	if t:sub(#t-2,#t) == "@r" then
		for k,v in pairs (player(0,"tableliving")) do
			if (math.sqrt(((player(id,"x")-v.x)^2 + player(id,"y")-v.y)^2)<1000) then
				msg2(v,player(id,"name")..": "..t)
			end
		end
	elseif t:sub(#t-2,#t) == "@g" then
		msg(player(id,"name")..": "..t)
	end
end

General concept. May or may not work. Fine-tune and fix if something's wrong yourself.

old Re: Radius Chat (tibia-like)

SeanHoca
User Off Offline

Quote
Yeah, didn't worked. (with/without other lua + i tried changing some code, not worked again.)

By the way, Radius Chat is going to be normal chat. No commands.

old Re: Radius Chat (tibia-like)

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("say","_s")
function _s(id,t)
	if t:sub(#t-1,#t) == "@r" then
		for k,v in pairs (player(0,"tableliving")) do
			if (math.sqrt(((player(id,"x")-player(v,"x"))^2 + (player(id,"y")-player(v,"y"))^2))<1000) then
				msg2(v,player(id,"name")..": "..t:sub(1,#t-2))
				return 1
			end
		end
	elseif t:sub(#t-1,#t) == "@g" then
		msg(player(id,"name")..": "..t:sub(1,#t-2))
		return 1
	end
end

Found a few dumb mistakes and fixed it up, you could have found them too, they're pretty dumb mistakes. Was indexing default CS2D table wrong way. Oops. Tested the code, works without a hitch.

Add all the fancy crap like team colors yourself. It doesn't require a lot of brain to do it. I believe in you.

old Re: Radius Chat (tibia-like)

SeanHoca
User Off Offline

Quote
Sorry mate, nothing changed.

1
2
3
ERROR: sys/lua/test.lua:5: attempt to index local 'v' (a number value)
 -> sys/lua/test.lua:5: in function <sys/lua/test.lua:2>
 -> in Lua hook 'say', params: 1, '@r'
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview