SA-MP Forums Archive
Hey. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hey. (/showthread.php?tid=571318)



Hey. - GShock - 17.04.2015

Hello.. I need something that would block a player from using HEX codes in the chat..
I need a script or snippet that when a player enters {ffffff} to the chat it does not even show up in the chat.
I tried this :-
pawn Код:
if (!strlen(text)) return (0);



Re: Hey. - Ahmad45123 - 17.04.2015

Well.. The code Isn't really easy.

But here is a tip:
Strings are actually arrays.. Meaing that the variable: string[5] which lets say equals "Johny" will look like :
Код:
0 - J
1 - O
2 - H
3 - N
4 - Y
5 - \0 (The NULL.)
So to loop through the character you can use:
pawn Код:
for(new i; i < strlen(string); i++)
{
    if(string[i] == 'CHAR HERE')
    {
          //CODE HERE
    }
}
Using the same code above... detect the pos of { and the pos of } and than delete all chars between them.


Re: Hey. - Vince - 17.04.2015

The client filters out such codes on its own, they're not even sent to the server in the first place.


Re: Hey. - GShock - 17.04.2015

Hmm. :/
Then why is that when someone enters hex codes in the chat. They automatically wins the reaction test? :/


Re: Hey. - Jefff - 17.04.2015

because you are using strcmp in test, use
if(text[0] && !strcmp(text, ...)) // test ok
or add
if (!strlen(text)) return (0);
before test


Re: Hey. - GShock - 17.04.2015

Quote:
Originally Posted by Jefff
Посмотреть сообщение
because you are using strcmp in test, use
if(text[0] && !strcmp(text, ...)) // test ok
or add
if (!strlen(text)) return (0);
before test
Ahh yea!
Thanks! It worked!