English Stop @C

14 replies
Goto Page
To the start Previous 1 Next To the start
05.06.18 02:43:06 pm
Up
Jenko63
User
Offline Off
how to stop players using from saying @C because there text will be shown in center of the screen
JENKO
05.06.18 03:10:19 pm
Up
Rainoth
Moderator
Offline Off
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
MAL • DeviantArt • For Wallpaper Engine users • Check YT for playlists... •
05.06.18 03:19:48 pm
Up
Gaios
Security Supporter
Offline Off
The way you should do it:
Code:
1
text:gsub('@C', '')
05.06.18 03:21:22 pm
Up
Jenko63
User
Offline Off
@user Rainoth:

thanks
JENKO
05.06.18 03:40:39 pm
Up
THEMUD
User
Offline Off
@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).
I don't know what I'm doing with my life.
05.06.18 03:51:26 pm
Up
VADemon
User
Offline Off
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"
Code:
1
string.gsub(chatmessage_variable, "@C$", "@C ")

However, you may want to delete the color code at the beginning too:
Code:
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
06.06.18 08:15:57 am
Up
Yates
Reviewer
Offline Off
@user Rainoth: Hey@C@C

06.06.18 08:53:24 am
Up
Gaios
Security Supporter
Offline Off
@user Yates: So everyones code is sh*t XD.. unless nobody will care about e-mails, so mine
06.06.18 09:22:31 am
Up
Yates
Reviewer
Offline Off
When is the last time anyone wrote an e-mail in chat. Who cares, just strip all of it.
06.06.18 02:47:45 pm
Up
Rainoth
Moderator
Offline Off
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.
MAL • DeviantArt • For Wallpaper Engine users • Check YT for playlists... •
06.06.18 05:30:50 pm
Up
Yates
Reviewer
Offline Off
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.
06.06.18 06:40:22 pm
Up
Hajt
User
Offline Off
I would use this function to prevent a user from entering "wrong" input.
Code:
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
06.06.18 06:50:31 pm
Up
VADemon
User
Offline Off
@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
06.06.18 08:41:51 pm
Up
Gaios
Security Supporter
Offline Off
Code:
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
06.06.18 10:00:45 pm
Up
Yates
Reviewer
Offline Off
@user VADemon: It's not called idiot proofing for a reason
To the start Previous 1 Next To the start