What's new command
#1

Well, I asked my friend for some help in scripting a whatsnew command as I'm still a newbie in PAWNO.

He's on vacation and I can't reach him. I was wondering if someone could help me and fix this script, thanks..

Basic information regarding it:
This command is supposed to display a window, with a list of everything that has been updated recently.


However, it appears like this:


Script:

PHP код:
COMMAND:whatsnew(playeridparams[])
{
    new 
watsnew128 ];
    
strcat(watsnew"{89ca25}==============================================================\n");
    
strcat(watsnew"Test | The latest changes on the server | San Andreas\n");
    
strcat(watsnew"==============================================================\n");
    
strcat(watsnew"{ffffff}- TEST.\n\
                        - TEST.\n\
                        - TEST.)\n\
                        - TEST.\n\
                        - TEST.\n\
                        - TEST.\n\
                        - TEST.\n\
                        - TEST.\n"
);
    
strcat(watsnew"     -TEST.\n");
    
ShowPlayerDialog(playerid11DIALOG_STYLE_MSGBOX"Test: Latest updates",watsnew"Ok"""); 
Thanks in advance!
Reply
#2

pawn Код:
new watsnew[ 128 ];
This string can only hold '127' characters + a null ending character ('\0').
So you just need to increase the '128' to the number of characters that will be in your dialog and add 1 to it for the null character. (Don't make it too high, because they can consume a lot of data)
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
new watsnew[ 128 ];
This string can only hold '127' characters + a null ending character ('\0').
So you just need to increase the '128' to the number of characters that will be in your dialog and add 1 to it for the null character. (Don't make it too high, because they can consume a lot of data)
Does the null ending character count ?
I mean, let's say this dialog box should contain 600 characters and I got 60 null ending characters (\n)
Am I supposed to write new watsnew[660]?
Reply
#4

"\n" is not a null character its a new line character. The null character is "\0" which represent end of string. you do not need to add this as its done automatically, but you need to make sure your array size when you create the "whatsnew" variable is the size of the string your doing + 1 extra for the null character which pawn will put in for you. So essentially if your string is 600 characters long you make the array size 601
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)