packed string +Rep
#1

well,i have made an enum for something:
pawn Код:
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?
Reply
#2

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.
Reply
#3

All you do is add the word char
Код:
new string[2000 char]
now uses 500 bytes instead of 2000

https://sampforum.blast.hk/showthread.php?tid=480529
Reply
#4

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
All you do is add the word char
Код:
new string[2000 char]
now uses 500 bytes instead of 2000

https://sampforum.blast.hk/showthread.php?tid=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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)