21.01.2011, 15:45
Introduзгo
Ae galera,sem nada para fazer resolvi criar algo simples,usando Fini Fast Reader And Writer fiz de tal forma rбpida e acessнvel,na qual os salvamentos sгo executados em menos de um segundo,assim sem lag ou algo do Tipo.
Tambйm criei Funзхes para vocкs usarem:
Funзхes
Cуdigo
O cуdigo do Fini esta no Arquivo,sem precisar de novas Includes:
Espero que seja ъtil
Ae galera,sem nada para fazer resolvi criar algo simples,usando Fini Fast Reader And Writer fiz de tal forma rбpida e acessнvel,na qual os salvamentos sгo executados em menos de um segundo,assim sem lag ou algo do Tipo.
Tambйm criei Funзхes para vocкs usarem:
Funзхes
Код:
SaveVehicleNumberPlateEx - Salvar Placa LoadVehicleNumberPlateEx - Carregar Placa RemoveVehicleNumberPlate - Remover Placa SetVehicleNumberPlateEx - Colocar Placa GetVehicleNumberPlateEx - Ler a Placa
O cуdigo do Fini esta no Arquivo,sem precisar de novas Includes:
pawn Код:
//==============================================================================
//Includes
#include a_samp
//==============================================================================
//Configs
#define MAX_PLATES (999)
#define PLACA_FILE "PlacasVeiculos.fek"
#define maxtag (00244)
#define maxfile (99999)
#define maxname (00064)
//==============================================================================
//Files
public OnFilterScriptInit()
{
Fini_OpenFile(PLACA_FILE);
for(new i; i < MAX_PLATES; ++i)
LoadVehicleNumberPlateEx(i);
Fini_SaveFile();
Fini_CloseFile();
}
public OnFilterScriptExit()
{
Fini_OpenFile(PLACA_FILE);
for(new i; i < MAX_PLATES; ++i)
SaveVehicleNumberPlateEx(i);
Fini_SaveFile();
Fini_CloseFile();
}
//==============================================================================
//Functions Plates
new Plaquinhas[MAX_PLATES][64];
stock
SetVehicleNumberPlateEx(vehid,plate[])
{
format(Plaquinhas[vehid],64,"%s",plate);
SetVehicleNumberPlate(vehid,plate);
return SetVehicleToRespawn(vehid);
}
stock
RemoveVehicleNumberPlate(vehid)
{
Plaquinhas[vehid][0] = '\0';
SetVehicleNumberPlate(vehid," ");
return SetVehicleToRespawn(vehid);
}
#define GetVehicleNumberPlateEx(%0) Plaquinhas[%0]
//==============================================================================
//File Functions Plates
stock
SaveVehicleNumberPlateEx(vehid)
{
new aString[8],iString[64];
format(aString,8,"%d",vehid),format(iString,64,"%s",GetVehicleNumberPlateEx(vehid));
return Fini_SetStr(aString,iString);
}
stock
LoadVehicleNumberPlateEx(vehid)
{
new aString[64];
format(aString,64,"%d",vehid);
return SetVehicleNumberPlateEx(vehid,Fini_GetStr(aString));
}
//==============================================================================
//Fini [2.0]
#define Fini_Exists fexist
#define Fini_GetFloat(%0) floatstr(Fini_GetStr(%0))
static
zNormal1,
zNormal2,
fStr[maxtag],
fTag[maxtag],
fFile[maxfile],
File:zFopenFile,
fName[maxname],
iSource
;
stock
Fini_OpenFile(fname[])
{
zFopenFile = fopen(fname,io_read);
while(fread(zFopenFile,fStr))
strins(fFile,fStr,strlen(fFile),maxfile);
fclose(zFopenFile);
format(fName,maxname,"%s",fname);
return true;
}
stock
Fini_SaveFile()
{
fremove(fName);
zFopenFile = fopen(fName,io_write);
fwrite(zFopenFile,fFile);
fclose(zFopenFile);
return true;
}
stock
Fini_CloseFile()
{
fFile[0] = '\0';
fName[0] = '\0';
return true;
}
stock
Fini_GetStr(ftag[])
{
zNormal1 = strfind(fFile,ftag,true);
zNormal2 = (zNormal1 + (strlen(ftag)));
strmid(fTag,fFile,zNormal2,(zNormal2 + maxtag),maxtag);
zNormal2 = strfind(fTag,"\n",true);
strmid(fStr,fTag,1,zNormal2 ,maxtag);
return fStr;
}
stock
Fini_SetStr(ftag[],fstr[])
{
format(fTag,maxtag,"%s=%s",ftag,Fini_GetStr(ftag));
zNormal1 = strfind(fFile,ftag,true);
if(zNormal1 != -1)
{
iSource = strlen( fTag ) ;
format(fStr,maxtag,"%s=%s",ftag,fstr);
strdel(fFile,zNormal1 ,(zNormal1 + iSource));
format(fStr,128,"%s",fStr);
strins(fFile,fStr,zNormal1 ,128);
}
else
{
format(fStr,maxtag,"%s=%s\r\n",ftag,fstr);
strins(fFile,fStr,strlen(fFile));
}
return true;
}
stock
Fini_Create(nFile[])
{
if (Fini_Exists(nFile)) return false;
new File:cFile = fopen(nFile,io_write);
return fclose(cFile);
}
stock
Fini_SetVal(ftag[],fval)
{
static Seting[24];
format(Seting,maxtag,"%d",fval);
Fini_SetStr(ftag,Seting);
return true;
}
stock
Fini_SetFloat(ftag[],Float:fval)
{
static Seting[24];
format(Seting,maxtag,"%f",fval);
Fini_SetStr(ftag,Seting);
return true;
}
stock
Fini_SetBool(ftag[],bool:fval)
{
static Seting[24];
format(Seting,maxtag,"%d",fval);
Fini_SetStr(ftag,Seting);
return true;
}
stock
Fini_IsSet(ftag[])
{
format(fTag,maxtag,"%s=%s",ftag,Fini_GetStr(ftag));
zNormal1 = strfind(fFile,ftag,true);
if(zNormal1 != -1)
return true;
return false;
}
stock Fini_GetBool(ftag[])
{
new Seting = strval(Fini_GetStr(ftag));
return Seting;
}
stock Fini_GetValue(ftag[])
{
new Seting = strval(Fini_GetStr(ftag));
return Seting;
}