Error: Your message is so long, or reached the maximum letters number.
#1

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;
}
Reply
#2

use strlen() function for checking message length
Reply
#3

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?
Reply
#4

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
use strlen() function for checking message length
pawn Код:
if(strlen(message) > 128)
{
    return SendClientMessage(playerid,COLOR_RED,"lol");
}
Reply
#5

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.
Reply
#6

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);
}
Reply
#7

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.
Reply
#8

bump
Reply
#9

it's impossible that no body knows how -_-
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)