Is this correct? Saving/Loading with dini
#1

Have I written this correctly?

pawn Код:
forward SaveToys(playerid);
public SaveToys(playerid)
{
    if(IsPlayerConnected(playerid) && PLogged[playerid])
    {
        new stringtoy[55];
        format(stringtoy, sizeof(stringtoy), "South-WestRP/PlayerToys/%s.ini", GetPlayerNameEx(playerid));
        if(!dini_Exists(stringtoy)) dini_Create(stringtoy);
        for(new x = 0; x < MAX_TOYS; x++)
        {
            dini_IntSet(stringtoy, "tCreated", ToyInfo[playerid][x][tCreated]);
            dini_IntSet(stringtoy, "tEquipped", ToyInfo[playerid][x][tEquipped]);
            dini_Set(stringtoy, "tName", ToyInfo[playerid][x][tName]);
            dini_IntSet(stringtoy, "tIndexID", ToyInfo[playerid][x][tIndexID]);
            dini_IntSet(stringtoy, "tModelID", ToyInfo[playerid][x][tModelID]);
            dini_IntSet(stringtoy, "tBoneID", ToyInfo[playerid][x][tBoneID]);
            dini_FloatSet(stringtoy, "tOffsetX", ToyInfo[playerid][x][tOffsetX]);
            dini_FloatSet(stringtoy, "tOffsetY", ToyInfo[playerid][x][tOffsetY]);
            dini_FloatSet(stringtoy, "tOffsetZ", ToyInfo[playerid][x][tOffsetZ]);
            dini_FloatSet(stringtoy, "tRotX", ToyInfo[playerid][x][tRotX]);
            dini_FloatSet(stringtoy, "tRotY", ToyInfo[playerid][x][tRotY]);
            dini_FloatSet(stringtoy, "tRotZ", ToyInfo[playerid][x][tRotZ]);
            dini_FloatSet(stringtoy, "tScaleX", ToyInfo[playerid][x][tScaleX]);
            dini_FloatSet(stringtoy, "tScaleY", ToyInfo[playerid][x][tScaleY]);
            dini_FloatSet(stringtoy, "tScaleZ", ToyInfo[playerid][x][tScaleZ]);
        }
    }
    return 1;
}

forward LoadToys(playerid);
public LoadToys(playerid)
{
    new stringtoy[55];
    format(stringtoy, sizeof(stringtoy), "South-WestRP/PlayerToys/%s.ini", GetPlayerNameEx(playerid));
    if(!dini_Exists(stringtoy)) return 0;
    for(new x = 0; x < MAX_TOYS; x++)
    {
        ToyInfo[playerid][x][tCreated] = dini_Int(stringtoy, "tCreated");
        ToyInfo[playerid][x][tEquipped] = dini_Int(stringtoy, "tEquipped");
        strmid(ToyInfo[playerid][x][tName], dini_Get(stringtoy, "tName"), 0, strlen(dini_Get(stringtoy, "tName")), 128);
        ToyInfo[playerid][x][tIndexID] = dini_Int(stringtoy, "tIndexID");
        ToyInfo[playerid][x][tModelID] = dini_Int(stringtoy, "tModelID");
        ToyInfo[playerid][x][tBoneID] = dini_Int(stringtoy, "tBoneID");
        ToyInfo[playerid][x][tOffsetX] = dini_Float(stringtoy, "tOffsetX");
        ToyInfo[playerid][x][tOffsetY] = dini_Float(stringtoy, "tOffsetY");
        ToyInfo[playerid][x][tOffsetZ] = dini_Float(stringtoy, "tOffsetZ");
        ToyInfo[playerid][x][tRotX] = dini_Float(stringtoy, "tRotX");
        ToyInfo[playerid][x][tRotY] = dini_Float(stringtoy, "tRotY");
        ToyInfo[playerid][x][tRotZ] = dini_Float(stringtoy, "tRotZ");
        ToyInfo[playerid][x][tScaleX] = dini_Float(stringtoy, "tScaleX");
        ToyInfo[playerid][x][tScaleY] = dini_Float(stringtoy, "tScaleY");
        ToyInfo[playerid][x][tScaleZ] = dini_Float(stringtoy, "tScaleZ");
    }
    return 1;
}
Reply
#2

I just tried testing this out and for some reason it only loaded toy 1 for all 10 toys.

For example [x] is 0 - 9

When I do /toysinv it shows what I have in my inventory so..

Toy: Azure Hat
Toy2: Police Hat

It only loaded
Toy: Azure Hat
Toy2: Azure Hat
Toy3: Azure Hat
etc

What's wrong with my code?

EDIT: It also saves only 1 toy to the file and does not save it correctly
Reply
#3

Quote:
Originally Posted by ColeMiner
Посмотреть сообщение
Don't double post.
Do you know how dini works or not? If so could you tell me why this is not working the way I want it to?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)