SA-MP Forums Archive
2 Strings - 1 Message - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 2 Strings - 1 Message (/showthread.php?tid=173411)



2 Strings - 1 Message - Scenario - 02.09.2010

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!


Re: 2 Strings - 1 Message - RoCK'N'Rolla - 02.09.2010

if(sscanf(params, "s", Message))


Re: 2 Strings - 1 Message - Scenario - 02.09.2010

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


Re: 2 Strings - 1 Message - Sergei - 02.09.2010

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.


Re: 2 Strings - 1 Message - RoCK'N'Rolla - 02.09.2010

"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


Re: 2 Strings - 1 Message - mrcoolballs - 02.09.2010

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]


Re: 2 Strings - 1 Message - RoCK'N'Rolla - 02.09.2010

or you can use :

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

Use "params" for "Message".


Re: 2 Strings - 1 Message - General Abe - 02.09.2010

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.


Re: 2 Strings - 1 Message - Scenario - 02.09.2010

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


Re: 2 Strings - 1 Message - Sergei - 02.09.2010

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