[Help] My car system
#1

Hey guys,

I just added some things to my car system but each time the server saves the cars, the codes in cars.cfg gets messed up.

I dont really know why, the last things I added to the system is cImpound & cImpoundOfficer
The cImpound on the server shoud there be like a text on for example ~g~Impounded
and cImpoundOfficer the officers name.

But when I use this command the codes work when I restart the server the cars.cfg is a hole mess.
pawn Код:
if(strcmp(cmd, "/impoundcar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new Float:x,Float:y,Float:z;
            new Float:a;
            new carid;
            carid = GetPlayerVehicleID(playerid);
            GetPlayerName(playerid, playername, sizeof(playername));
            GetVehiclePos(carid, x, y, z);
//          GetPlayerFacingAngle(playerid, a);
            GetVehicleZAngle(carid, a);
            if(PlayerInfo[playerid][pAdmin] >= 2 || IsACop(playerid) || PlayerInfo[playerid][pJob] == 7)
            {
                new Impounded[9];
                format(Impounded, sizeof(Impounded), "~y~Impounded");
                CarInfo[carid][cLocationx] = x;
                CarInfo[carid][cLocationy] = y;
                CarInfo[carid][cLocationz] = z+0.5;
                CarInfo[carid][cAngle] = a;
                strmid(CarInfo[carid][cImpound], Impounded, 0, strlen(Impounded), 9);
                strmid(CarInfo[carid][cImpoundOfficer], playername, 0, strlen(playername), 30);
                GameTextForPlayer(playerid, "You have impounded this vehicle.", 10000, 3);
                OnPropUpdate();
                OnPlayerUpdateEx(playerid);
                DestroyVehicle(carid);
                CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                SetVehicleModifications(carid);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not authorized to use that command !");
                return 1;
            }
        }
        return 1;
    }
Here are the Code for the save system
pawn Код:
idx = 364;
    while (idx < sizeof(CarInfo))
    {
        new coordsstring[500];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s,%s\n",
        CarInfo[idx][cModel],
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        CarInfo[idx][cColorOne],
        CarInfo[idx][cColorTwo],
        CarInfo[idx][cOwner],
        CarInfo[idx][cLicense],
        CarInfo[idx][cOwned],
        CarInfo[idx][cLock],
        CarInfo[idx][cPaintjob],
        CarInfo[idx][cVirWorld],
        CarInfo[idx][cComponent0],
        CarInfo[idx][cComponent1],
        CarInfo[idx][cComponent2],
        CarInfo[idx][cComponent3],
        CarInfo[idx][cComponent4],
        CarInfo[idx][cComponent5],
        CarInfo[idx][cComponent6],
        CarInfo[idx][cComponent7],
        CarInfo[idx][cComponent8],
        CarInfo[idx][cComponent9],
        CarInfo[idx][cComponent10],
        CarInfo[idx][cComponent11],
        CarInfo[idx][cComponent12],
        CarInfo[idx][cComponent13],
        CarInfo[idx][cTicket],
        CarInfo[idx][cWarn],
        CarInfo[idx][cImpound],
        CarInfo[idx][cImpoundOfficer]);
        if(idx == 364)
        {
            file2 = fopen("cars.cfg", io_write);
        }
        else
        {
            file2 = fopen("cars.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);

    }
pawn Код:
enum cInfo
{
    cModel,
    Float:cLocationx,
    Float:cLocationy,
    Float:cLocationz,
    Float:cAngle,
    cColorOne,
    cColorTwo,
    cOwner[MAX_PLAYER_NAME],
    cOwned,
    cLock,
    cPaintjob,
    cVirWorld,
    cComponent0,
    cComponent1,
    cComponent2,
    cComponent3,
    cComponent4,
    cComponent5,
    cComponent6,
    cComponent7,
    cComponent8,
    cComponent9,
    cComponent10,
    cComponent11,
    cComponent12,
    cComponent13,
    cLicense[30],
    cTicket,
    cWarn,
    cTrunk,
    cImpound[30],
    cImpoundOfficer[MAX_PLAYER_NAME],
};

new CarInfo[1165][cInfo];
The working line on the car system
pawn Код:
400,10000.000000,10000.000000,10000.000000,0.000000,0,0,Dealership,5BBM,0,0,999,9999,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,~g~Released,None
After I tested the command
pawn Код:
400,10000.000000,10000.000000,10000.000000,0.000000,0,0,Dealership,5BBM,0,0,999,9999,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,None
,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)