Writing to file problem
#1

Hi, everyone!

I am currently editing LA-RP, because I've just started with PAWN scripting. Trough my modifications to the script, I've tried to add an /regplate command for the cars that could be bought, which should in theory should save to the cars.cfg file. The problem is, it doesn't save.

Here is the /regplate command:
pawn Код:
if(strcmp(cmd, "/regplate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new plate[128];
            plate = strtok(cmdtext, idx);

            if(strlen(plate) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /regplate [SF-XXX-XXX]");
           
            new vehicleid;
            vehicleid = GetPlayerVehicleID(playerid);
            if(vehicleid > 183)
            {
                CarInfo[vehicleid][cLicense] = strval(plate);
                OnPropUpdate();
                OnPlayerUpdate(playerid);
                format(string, sizeof(string), "* You've registered the car with this plate: %s. The ID of the car is: %d", plate, vehicleid);
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
            return 1;
        }
        return 1;
    }
The thing is in the "You've registered the car with this plate:..." string, the plate and ID of the car, are correct.

Note: The other variables: owner/position/description, are being saved.

And yes I know this is a Godfather edit, and we should not to them anymore, but I'm currently at a noob level when it comes to scripting.
Reply
#2

pawn Код:
if(strcmp(cmd, "/regplate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new plate[128];
            plate = strtok(cmdtext, idx);

            if(strlen(plate) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /regplate [SF-XXX-XXX]");
           
            new vehicleid;
            new file[256];
            vehicleid = GetPlayerVehicleID(playerid);
            if(vehicleid > 183)
            {
                CarInfo[vehicleid][cLicense] = strval(plate);
                OnPropUpdate();
                OnPlayerUpdate(playerid);
                format(file,sizeof(file),"/file/cars.cfg");
                dini_Set(file,"plate",plate);
                format(string, sizeof(string), "* You've registered the car with this plate: %s. The ID of the car is: %d", plate, vehicleid);
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
            return 1;
        }
        return 1;
    }
Reply
#3

Uhm, thank you, but this is a solution if you use separate .cfg files for every car.
Reply
#4

Only add "plate" on top, register, login, and disconnect. If need help PM me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)