How to read specific line from a file?
#6

pawn Код:
CMD:createhouse(playerid, params[])
{
    new hinterior, hcost, HID;
    if(sscanf(params, "ddd", HID, hinterior, hcost)) scm(playerid, colorusage, "USAGE: /createhouse [HouseID] [Interior] [Price]");
    else if(pInfo[playerid][pAdmin] < 4) SendClientMessage(playerid, colorgrey, "<!> You're not authorized to use that command.");
    else if(!(0 <= hinterior <= 150)) scm(playerid, colorgrey, "<!> Invalid interior ID!");
    else
    {
        if(fexist(HousePath(HID))) return scm(playerid, colorgrey, "<!> House with that ID already exist!");
        new Float:X, Float:Y, Float:Z, pInter, pVirW;
        GetPlayerPos(playerid, X, Y, Z);
        pInter = GetPlayerInterior(playerid);
        pVirW = GetPlayerVirtualWorld(playerid);
        CreateHouse(HID, hinterior, X, Y, Z, pInter, pVirW, hcost);
    }
    return 1;
}

stock CreateHouse(HouseID, Unique, Float:X, Float:Y, Float:Z, OutsideInter, OutsideVirW, HousePrice)
{
    new File:HouseFile = fopen("HouseInteriors.cfg", io_read);
    new string[128], hinterior, Float:Pos[3];
    while(fread(HouseFile, string))
    {
        if(strval(string) == Unique)
        {
            sscanf(string,"{i}ia<f>[3]{s[64]}",hinterior, Pos);
            break;
        }
    }
    fclose(HouseFile);

    new INI:House = INI_Open(HousePath(HouseID));
    INI_WriteFloat(House, "EnterX", X);
    INI_WriteFloat(House, "EnterY", Y);
    INI_WriteFloat(House, "EnterZ", Z);
    INI_WriteFloat(House, "ExitX", Pos[0]);
    INI_WriteFloat(House, "ExitY", Pos[1]);
    INI_WriteFloat(House, "ExitZ", Pos[2]);
    INI_WriteInt(House, "InsideInt", hinterior);
    INI_WriteInt(House, "InsideVW", Unique+1);
    INI_WriteInt(House, "OutsideInt", OutsideInter);
    INI_WriteInt(House, "OutsideVW", OutsideVirW);
    INI_WriteInt(House, "Owned", 0);
    INI_WriteInt(House, "Price", HousePrice);
    INI_Close(House);
    printf("HouseID %d | UniqInteriorID: %d | Interior: %d | X: %.4f | Y: %.4f | Z: %.4f | OutsideInt: %d | OutsideVW: %d | Price: %d", HouseID, Unique, hinterior, Pos[0], Pos[1], Pos[2], OutsideInter, OutsideVirW, HousePrice);

    LoadHouse(HouseID, HousePath(HouseID));

    return 1;
}
Reply


Messages In This Thread
How to read specific line from INI file? - by Amel_PAtomAXx - 13.06.2014, 12:10
Re: How to read specific line from a file? - by Jefff - 13.06.2014, 12:19
Re: How to read specific line from a file? - by Amel_PAtomAXx - 13.06.2014, 12:30
Re: How to read specific line from a file? - by Threshold - 13.06.2014, 12:53
Re: How to read specific line from a file? - by Amel_PAtomAXx - 13.06.2014, 13:39
Re: How to read specific line from a file? - by Jefff - 13.06.2014, 14:27
Re: How to read specific line from a file? - by Amel_PAtomAXx - 13.06.2014, 14:36
Re: How to read specific line from a file? - by Amel_PAtomAXx - 13.06.2014, 16:01

Forum Jump:


Users browsing this thread: 1 Guest(s)