PDA

View Full Version : packed string +Rep


iBots
23/04/2015, 11:16 AM
well,i have made an enum for something:

enum
{
ID[2000], //2000 is the max of that something,when i wanna check i do like somethinginfo[playerid][ID][1-2000]
//and here more like it
};

When i wanna change it to packed string,how much should i change 2000 to?

AberKane
23/04/2015, 03:15 PM
That's a huge ass problem, give that much of memory to such a string not to mention that it will also be given to different players. If you understand how binary works, you would puke.
But to clear things for you, what you need to do expecting that the "2000" number that you're using is something like score or money or whatever.
enum PlayerInfos
{
String[MAX_PLAYER_NAME], // Just a string to hold the player name
String2[150], // A string which is an array that holds 150 characters in this case
Money, // The money amount will be held here in this integer or decimal
Score, // ...
};
//Now this will hold different data for different players
pInfos[MAX_PLAYERS][PlayerInfos];
Then let's say you have a player, and want to increase his/her money.
pInfos[playerid][Money] += 2000;
//
If am mistaken about your thoughts please reply back.

TakeiT
23/04/2015, 05:17 PM
All you do is add the word char new string[2000 char] now uses 500 bytes instead of 2000

http://forum.sa-mp.com/showthread.php?t=480529

AberKane
23/04/2015, 05:24 PM
All you do is add the word char new string[2000 char] now uses 500 bytes instead of 2000

http://forum.sa-mp.com/showthread.php?t=480529
Ma bad, as a C++ developer i wasn't aware of packed strings in pawn, until i read your topic, it's probably like pawn performs operations on the bit level to save space instead on C++ we use bitwise operators to work on bit patterns, thanks peace.