string - 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)
+--- Thread: string (
/showthread.php?tid=422685)
string -
audriuxxx - 14.03.2013
Hi, what is better?
Код:
new String[ 50 ];
format(String,50,"blldflsldflsdflsdlfldslfl");
Or
Код:
new String[ MAX_PLAYERS ];
format(String[ playerid ],50,"blldflsldflsdflsdlfldslfl");
Re: string -
Ryan_Bowe - 15.03.2013
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.
Re: string -
Neil. - 15.03.2013
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
Re: string -
Glad2BeHere - 15.03.2013
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]);