10.12.2014, 06:45
Boas, tenho o seguinte cуdigo:
Se eu usar assim:
O ficheiro escreve assim:
(caso o ficheiro nao exista..
Caso exista o ficheiro fica assim:
Repete em vez de apagar a linha..
pawn Код:
stock RT_setText(rt_lang[], rt_key[], rt_text[])
{
new File:rt_file, rt_Trans[128], text[250];
rt_file = fopen(formatDirectory(rt_lang));
while(fread(rt_file, rt_Trans)){
if(strfind(rt_Trans, rt_key, true) == 0){
fdeleteline(formatDirectory(rt_lang), rt_Trans);
}
}
format(text, sizeof text, "%s = %s\r\n", rt_key, rt_text);
fwrite(rt_file, text);
fclose(rt_file);
}
// Retirado da wiki ( Fdelete was made by Sacky. )
stock fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(strcmp(templine,line,true)){
strdel(temp,i-1,i+strlen(line)-1);
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}
stock fcreate(filename[])
{
if (fexist(filename)){return false;}
new File:fhandle = fopen(filename,io_write);
fclose(fhandle);
return true;
}
pawn Код:
RT_setText("pt", "CHAT_SAY", "%s (%d) diz:");
(caso o ficheiro nao exista..
Код:
HELLO = OlГЎ, %s! CHAT_SAY = %s (%d) diz:
Код:
HELLO = OlГЎ, %s! CHAT_SAY = %s (%d) diz: HELLO = OlГЎ, %s! CHAT_SAY = %s (%d) diz: