Forum

> > CS2D > Scripts > Stop @C
Forums overviewCS2D overview Scripts overviewLog in to reply

English Stop @C

14 replies
To the start Previous 1 Next To the start

old Stop @C

Jenko63
User Off Offline

Quote
how to stop players using from saying @C because there text will be shown in center of the screen

old Re: Stop @C

Rainoth
Moderator Off Offline

Quote
Assuming you're using lua "msg" to format text messages and not just default CS2D messages, you'd just need to check if players wrote "@C" and remove it.

if txt:sub(#txt-1,#txt) == "@C" then txt = txt:sub(1,#txt-2) end

old Re: Stop @C

Gaios
Reviewer Off Offline

Quote
The way you should do it:
1
text:gsub('@C', '')

old Re: Stop @C

THEMUD
User Off Offline

Quote
@user Gaios: If a user wrote his E-mail in capital and his E-mail's hosting service name started with 'c', his E-mail wouldn't be displayed correctly.

Appending the
$
magic character to the pattern makes sure that the "@C" is written at the end of the string, thus preventing such cases to happen (even though they're not likely to happen, but still).

old Re: Stop @C

VADemon
User Off Offline

Quote
What @user THEMUD: said. @C must only be replaced at the end of the message, because this message will be valid: "Hello@C my message"
1
string.gsub(chatmessage_variable, "@C$", "@C ")
However, you may want to delete the color code at the beginning too:
1
string.gsub(chatmessage_variable, "^\169%d%d%d%d%d%d%d%d%d", " %1")

But instead of deleting the @C or colorcode, I place a space " " in the end or in the beginning in the message, so these codes have no meaning to cs2d

old Re: Stop @C

Gaios
Reviewer Off Offline

Quote
@user Yates: So everyones code is sh*t XD.. unless nobody will care about e-mails, so mine

old Re: Stop @C

Yates
Reviewer Off Offline

Quote
When is the last time anyone wrote an e-mail in chat. Who cares, just strip all of it.

old Re: Stop @C

Rainoth
Moderator Off Offline

Quote
I don't think the people playing this game have the creativity/capability to think of a workaround like you did. Most will give up after seeing "@C" doesn't work.

old Re: Stop @C

Yates
Reviewer Off Offline

Quote
You underestimate the power of idiots. Always, always, idiot proof your code.

The people that usually find out these loop-holes and try to break things are idiots. Logical thinking is not one of their strong feats, so they try things like @C@C. It is within their nature.

Took them 5 minutes to figure out @C@C worked on my server after I patched it to remove the last instance like you did.

old Re: Stop @C

Hajt
User Off Offline

Quote
I would use this function to prevent a user from entering "wrong" input.
1
2
3
4
5
6
7
function escapeString(text)
	if string.sub(text, -2) == "@C" then
		text = string.sub(text, 1, string.len(text) - 2)
	end
	text = string.gsub(text, "[\166]", " ")
	return text
end

old Re: Stop @C

VADemon
User Off Offline

Quote
@user Hajt: read the replies above, your code will miss "@C@C" just like user Rainoth's first answer.

@user Yates: No, these people are true legends. They find the impossible. Their logic exceeded your logic and they outsmarted your system.
The people who find the deepest & elegant loopholes have my respect.

Also regarding "@C@C" - when you add a space to the end of the message, it will look very weird in chat, because it must have worked!!1111

old Re: Stop @C

Gaios
Reviewer Off Offline

Quote
1
2
3
4
5
6
7
8
local txt = 'Remove Kebab@C@C@C'

while txt:sub(-2) == '@C' do
    txt = txt:sub(1, -3)
end

print(txt)
-- Remove Kebab
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview