31.05.2012, 16:15
You can use this function
pawn Код:
stock freplaceline(filename[], find[], replace[])
{
if(!fexist(filename)) return 0;
new File:handle = fopen(filename, io_read);
if(!handle) return 0;
new File:tmp = ftemp();
if(!tmp)
{
fclose(handle);
return 0;
}
new line[256];
while(fread(handle, line))
{
if(strfind(line, find) == -1)
fwrite(tmp, line);
else
fwrite(tmp, replace);
}
fclose(handle);
fseek(tmp, 0);
handle = fopen(filename, io_write);
if(!handle)
{
fclose(tmp);
return 0;
}
while(fread(tmp, line))
{
fwrite(handle, line);
}
fclose(handle);
fclose(tmp);
return 1;
}
pawn Код:
public LastGunShopDate(playerid)
{
new str[128], sstr[128];
new year,month,day;
getdate(year, month, day);
format(str, sizeof(str), "Gunshop:%d",P_Info[playerid][gunkey]);
format(sstr, sizeof(sstr), "GunShop:%d - Date:%02d|%02d|%d\r\n",P_Info[playerid][gunkey],day,month,year);
freplaceline("guns.cfg",str,sstr);
return 1;
}