native TS_CriarArquivo(filename[]);
native TS_DeletarArquivo(filename[]);
native TS_CarregarArquivo(filename[]);
native TS_SalvarArquivo();
native TS_FecharArquivo();
native TS_EscreverString(filename[], linename[], string[]);
native TS_EscreverInt(filename[], linename[], inteiro);
native TS_LerString(linename[]);
native TS_LerInt(linename[]);
#include a_samp
new NomeArquivo[50];
new Conteudo[1000];
/*
native TS_CriarArquivo(filename[]);
native TS_DeletarArquivo(filename[]);
native TS_CarregarArquivo(filename[]);
native TS_SalvarArquivo();
native TS_FecharArquivo();
native TS_EscreverString(filename[], linename[], string[]);
native TS_EscreverInt(filename[], linename[], inteiro);
native TS_LerString(linename[]);
native TS_LerInt(linename[]);
*/
#define TS_DeletarArquivo(%0) fremove(%0)
stock TS_CriarArquivo(filename[])
{
if(fexist(filename)) return false;
new File: Arquivo = fopen( filename, io_write );
fclose(Arquivo);
return true;
}
stock TS_CarregarArquivo(filename[])
{
new File: Arquivo;
new string[3000];
new linhas[128];
Arquivo = fopen(filename,io_read);
while(fread(Arquivo,linhas))
{
format(string,3000,"%s%s",string,linhas);
}
fclose(Arquivo);
strmid(Conteudo, string, 0, strlen(string), 255);
strmid(NomeArquivo, filename, 0, strlen(filename), 255);
return true;
}
stock TS_EscreverInt(linename[], inteiro)
{
new string[128];
format(string, sizeof string, "%d", inteiro);
return TS_EscreverString(linename, string);
}
stock TS_EscreverString(linename[], string[])
{
new Igual[60];
format(Igual, sizeof Igual, "%s=", linename);
if(strfind(Conteudo,Igual,false) == -1)
{
format(Conteudo, 500, "%s%s%s\r\n",Conteudo, Igual, string);
}
else
{
strdel(Conteudo, strfind(Conteudo,Igual,false) + strlen(Igual), strfind(Conteudo, "\r\n", false));
strins( Conteudo, string, strfind(Conteudo,Igual,false) + strlen(Igual) );
}
return false;
}
stock TS_SalvarArquivo()
{
new File: Arquivo;
Arquivo = fopen( NomeArquivo, io_write );
fwrite( Arquivo, Conteudo );
fclose(Arquivo);
return true;
}
stock TS_LerInt(filename[], linename[])
return strval(TS_LerString(filename, linename));
stock TS_LerString(filename[], linename[])
{
new result[200];
new igual[60];
new File: Arquivo;
new string[3000];
new linhas[200];
Arquivo = fopen(filename,io_read);
while(fread(Arquivo,linhas))
{
format(string,3000,"%s%s",string,linhas);
}
fclose(Arquivo);
format(igual,51,"%s=",linename);
if(strfind(string,igual,false) != -1)
{
strmid(result,string,strfind(string, igual, false)+strlen(igual),strfind(string,"\r\n",false,strfind(string, igual, false)+strlen(igual)));
}
return result;
}
Voce nгo pode dar rep, entгo nгo fale isso sу porque vocк vк alguns falando isso e vai copiar.
-- Legal seu trabalho, ![]() |
Legal, tambйm estava afim de criar um assim, apenas para uso prуprio mesmo, vou dar uma estudada no cуdigo.
|
Voce nгo pode dar rep, entгo nгo fale isso sу porque vocк vк alguns falando isso e vai copiar.
-- Legal seu trabalho, ![]() |
?? Mas sу tem um problema.. ninguйm pediu sua opiniгo. Nгo curtiu meu post ? denuncia entгo, vai fundo..
|
Bem para aprender e fazer algo bom tem de se comecar por algum lado ne verdade.
Como vc disse й apenas um codigo para estudos, mesmo assim bom trabalho. |