2 Strings - 1 Message
#1

Okay... I currently have this command;

pawn Код:
command(b, playerid, params[])
{
    new Message[128];
    if( sscanf( params, "s[128]", Message) )
    {
        SendClientMessage( playerid, COLOR_WHITE, "SYNTAX: /b [message]" );
    }
            else
            {
                format( string, sizeof( string ), "(( %s:  %s )) ", GetName( playerid ), Message);
                NearByMessage( playerid, COLOR_B, string);

    }
    return 1;
}
And I know that when I go over the string size (128 characters) it will just cut off the rest of what I said. How can I make it if I do go over the alloted string size, it will just send another message like "... [the rest]"? I'm still learning how to use "sscanf" please help!
Reply
#2

if(sscanf(params, "s", Message))
Reply
#3

Quote:
Originally Posted by RoCK'N'Rolla
Посмотреть сообщение
if(sscanf(params, "s", Message))
Could you elaborate a little more on that? What does it do?
Reply
#4

1. Don't use sscanf, you have only one parameter here.
2. Check length of the message, if it's too long, cut it in two using strmid or any other variant.
Reply
#5

"s" is the symbol which includes texts in sscanf, thats all. If you want to add a number or player id, use "d" or "i".

Check it: https://sampwiki.blast.hk/wiki/Fast_Commands
Reply
#6

the string size is incorrect, 128 for the max length of what Message can be and also you need + 24 because of the GetName so change your string size to [152]
Reply
#7

or you can use :

if(!strlen(params)) return SendClientMessage(playerid, mwhite, "Usage: /b [message]");

Use "params" for "Message".
Reply
#8

Quote:
Originally Posted by mrcoolballs
Посмотреть сообщение
the string size is incorrect, 128 for the max length of what Message can be and also you need + 24 because of the GetName so change your string size to [152]
Text I/O is 128 max, so it is correct.
Reply
#9

Could someone give me a straight up answer and explain it? Your all confusing me a bit.
Reply
#10

Quote:
Originally Posted by RoCK'N'Rolla
Посмотреть сообщение
or you can use :

if(!strlen(params)) return SendClientMessage(playerid, mwhite, "Usage: /b [message]");

Use "params" for "Message".
No.

pawn Код:
if(isnull(params)) //usage
else //process command
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)