Showroom Id Trouble
#1

When you create a showroom it works fine but if you restart server all showrooms are gone (files still in scriptfiles folder however) and if you create a new showroom it replaces the files in scriptfiles folder?

So i know it is something to do with LastShowroomID but not sure how to fix :S


pawn Код:
// - CreateShowroom
public CreateShowroom(Name[], Float:X, Float:Y, Float:Z)
{
    new CreatedID = GetEmptyShowroomID();

    Iter_Add(SRs, CreatedID);
    LastShowroomID = Iter_Last(SRs)+1;

    format(Showrooms[CreatedID][SRName], 100, Name);
    Showrooms[CreatedID][SRX] = X;
    Showrooms[CreatedID][SRY] = Y;
    Showrooms[CreatedID][SRZ] = Z;
    Showrooms[CreatedID][SRExist] = 1;

    Showrooms[CreatedID][SRPick] = CreatePickup(1239, 1, X, Y, Z, 0);

    new String[128];
    format(String, 128, "{ADFF2F}SHOWROOM\n{ADFF2F}%s\n{FFFFFF}Showroom ID {ADFF2F}%d", Showrooms[CreatedID][SRName], CreatedID);
    Showrooms[CreatedID][SR3D] = Create3DTextLabel(String, -1, X, Y, Z, 25.0, 0);
   
    new FileName[50];
    format(FileName, 50, "%s/Showroom_%d.ini", EVOVEHICLE_SHOWROOM_DIR, CreatedID);

    new INI:SRFile = INI_OpenFile(FileName);

    INI_SetTag(SRFile, "evo");

    INI_TypeString(SRFile, "NAME", Name);
    INI_TypeFloat(SRFile, "X", X);
    INI_TypeFloat(SRFile, "Y", Y);
    INI_TypeFloat(SRFile, "Z", Z);

    INI_CloseFile(SRFile);

    return CreatedID;
}

// - DeleteShowroom
public DeleteShowroom(showroomid)
{
    Showrooms[showroomid][SRExist] = 0;
    DestroyPickup(Showrooms[showroomid][SRPick]);
    Delete3DTextLabel(Showrooms[showroomid][SR3D]);

    Iter_Remove(SRs, showroomid);
    LastShowroomID = Iter_Last(SRs)+1;

    new FileName[50];
    format(FileName, 50, "%s/Showroom_%d.ini", EVOVEHICLE_SHOWROOM_DIR, showroomid);
    fremove(FileName);
}

// - LoadShowrooms
public LoadShowrooms()
{
    new SRFileName[50], Loadedcount, String[128];
   
    for(new i = LastLoadedSR; i < LastShowroomID; i++)
    {
        format(SRFileName, 50, "%s/Showroom_%d.ini", EVOVEHICLE_SHOWROOM_DIR, i);

        if(fexist(SRFileName))
        {
            INI_ParseFile(SRFileName, "LoadShowroom_%s", .bExtra = true, .extra = i);

            Showrooms[i][SRPick] = CreatePickup(1239, 1, Showrooms[i][SRX], Showrooms[i][SRY], Showrooms[i][SRZ], 0);

            format(String, 128, "{ADFF2F}SHOWROOM\n{ADFF2F}%s\n{FFFFFF}Showroom ID {ADFF2F}%d", Showrooms[i][SRName], i);
            Showrooms[i][SR3D] = Create3DTextLabel(String, -1, Showrooms[i][SRX], Showrooms[i][SRY], Showrooms[i][SRZ], 25.0, 0);

            Showrooms[i][SRExist] = 1;
           
            Loadedcount++;

            if(Loadedcount == 50)
            {
                LastLoadedSR = i+1;
                SetTimer("LoadShowrooms", 10000, 0);
                break;
            }
        }

        if(i == LastShowroomID-1)
        {
            LastLoadedSR = 0;
            break;
        }
    }
}

// - LoadShowroom_evo
public LoadShowroom_evo(ShowroomID, name[], value[])
{
    INI_String("NAME", Showrooms[ ShowroomID ][SRName], 100);
    INI_Float("X", Showrooms[ ShowroomID ][SRX]);
    INI_Float("Y", Showrooms[ ShowroomID ][SRY]);
    INI_Float("Z", Showrooms[ ShowroomID ][SRZ]);
    Showrooms[ ShowroomID ][SRExist] = 1;
    return 1;
}

// - Save Showrooms
public SaveShowrooms(last)
{
    new SRFileName[35], INI:SRFile, SavedCount;
    Unloading = last;
   
    for(new i = LastSavedSR; i < LastShowroomID; i++)
    {
        if(Showrooms[i][SRExist] == 1)
        {
            if(Showrooms[i][SRNeedSave] == 1)
            {
                if(SavedCount == 10 && Unloading == 0)
                {
                    LastSavedSR = i;
                    SetTimer("SaveShowrooms", 5000, 0);
                    break;
                }

                format(SRFileName, 35, "%s/Showroom_%d.ini", EVOVEHICLE_SHOWROOM_DIR, i);

                SRFile = INI_OpenFile(SRFileName);

                INI_SetTag(SRFile, "evo");

                INI_TypeString(SRFile, "NAME", Showrooms[i][SRName]);
                INI_TypeFloat(SRFile, "X", Showrooms[i][SRX]);
                INI_TypeFloat(SRFile, "Y", Showrooms[i][SRY]);
                INI_TypeFloat(SRFile, "Z", Showrooms[i][SRZ]);

                INI_CloseFile(SRFile);

                SavedCount++;
            }
        }

        if(i == LastShowroomID-1)
        {
            LastSavedSR = 0;
            break;
        }
    }
}
Reply
#2

i think this is my problem:

under

pawn Код:
// - LoadShowrooms
will this be loading all the .ini files in the folder?

pawn Код:
for(new i = LastLoadedSR; i < LastShowroomID; i++)
if not is there a way for it to automatically load every .ini in that folder?
Reply
#3

bump still had no luck can anyone help?
Reply
#4

Bump really need help with this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)