[FilterScript] Simples Sistema de Salvar Placas - fPlacas
#1

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
Код:
SaveVehicleNumberPlateEx - Salvar Placa
LoadVehicleNumberPlateEx - Carregar Placa
RemoveVehicleNumberPlate - Remover Placa
SetVehicleNumberPlateEx    - Colocar Placa
GetVehicleNumberPlateEx   - Ler a Placa
Cуdigo
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;
}
Espero que seja ъtil
Reply
#2

Legal Amiguinho !
Reply
#3

Drakon como sempre fazendo уtimo trabalho ._.

@ Drakon, me add no msn gilhrp@hotmail.com, acho que achei um bug no Fcommand [/ACHO
Reply
#4

Boa [FeK] Drakins
Reply
#5

quando eu uso meu serve fecha
Reply
#6

Good ....I Liked -_-
Reply
#7

Legal
..........

maquerx
Poste seu server_log
Reply
#8

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3c, ©2005-2010 SA-MP Team

[22:55:11] password = "" (string)
[22:55:11]
[22:55:11] Server Plugins
[22:55:11] --------------
[22:55:11] Loading plugin: streamer
[22:55:11]

*** Streamer Plugin v2.3.8 by Incognito loaded ***

[22:55:11] Loaded.
[22:55:11] Loaded 1 plugins.

[22:55:11]
[22:55:11] Filter Scripts
[22:55:11] ---------------
[22:55:11] Loading filter script 'splaca.amx'...
tenso
Reply
#9

Cria o arquivo PlacasVeiculos.fek
Reply
#10

[FeK]DraKiNs

Cara esse tudo йra o q eu estava esperando.
Mas assim eu queria fazer com que o player.
pudesse usar esses comandos. e poder criar uma placa randomica.
em um determinado lugar.
й possivel fazer isso ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)