Why this doesent save? - 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: Why this doesent save? (
/showthread.php?tid=190431)
Why this doesent save? -
Danny - 15.11.2010
Hi,
My question is simple: Why this doesent work?
Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
if(pVeh[playerid] != -1 && pVeh[playerid] == vehicleid)
{
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof file,"%s/%s.ini",CARFILE,pname);
if (dini_Exists(file))
{
dini_IntSet(file,"Color1",color1);
dini_IntSet(file,"Color2",color2);
return 1;
}
}
return 1;
}
And Yes, all variable's are valid.
Re: Why this doesent save? -
The_Moddler - 15.11.2010
Show us your CARFILE define.
Re: Why this doesent save? -
Danny - 15.11.2010
Код:
#define CARFILE "OwnedCars" //
It works on all the other car data .
Re: Why this doesent save? -
iggy1 - 15.11.2010
Aren't you supposed to check if the dini
doesn't exist? And if it doesn't - create it? I'm not sure i haven't used dini for a long time. From the looks of that code it will write the color to the file if the file exists, but if it doesn't exist it will do nothing. (and maybe cause a crash)
EDIT: I may be confused with the standard file functions not sure. Like i said i havn't used dini for a long time. (and even then i used it for a very short time)
Re: Why this doesent save? -
The_Moddler - 15.11.2010
pawn Код:
#define CARFILE OwnedCars
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
if(pVeh[playerid] != -1 && pVeh[playerid] == vehicleid)
{
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof file,"%s/%s.ini", CARFILE, pname);
if(dini_Exists(file))
{
dini_IntSet(file,"Color1",color1);
dini_IntSet(file,"Color2",color2);
}
else
{
dini_Create(file);
dini_IntSet(file,"Color1",color1);
dini_IntSet(file,"Color2",color2);
}
}
return 1;
}
Try now.
Re: Why this doesent save? -
Danny - 15.11.2010
This function will only be called if pVeh[playerid] is not -1. Ive made a function on another point in the script that creates a file if a player buys a car, so i dont have to create it.