Error: Your message is so long, or reached the maximum letters number. -
AnonScripter - 31.05.2014
How to make something to send message like:
Error: Your message is so long, or reached the maximum letters number.
Example: look at this pawn code, if the message letters is more than 128, send the error message.
pawn Код:
CMD:something(playerid, params[])
{
new message[128], targetid;
if(sscanf(params, "us[128]", targetid, message)) return SendClientMessage(playerid, COLOR_WHITE, "/pm [playerid/name] [message]");
return 1;
}
Re: Error: Your message is so long, or reached the maximum letters number. -
BroZeus - 31.05.2014
use strlen() function for checking message length
Re: Error: Your message is so long, or reached the maximum letters number. -
AnonScripter - 31.05.2014
Quote:
Originally Posted by BroZeus
use strlen() function for checking message length
|
yes i know this but wiki doesnt explain how to use this, can u show me?
Re: Error: Your message is so long, or reached the maximum letters number. -
NaClchemistryK - 31.05.2014
Quote:
Originally Posted by BroZeus
use strlen() function for checking message length
|
pawn Код:
if(strlen(message) > 128)
{
return SendClientMessage(playerid,COLOR_RED,"lol");
}
Re: Error: Your message is so long, or reached the maximum letters number. -
AnonScripter - 31.05.2014
thank you
[edit:] didn't work, it sends the half of the message if its so long, also it sends this message to the DOS Window:
Код:
sscanf warning: String buffer overflow.
Re: Error: Your message is so long, or reached the maximum letters number. -
NaClchemistryK - 31.05.2014
You have to put that script snippet above the code in which everything is done... Like this:
pawn Код:
CMD:banme(playerid,params[])
{
new reason[15]
if(sscanf(params,"s[15]",reason)) return SendClientMessage(playerid,-1,"Learn to use the command /banme you idiot.");
Ban(playerid);
if(strlen(reason) > 15) return SendClientMessage(playerid,-1,"Don't spam.");//this must be above "Ban(playerid);"
}
The strlen stuff must be above. So the correct one is:
pawn Код:
CMD:banme(playerid,params[])
{
new reason[15]
if(sscanf(params,"s[15]",reason)) return SendClientMessage(playerid,-1,"Learn to use the command /banme you idiot.");
if(strlen(reason) > 15) return SendClientMessage(playerid,-1,"Don't spam.");//Right here it must be.
Ban(playerid);
}
Re: Error: Your message is so long, or reached the maximum letters number. -
AnonScripter - 01.06.2014
didn't work, the message is not showing up, if u typed more than 15 letters, it sends only 15 letters with showing the DOS message "sscanf warning: String buffer overflow."
instead of the Spam message.
Re: Error: Your message is so long, or reached the maximum letters number. -
AnonScripter - 01.06.2014
bump
Re: Error: Your message is so long, or reached the maximum letters number. -
AnonScripter - 02.06.2014
it's impossible that no body knows how -_-
Re: Error: Your message is so long, or reached the maximum letters number. -
SyntaxQ - 02.06.2014
pawn Код:
CMD:banme(playerid,params[])
{
new reason[16];
if(sscanf(params,"s[16]",reason)) return SendClientMessage(playerid,-1,"Learn to use the command /banme you idiot.");
if(strlen(reason) > 15) return SendClientMessage(playerid,-1,"Don't spam.");
Ban(playerid);
return 1;
}
Edited NaCl's command.