Something wrong with loading vehicle system?
#1

Is there something wrong with this code? the problem i am having is the showroom always creates with id zero.? so to me that means something is wrong with the GetEmptyShowroom but i don't know what :S Any help?

pawn Код:
// For Showrooms
new Iterator:SRs<MAX_SHOWROOM>;
pawn Код:
// -GetEmptyShowroomID
GetEmptyShowroomID()
{
    return Iter_Free(SRs);
}
pawn Код:
// For Showroom
// - 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;
}
Reply
#2

You don't need to create wrappers for iter functions, but if you really want, then why not

pawn Код:
#define GetEmptyShowroomID() Iter_Free(SRs)
Cannot reproduce problem, code: http://pastebin.com/rnyxdkQC
Reply
#3

still having problem :S if i pastebin the whole include could you have a look?
Reply
#4

bump still having problems :S
Reply
#5

It's been a few weeks and still have this problem can anyone help? Cheers
Reply
#6

pawn Код:
#define GetEmptyShowroomID() Iter_Free(SRs)
public CreateShowroom(Name[], Float:X, Float:Y, Float:Z)
{
    new
        CreatedID = GetEmptyShowroomID();
    printf("Showroom: Fetched showroom %d", CreatedID);
   
    Iter_Add(SRs, CreatedID);
   
    //I'm not quite sure what is LastShowroomID supposed to point at. Last
    //ID inserted is just one line higher, and it's CreatedID.
    //Iter_Last + 1 should be substituted with Iter_Free
    LastShowroomID = GetEmptyShowroomID();
    if(LastShowroomID == -1) {
        printf("Showroom: There is no more free slots!");
        return 0;
    }
   
    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;
}
Run this code, and give me the output from console/log.
Reply
#7

Still no luck came up saying

Quote:

Showroom: Fetched showroom 0

but still no luck when server restarts all pickups disappear and when you create a new showroom starts back at id 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)