usaage big array
#1

Hello,
i have got one big (really big) array in my game mode:

Код:
enum e_Przedmioty
{
	ID,
	Nazwa[34],
	Kategoria,
	Typ,
	War[100],
	Miejsce,
	InUse
}
new Przedmioty[MAX_PLAYERS][100][e_Przedmioty];
I cann't reduce array size, because i use it to save player's items. Everytime when i'm using this array anywhere in my script size of gamemode after compilate rise about few MB.

How to solve this problem?
Reply
#2

PHP код:
enum e_Przedmioty
{
    
ID,
    
Nazwa[34],
    
Kategoria,
    
Typ,
    
War[100],
    
Miejsce,
    
InUse
};
new 
Przedmioty[MAX_PLAYERS][100][e_Przedmioty]; 
There..
Reply
#3

Ask yourself do you really need that big array?
Natwa needs to be 34? War 100? Multiplied by MAX_PLAYERS and than 100 times for every player?
At least you can redefine MAX_PLAYERS value to fit your needs.
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
But i guess that whole system can be done in other way, without allocation of that much memory.
Reply
#4

Thanks WhiteGhost for replay.

I don't really get what you had on your mind, sorry i don't speak english very good.

I know size of this array is problem. I'm asking how to fix this problem.

edit:
Thanks Dragony92 for your replay.

nazwa holds the name of item, so i can reduce only a few chars
war is holding description of item (which is different for every item) so i can't reduce it too..

Have you got any idea how can i do this other way?
Reply
#5

Dragony92 - i redefined max_players and set 200. It really helped but amx file is sill too big. Anyway thanks so much. Have anybody got any others ideas how to solve problem?
Reply
#6

Can you try to explain us what are you trying to make so we can suggest you better way of making it.
Reply
#7

I am creating items system, every people have items which they can use (eg. m4,pizza,driving licence etc).

Код:
enum e_Przedmioty
{
    ID, // id of item
    Nazwa[34], // name of item (like "Deasert Eagle")
    Kategoria, // category (weapons,drugs etc)
    Typ, (type - for example weapon id)
    War[100], (description, for example description of id card is "John Smith born 1993")
    Miejsce, // owner id
    InUse // is in use
};
when somebody choose some item from dialog, for example it is m4.

i check witch category is this item, because it is weapons category i know i have to give player weapon (for example for food i restore player's health)

Next i check the type, so i know it is m4 and send message that he is using m4 (name) and set item "InUse".

I have to know id of item to update it in database.
Reply
#8

How often is the data accessed? I find it rather silly to copy something into memory if it's already stored in the database. If it's only sporadically accessed then you really only need to store the ID in memory; retrieve the rest from the database as and when it's needed.
Reply
#9

Are you using multi-iterators in operations? Or standard loops?
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
How often is the data accessed? I find it rather silly to copy something into memory if it's already stored in the database. If it's only sporadically accessed then you really only need to store the ID in memory; retrieve the rest from the database as and when it's needed.
It depends on players. Somebody use it once per day, somebody few times a a minute. I'm afraid downloading data from mysql everytime could took too long and lag serwer. Am i right?

Rdx - standard loops like for and sometimes while
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)