29.05.2012, 19:21
Hi people.
I have a little system here to save the date of the last time a person entered a Gun shop.
Here's the code:
Code to delete the line.
On the command "/enter" and "/exit" I have the LastGunShopEntered(playerid);
Now Ingame, when I get in the Gunshop ID 2.
This is what happens in the file..
GunShop:0 - Date:10|03|2000
GunShop:1 - Date:10|03|2000
GunShop:3 - Date:10|03|2000
GunShop:4 - Date:10|03|2000
GunShop:5 - Date:10|03|2000
GunShop:2 - Date:29|05|2012
The order gets messed up, can somebody help with this? Please.
I have a little system here to save the date of the last time a person entered a Gun shop.
Here's the code:
pawn Код:
public LastGunShopDate(playerid)
{
new str[128];
new File:enter;
new year,month,day;
getdate(year, month, day);
format(str, sizeof(str), "Gunshop:%d",P_Info[playerid][gunkey]);
fdeleteline("guns.cfg",str);
new sstr[128];
format(sstr, sizeof(sstr), "GunShop:%d - Date:%02d|%02d|%d\r\n",P_Info[playerid][gunkey],day,month,year);
enter=fopen("guns.cfg", io_append);//
fwrite(enter, sstr);
fclose(enter);
return 1;
}
pawn Код:
stock fdeleteline(filename[], removed[])
{
new string[64], str[32], File:handle, File:ftmp;
handle = fopen(filename,io_read);
format(str,sizeof(str),"%s.pt",filename);
ftmp = fopen(str,io_write);
while(fread(handle,string))
if(strfind(string,removed) == -1)
fwrite(ftmp,string);
fclose(handle);
fclose(ftmp);
handle = fopen(filename,io_write);
ftmp = fopen(str,io_read);
while(fread(ftmp,string))
fwrite(handle,string);
fclose(handle);
fclose(ftmp);
return fremove(str);
}
Now Ingame, when I get in the Gunshop ID 2.
This is what happens in the file..
GunShop:0 - Date:10|03|2000
GunShop:1 - Date:10|03|2000
GunShop:3 - Date:10|03|2000
GunShop:4 - Date:10|03|2000
GunShop:5 - Date:10|03|2000
GunShop:2 - Date:29|05|2012
The order gets messed up, can somebody help with this? Please.