SA-MP Forums Archive
[help] load pikcups and objects from file - 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: [help] load pikcups and objects from file (/showthread.php?tid=197061)



[help] load pikcups and objects from file - roi857 - 07.12.2010

i want load pickups from file in command, in taht way, in file:
"pickup %d %d %f %f %f" or "CreatePickup(...."


Re: [help] load pikcups and objects from file - Toreno - 07.12.2010

I'm not sure it works. However, try it... it looks to me.

First, put this ontop of your GM.
pawn Код:
forward LoadPickUps();
Now, you can put this under forward LoadPickUps();
pawn Код:
enum puInfo
{
    puModel,
    puType,
    Float:puCoordX,
    Float:puCoordY,
    Float:puCoordZ,
    puVirtualW,
};
new PickUpInfo[MAX_PLAYERS][puInfo];
And now go to your scriptfiles, open a new text tile with the name pickups.txt
after that put this function where ever you want on your GM
pawn Код:
public LoadPickUps()
{
    new Coords[30][128];
    new string[256];
    new File: file = fopen("pickups.txt", io_read);
    if(file)
    {
        new idx;
        while (idx < sizeof(PickUpInfo))
        {
            fread(file, string);
            split(string, Coords, ',');
            PickUpInfo[idx][puModel] = floatstr(Coords[0]);
            PickUpInfo[idx][puType] = floatstr(Coords[1]);
            PickUpInfo[idx][puCoordX] = floatstr(Coords[2]);
            PickUpInfo[idx][puCoordY] = floatstr(Coords[3]);
            PickUpInfo[idx][puCoordZ] = floatstr(Coords[4]);
            PickUpInfo[idx][puVirtualW] = floatstr(Coords[5]);
            idx++;
        }
        fclose(file);
    }
    return 1;
}
after you did all this, go to your OnGameModeInit()
and put under it this:
pawn Код:
LoadPickUps();
then under it:
pawn Код:
for(new p = 0; p < sizeof(PickUpInfo); p++)
{
    CreatePickup(PickUpInfo[p][puModel], PickUpInfo[p][puType], PickUpInfo[p][puCoordX], HouseInfo[p][puCoordY], HouseInfo[p][puCoordZ], PickUpInfo[p][puVirtualW]);
}
now, go to your text file (pickups.txt)
and it works like that
1241, 2, 1503.3359, 1432.3585, 10.1191, -1
1242, 1, 1503.3359, 1432.3585, 10.1191, 0
1245, 3, 1503.3359, 1432.3585, 10.1191, 0

each one is pickup, you need to modify each one them,
Not tested, I guess it needs to work...

it looks good to me, test it and tell me, for help talk to me


Re : [help] load pikcups and objects from file - timaoux - 30.08.2011

sorry for discussion reporter but i want know something, @Toreno did you know how to do that with dini ?