SA-MP Forums Archive
Not loading (?) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Not loading (?) (/showthread.php?tid=528387)



Not loading (?) - Beckett - 27.07.2014

pawn Код:
OnGameModeInit()
{
    new string[40];
    for(new idx = 0; idx < sizeof(HInfo); idx++)
    {
        format(string, sizeof(string),HOUSE_PATH, idx);
        INI_ParseFile(string, "LoadHouses_%d", .bExtra = true, .extra = idx );
        new labelstring[100];
        switch(HInfo[idx][Owned])
        {
            case 0:{format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HInfo[idx][Price]);}
            case 1:{format(labelstring,sizeof(labelstring),"Owned: Yes \n Owner: %s",HInfo[idx][Owner]);}
        }
        HInfo[idx][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,HInfo[idx][XPos],HInfo[idx][YPos],HInfo[idx][ZPos],25.0,HInfo[idx][VirtualWorld]);

    }
}
Well another thing about this house system I'm almost done with it but I'm stuck right here this code compiles fine but the thing is it isn't loading anything from the file why so? even the Textlabel isn't being loaded.

Thanks.


Re: Not loading (?) - [XST]O_x - 27.07.2014

Can you show your LoadHouses callback?


Re: Not loading (?) - Beckett - 27.07.2014

pawn Код:
public LoadHouses(idx, name[], value[])
{
        INI_Float("XPos",HInfo[idx][XPos]);
        INI_Float("YPos",HInfo[idx][YPos]);
        INI_Float("ZPos",HInfo[idx][ZPos]);
        INI_Int("Owned",HInfo[idx][Owned]);
        INI_Int("Price",HInfo[idx][Price]);
        INI_String("Owner",HInfo[idx][Owner],25);
        INI_Int("VirutalWorld",HInfo[idx][VirtualWorld]);
        return 1;
}



Re: Not loading (?) - Beckett - 27.07.2014

------


Re: Not loading (?) - Threshold - 27.07.2014

pawn Код:
INI_ParseFile(string, "LoadHouses_%d", .bExtra = true, .extra = idx );
This function would be used to load 'tags' from the LoadHouses function, but LoadHouses uses no tags, so you want to pass the tag through the function by doing the following:
pawn Код:
INI_ParseFile(string, "LoadHouses", .bExtra = true, .extra = idx, .bPassTag = true);
Also, I recommend that you check the file exists for doing this, so I've added that in for you.

Your complete code is:
pawn Код:
public OnGameModeInit()
{
    new string[40];
    for(new idx = 0; idx < sizeof(HInfo); idx++)
    {
        format(string, sizeof(string), HOUSE_PATH, idx);
        if(!fexist(string)) continue;
        INI_ParseFile(string, "LoadHouses", .bExtra = true, .extra = idx, .bPassTag = true);
        new labelstring[50];
        if(!HInfo[idx][Owned]) format(labelstring, sizeof(labelstring), "Owned: No \nPrice: %i", HInfo[idx][Price]);
        else format(labelstring, sizeof(labelstring), "Owned: Yes \n Owner: %s", HInfo[idx][Owner]);
        HInfo[idx][HouseLabel] = Create3DTextLabel(labelstring, 0xFF0000FF, HInfo[idx][XPos], HInfo[idx][YPos], HInfo[idx][ZPos], 25.0, HInfo[idx][VirtualWorld]);
    }
    return 1;
}



Re: Not loading (?) - Beckett - 27.07.2014

Okay so I've done what you said and didn't work either. However I've made a print to the console that says how many houses has been loaded, it says (1) which is right that means it's working but at the same time it's not, why so? I believe the issue is in INI_ParseFile or where?


AW: Not loading (?) - Threshold - 28.07.2014

Hmmm can you show where you save the values in the file ?


Re: Not loading (?) - BroZeus - 28.07.2014

you probably forgot to use INI_SetTag while saving
Lets assume that you saved with "data" [case sensitive] as a tag
so now the loading and public header for loading would be --
Quote:

INI_ParseFile(string, "LoadHouses_%s", .bExtra = true, .extra = idx);

public LoadHouses_data(idx, name[], value[])




Re: Not loading (?) - Threshold - 28.07.2014

You wouldn't need bPassTag in the INI_ParseFile function if you were to approach it that way.


Re: AW: Not loading (?) - Beckett - 28.07.2014

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Hmmm can you show where you save the values in the file ?
pawn Код:
public SaveHouse(id)
{
    new file4[40];
    format(file4, sizeof(file4),HOUSE_PATH, id);
    new INI:File = INI_Open(file4);
    INI_WriteInt(File,"Owned",HInfo[id][Owned]);
    INI_WriteInt(File,"Price",HInfo[id][Price]);
    INI_WriteString(File,"Owner",HInfo[id][Owner]);
    INI_WriteFloat(File,"XPos",HInfo[id][XPos]);
    INI_WriteFloat(File,"YPos", HInfo[id][YPos]);
    INI_WriteFloat(File,"ZPos",HInfo[id][ZPos]);
    INI_Close(File);
    return 1;
}