SA-MP Forums Archive
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=651041)



String. - Hunud - 12.03.2018

What's better, or just what's the best way and why should i choose this way. Is there any differences, or i just have to take care of number of cells ?

Код:
new globalstring[ 1024 ];
Код:
format(globalstring, sizeof(globalstring), "Hello %s, Welcome to SA:MP", playername);
Код:
new string[ 80 ];
Код:
format(string, sizeof(string), "Hello %s, Welcome to SA:MP", playername);
Код:
new string[ 25 + MAX_PLAYER_NAME ];
Код:
format(string, sizeof(string), "Hello %s, Welcome to SA:MP", playername);



Re: String. - Meller - 12.03.2018

I'll be your hero!



This is how the correct way would be in any scripting language.



PHP код:
// define a macro telling us a 'English' version of a message that's visible to a client, preferably in a seperate file in the includes folder.
#define MESSAGE_TEST
    
"Hello %s, this is some weird shit."
// and then the usage is:
const ShowTestMessage(playerid) {
    static 
cells[sizeof(MESSAGE_TEST)+MAX_PLAYER_NAME];
    static 
userName[MAX_PLAYER_NAME];
    
GetPlayerName(playeriduserNamesizeof(userName));
    
format(cellssizeof cellsMESSAGE_TESTuserName);
    return 
cells;









im a smartass


Re: String. - ISmokezU - 12.03.2018

The second way is better.