Writing to file problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Writing to file problem (
/showthread.php?tid=165200)
Writing to file problem -
roadless - 03.08.2010
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.
Re: Writing to file problem -
cofy1 - 03.08.2010
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;
}
Re: Writing to file problem -
roadless - 03.08.2010
Uhm, thank you, but this is a solution if you use separate .cfg files for every car.
Re: Writing to file problem -
cofy1 - 04.08.2010
Only add "plate" on top, register, login, and disconnect. If need help PM me