31.12.2018, 06:25
I'm not sure why you're even restricting the use of '~f~' and '~o~'... they're not even valid gametext keys.
https://sampwiki.blast.hk/wiki/GameTextStyle
This basic command only stops the admin/player using '~k~' in the message as well as having unmatched tildes.
https://sampwiki.blast.hk/wiki/GameTextStyle
Quote:
|
Be careful, using too many text colors or special characters in one gametext may crash every player the gametext is shown to. Additionally, avoid using an uneven usage of the ~ character. Example: ~~r~Hello, ~g~how are ~y~~you?~ |
PHP код:
CMD:ann(playerid, params[])
{
if(isnull(params)) // If the player did not enter parameters...
return SendClientMessage(playerid, -1, "Usage: /ann [text]"); // Send the player a usage message.
if(strfind(params, "~k~", true) != -1) // If we find a forbidden string in our text...
return SendClientMessage(playerid, -1, "Wrong!"); // Send the player an error message.
new count = 0; // Store the count of tildes (~) in this variable.
for(new i = 0, j = strlen(params); i < j; i++) // Loop through the string to count all the tildes (~).
{
if(params[i] == '~') // If the character is a tilde...
count++; // Add 1 to our count.
}
if((count % 2) != 0) // If the number of tildes in our message is odd...
return SendClientMessage(playerid, -1, "Odd number of tildes!"); // Send an error message to the player.
GameTextForAll(params, 10000, 4); // Send the game text to all players.
return 1;
}

