string
#1

Hi, what is better?

Код:
new String[ 50 ];

format(String,50,"blldflsldflsdflsdlfldslfl");
Or

Код:
new String[ MAX_PLAYERS ];

format(String[ playerid ],50,"blldflsldflsdflsdlfldslfl");
Reply
#2

I don't really know, but I do this for most of my commands.
pawn Код:
new string[128];
format(string, sizeof(string), "blldflsldflsdflsdlfldslfl", Whatever here.);
Work's fine for me you can do whatever though.
Reply
#3

No, don't use MAX_PLAYERS. MAX_PLAYERS is not a variable, it's a define. The maximum number of players a server can hold (this by default is 500, even if you change the number in your server.cfg file). Therefore you're creating a new variable which has 500 characters. You only need to use 128 characters (Unless you need less or more). If you really want to save some bytes, Use a string counter. So:

pawn Код:
new mychar[128]; //Your 128 (or a lower character) character variable
format(mychar,sizeof(mychar), "Your text here"); //Formatting
SendClientMessage(playerid, -1, mychar); //Send the formatted message




Source Samp Wiki
Reply
#4

Both methods are acceptable because u are the only different is the string[MAX_PLAYERS] is a variable and every u call/use it it would carry that value hence the text....... so i recommended u use string unlesss u want to call a variables
pawn Код:
new string[MAX_PLAYERS][256];
format(string[playerid], sizeof(string[playerid]), "Hi");
SendClientMessage(playerid, -1, string[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)