Loading 1 all time when creating new.
#1

Ok. I have a problem, When I create a new ATM it loads 1, So the ATM's ID is always 1 and doesn't change, I want it so that when a player types /addatm it will create an ATM with an ID that hasn't be used for example if he creates 2 ATM's and he deletes ATM 1 it recreates ATM 1 then if he creates an other it creates ATM 3.

Here's my code.
pawn Код:
stock GetATMs()
{
    new file[60];
    for(new i = 0; i < MAX_ATM;i++)
    {
        format(file,sizeof(file),"ATMs/%i.ini",i);
        if(!dini_Exists(file)) continue;
    }
    return 1;
}
*Don't script much in sa-mp any more*.
Reply
#2

pawn Код:
stock GetATMs()
{
    new file[15];
    for(new i = 0; i < MAX_ATM;i++)
    {
        format(file,sizeof(file),"/ATMs/%i.ini",i);
        if(!dini_Exists(file)) return i;
    }
    return -1;
}
pawn Код:
new FreeSlot = GetATMs();
if(FreeSlot == -1) return Is now MAX_ATM files
// code here
Reply
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
stock GetATMs()
{
    new file[15];
    for(new i = 0; i < MAX_ATM;i++)
    {
        format(file,sizeof(file),"/ATMs/%i.ini",i);
        if(!dini_Exists(file)) return i;
    }
    return -1;
}
pawn Код:
new FreeSlot = GetATMs();
if(FreeSlot == -1) return Is now MAX_ATM files
// code here
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)