stock LoadBiz()
{
if(!fexist(PATH)) return 1;
new File:i=fopen(PATH, io_read), st[1020], idx;
while(idx < sizeof(BusinessInfo) && fread(i, st))
{
sscanf(st, "p<|>iis[32]iiiffffffffiiiis[128]",
BusinessInfo[idx][bOwned],
BusinessInfo[idx][bPrice],
BusinessInfo[idx][bOwner],
BusinessInfo[idx][bType],
BusinessInfo[idx][bLocked],
BusinessInfo[idx][bMoney],
BusinessInfo[idx][bEntranceX],
BusinessInfo[idx][bEntranceY],
BusinessInfo[idx][bEntranceZ],
BusinessInfo[idx][bEntranceA],
BusinessInfo[idx][bExitX],
BusinessInfo[idx][bExitY],
BusinessInfo[idx][bExitZ],
BusinessInfo[idx][bExitA],
BusinessInfo[idx][bInt],
BusinessInfo[idx][bWorld],
BusinessInfo[idx][bInsideInt],
BusinessInfo[idx][bInsideWorld],
BusinessInfo[idx][bName]
);
}
fclose(i);
BusinessInfo[idx][bOutsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[idx][bEntranceX], BusinessInfo[idx][bEntranceY], BusinessInfo[idx][bEntranceZ], BusinessInfo[idx][bWorld]); //Creates a pickup at the business entrance.
BusinessInfo[idx][bInsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[idx][bExitX], BusinessInfo[idx][bExitY], BusinessInfo[idx][bExitZ], BusinessInfo[idx][bInsideWorld]); //Creates a pickup at the exit(Inside the interior)
printf("%f|||%f|||%f|||%d", BusinessInfo[idx][bEntranceX], BusinessInfo[idx][bEntranceY], BusinessInfo[idx][bEntranceZ], BusinessInfo[idx][bWorld]);
print("done");
return 1;
}
if (strcmp("/savemyhp", cmdtext, true) == 0)
{
new pname[32],Float:health, str[200];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
GetPlayerHealth(playerid, health);
new File:hp=fopen("/UsersHP.ini", io_append);
if(hp)
{
format(str, sizeof(str), "%s(hp)=%f\r\n", pname, health); fwrite(hp, str);
fclose(hp);
}
return 1;
}
if (strcmp("/loadmyhp", cmdtext, true) == 0)
{
new File:hp=fopen("/UsersHP.ini", io_read), string[200], str[200];
fread(hp, str);
format(string, 200, "The health you saved = %f", floatstr(str));
SendClientMessage(playerid, -1, string);
fclose(hp);
return 1;
}
That happened to me once. Finally I avoided the problem reading those parameters as strings and then converting them to floats with floatstr.
It isn't the most professional solution, but it works. |
format(string, 200, "The health you saved = %f", floatstr(str));
pawn Код:
|
stock SaveBiz(id)
{
new File:File=fopen(PATH, io_write);
if(File)
{
new str[165];
fwrite(File,"[data]\r\n");
format(str,30,"bOwned=%d\r\n", BusinessInfo[id][bOwned]); fwrite(File, str);
format(str,30,"bPrice=%d\r\n", BusinessInfo[id][bPrice]); fwrite(File, str);
format(str,30,"bOwner=%s\r\n", BusinessInfo[id][bOwner]); fwrite(File, str);
format(str,30,"bType=%d\r\n", BusinessInfo[id][bType]); fwrite(File, str);
format(str,30,"bLocked=%d\r\n", BusinessInfo[id][bLocked]); fwrite(File, str);
format(str,30,"bMoney=%d\r\n", BusinessInfo[id][bMoney]); fwrite(File, str);
format(str,30,"bEntranceX=%f\r\n", BusinessInfo[id][bEntranceX]); fwrite(File, str);
format(str,30,"bEntranceY=%f\r\n", BusinessInfo[id][bEntranceY]); fwrite(File, str);
format(str,30,"bEntranceZ=%f\r\n", BusinessInfo[id][bEntranceZ]); fwrite(File, str);
format(str,30,"bEntranceA=%f\r\n", BusinessInfo[id][bEntranceA]); fwrite(File, str);
format(str,30,"bExitX=%f\r\n", BusinessInfo[id][bExitX]); fwrite(File, str);
format(str,30,"bExitY=%f\r\n", BusinessInfo[id][bExitY]); fwrite(File, str);
format(str,30,"bExitZ=%f\r\n", BusinessInfo[id][bExitZ]); fwrite(File, str);
format(str,30,"bExitA=%f\r\n", BusinessInfo[id][bExitA]); fwrite(File, str);
format(str,30,"bInt=%d\r\n", BusinessInfo[id][bInt]); fwrite(File, str);
format(str,30,"bWorld=%d\r\n", BusinessInfo[id][bWorld]); fwrite(File, str);
format(str,30,"bInsideInt=%d\r\n", BusinessInfo[id][bInsideInt]); fwrite(File, str);
format(str,30,"bInsideWorld=%d\r\n", BusinessInfo[id][bInsideWorld]); fwrite(File, str);
format(str,30,"bName=%s\r\n", BusinessInfo[id][bName]); fwrite(File, str);
fclose(File);
}
fclose(File);
return 1;
}
Did you take a look at this method handling data in files? https://sampforum.blast.hk/showthread.php?tid=430722
|
if (strcmp("/loadmyhp", cmdtext, true) == 0)
{
new File:hp=fopen("/UsersHP.ini", io_read), string[200], str[200];
fread(hp, str);
format(string, 200, "The health you saved = %f", floatstr(str));
SendClientMessage(playerid, -1, string);
fclose(hp);
return 1;
}