File format.
#1

pawn Код:
public OnPropUpdate()
{
    new idx;
    new File: file2;
    while (idx < sizeof(HouseInfo)) {
        new coordsstring[255];
        format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n\r",
            HouseInfo[idx][hEntrancex],
            HouseInfo[idx][hEntrancey],
            HouseInfo[idx][hEntrancez],
            HouseInfo[idx][hExitx],
            HouseInfo[idx][hExity],
            HouseInfo[idx][hExitz],
            HouseInfo[idx][hHealthx],
            HouseInfo[idx][hHealthy],
            HouseInfo[idx][hHealthz],
            HouseInfo[idx][hArmourx],
            HouseInfo[idx][hArmoury],
            HouseInfo[idx][hArmourz],
            HouseInfo[idx][hOwner],
            HouseInfo[idx][hDiscription],
            HouseInfo[idx][hValue],
            HouseInfo[idx][hHel],
            HouseInfo[idx][hArm],
            HouseInfo[idx][hInt],
            HouseInfo[idx][hLock],
            HouseInfo[idx][hOwned],
            HouseInfo[idx][hRooms],
            HouseInfo[idx][hRent],
            HouseInfo[idx][hRentabil],
            HouseInfo[idx][hTakings],
            HouseInfo[idx][hVec],
            HouseInfo[idx][hVcol1],
            HouseInfo[idx][hVcol2],
            HouseInfo[idx][hDate],
            HouseInfo[idx][hLevel],
            HouseInfo[idx][hWorld],
            HouseInfo[idx][hOutWorld],
            HouseInfo[idx][hOutInt],
            HouseInfo[idx][hOTaken]);
        HouseInfo[idx][hWorld] = idx;
        if(idx == 0) {
            file2 = fopen("cfgs/property.cfg", io_write);
        }
        else {
            file2 = fopen("cfgs/property.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
As you see, I've got this code above, and it saves it by each line and formatting it.
But each time that someone moves a house ingame, in the property.cfg, it's getting messy.
Any reason ?
Reply
#2

What do you mean by messy?
Reply
#3

It doesn't make everything in lines, everything is together.
Reply
#4

Quote:
Originally Posted by Darnell
Посмотреть сообщение
It doesn't make everything in lines, everything is together.
Maybe that's because of this line?
pawn Код:
new coordsstring[255];
        format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n\r",
Or do you mean something else by "Everything is together"?
Reply
#5

You mean you want to write them in each lines?
Use "\n" instead "," then.
Reply
#6

You probabrly didn't understood.
In the file, I write it like this for example.
Код:
-2087.8040,2478.4866,48.3979,-2077.9951,2476.3862,41.9455,0,0,0,0,0,0,The State,Mansion,1,0,0,0,1,0,3,0,0,0,0,0,0,0,2
-2077.9951,2266.5142,5.4755,1267.663208,-781.323242,1091.906250,0,0,0,0,0,0,The State,Mansion,1,0,0,5,1,0,3,0,0,0,0,0,0,0,2
But then, if someone moves it, it's like that.
Код:
-2087.8040,2478.4866,48.3979,-2077.9951,2476.3862,41.9455,0,0,0,0,0,0,The State,Mansion,1,0,0,0,1,0,3,0,0,0,0,0,0,0,2-2077.9951,2266.5142,5.4755,1267.663208,-781.323242,1091.906250,0,0,0,0,0,0,The State,Mansion,1,0,0,5,1,0,3,0,0,0,0,0,0,0,2
Reply
#7

What's the command for when someone moves a house or whatever?
Reply
#8

/houseentrance, in this case.
pawn Код:
if(strcmp(cmd, "/houseentrance", true) == 0) {
        if(IsPlayerConnected(playerid)) {
            if (PlayerInfo[playerid][pAdmin] < 10) {
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /houseentrance [houseid] - Moves a house to you");
                return 1;
            }
            new proplev = strval(tmp);
            if(proplev > sizeof(HouseInfo) || proplev < 0) {
                SendClientMessage(playerid,COLOR_WHITE,"House ID must be above 0 and below 33");
                return 1;
            }
            else {
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(playerid,X,Y,Z);
                format(string,sizeof(string),"Entrance of House %d to %f - %f - %f",proplev,X,Y,Z);
                ABroadCast(COLOR_YELLOW,string,5);
                HouseInfo[proplev][hEntrancex] = X;
                HouseInfo[proplev][hEntrancey] = Y;
                HouseInfo[proplev][hEntrancez] = Z;
                OnPropUpdate();
                return 1;
            }
        }
    }
Reply
#9

Try using "\r\n" instead of just "\n"
Reply
#10

Much love Jack, repped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)