Question about variables
#1

Well, anyone should know that:
pawn Code:
new cars[100] ; // You can make 100 cars using one variable
But since I saw on GarHouse script a thing, I wonder: How do I save these variables on a file, and according new cars ( example ), are create, the variable goes up + 1. Like on GarHouse IDS:

I made my first house. The second one will be 1, and so... so... so...
Code:
 0, 1, 2, 3
It'd be on dini. For determine a variable for each owned vehicle by a player. Thx.
Reply
#2

Well you can't change the size of an array after it has been created, if that's what you're talking about.
Reply
#3

I mean on house system, when you make the first house, the ID is 0. The second 1. The thrid 2. And the house are defined maybe by some array, according they're loaded. And I'd like to make that with vehicle. Each time one is created, will be the old one ID + 1
Reply
#4

You can use this code:
pawn Code:
stock GetFreeHouseID()
{
    new file[128];
    for(new h = 0;h < 800; h++)
    {
        format(file, sizeof(file), "/Houses/%d.ini", h); // You will have to rename this to your own file destination
        if(!dini_Exists(file))
        {
            return h;
        }
    }
    return -1;
}
But that will check, whats the next ID of a house. So, you will have to name them like 00.ini, 01.ini and so on...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)