Script Size
#5

Re-format strings instead of creating multiple ones for messages, for example:

Код:
new string[145];
GetPlayerName(targetid, string, 25);
format(string, sizeof (string), "[PM] To %s (%i): %s", string, targetid, params);
SendClientMessage(playerid, -1, string);

GetPlayerName(playerid, string, 25);
format(string, sizeof (string), "[PM] From %s (%i): %s", string, playerid, params);
SendClientMessage(targetid, -1, string);

// Do that instead of doing this:

new player_name[25], target_name[25], string1[145], string2[145];
GetPlayerName(playerid, player_name, 25);
GetPlayerName(targetid, target_name, 25);

format(string1, sizeof (string1), "[PM] To %s (%i): %s", target_name, targetid, params);
SendClientMessage(playerid, -1, string1);

format(string2, sizeof (string2), "[PM] From %s (%i): %s", player_name, playerid, params);
SendClientMessage(playerid, -1, string2);
Calculate how much cells you need for a string, instead of using a large size for no reason:

Код:
/*
String is: 
%s (%i) has logged in.

To calculate how much cells (max.) it needs, replace the specifiers (%*) with their values:

%s = player name, which has a max length of 24
%i = playerid, which has a max length of 3 (because 999 is the limit)
 () has logged in. = 18 characters

24 + 3 + 18 = 45
Add 1 to it for the NULL = 46
*/

new string[46];
Reply


Messages In This Thread
Script Size - by vassilis - 08.09.2016, 14:42
Re: Script Size - by Vince - 08.09.2016, 14:45
Re: Script Size - by OneDay - 08.09.2016, 14:47
Re: Script Size - by vassilis - 08.09.2016, 14:48
Re: Script Size - by Stinged - 08.09.2016, 15:05
Re: Script Size - by Gammix - 08.09.2016, 15:35
Re: Script Size - by vassilis - 08.09.2016, 17:04
Re: Script Size - by Nero_3D - 08.09.2016, 19:44
Re: Script Size - by Gammix - 08.09.2016, 21:32

Forum Jump:


Users browsing this thread: 1 Guest(s)