max amount [+rep]
#1

Well,i have made system for objects in houses,it's all fine,but the problem is that i loop alot,each dialog has a loop,and the loop is :
pawn Код:
for(new example = 0; example < MAX_HOUSESOBJECTS; example++)
{
//code
}
The problem is that MAX_HOUSEOBJECTS is 5000,and it makes amx size like 3000 kb,but when i set MAX_HOUSEOBJECTS to 50 the amx file decreases alot,how can i make it loop all over the objects and find them and ...without that much of size?
Reply
#2

Why do you need to keep looping over them for in the first place? Perhaps you could assign the objects individually to each house, then only loop the objects that belong to the house?

Furniture[MAX_HOUSES][MAX_OBJECTS_PER_HOUSE];
Reply
#3

give me example and by the way when i do it,lets say i want to show all of the furnitures ,max furnitures per house is 250,so i will have to loop 250 and do Furniture[houseid][i]
Reply
#4

Quote:
Originally Posted by iBots
Посмотреть сообщение
give me example and by the way when i do it,lets say i want to show all of the furnitures ,max furnitures per house is 250,so i will have to loop 250 and do Furniture[houseid][i]
I would recommend the limit being 80 as there's no need for anything more in regards to furnishing a house.

If the player owns the house, say he wants to edit/display furniture ect. you would simply need to loop through the array:

for (new i = 0; i < MAX_PER_HOUSE; i++)
{
if (IsValidDynamicObject (Furniture[playerid][i][id]))
{
....
}
}

On mobile sorry.
Reply
#5

i got a reason to keep them 250,can i get any solution for it?
Reply
#6

If you want max 250 objects then try this

new MAX_HOUSEOBJECTS = 250;

for(new 1 = 0; 1 < MAX_HOUSEOBJECTS; i++)
Reply
#7

All your previous topics are about the size of amx file. Why are you concerned about its size? You can do the optimization part later when you finish your script. Just leave it as it is.
Reply
#8

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
If you want max 250 objects then try this

new MAX_HOUSEOBJECTS = 250;

for(new 1 = 0; 1 < MAX_HOUSEOBJECTS; i++)
Wrong. Then every time he wants to create a variable with MAX_HOUSEOBJECTS, he cannot do it without raising an error.

Eg.
pawn Код:
new variable[MAX_HOUSEOBJECTS];
This is still the best suggestion:
pawn Код:
Furniture[MAX_HOUSES][MAX_OBJECTS_PER_HOUSE];
Why would you have 250 furniture per house? That's ridiculous, you will never use up 250 objects on a single house... even 30 is an acceptable limit per house...

--

It depends what you're trying to do... if you're looping through ALL house objects in EVERY house, then you need to loop through all houses at the same time.

pawn Код:
for(new h = 0; h < MAX_HOUSES; h++)
{
    //check if house exists here?
    //check if house is owned here?
    for(new i = 0; i < MAX_OBJECTS_PER_HOUSE; i++)
    {
        if(!IsValidDynamicObject(Furniture[h][i])) continue;
        //Everything can be done where objectid = Furniture[h][i]
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)