Erro FS Bank
#8

Consertei o FS para vocк :


pawn Код:
/* |=| |=|=====|=|  //=======
              |=| |=|     |=| ||
              |=| |=|=====|=| \\=======||
              |=| |=|                  ||
              |=| |=|          =======// */



//[IpS] Bank System v1.0 made by Chuck Cornfild or Chuck (Igor)
//             Powered by IpS Websites®
//     Copyright ©2010, IpS WebSites & Design.
//             All Rights Reserved.


#include <a_samp>
#include <dini>


#define UserPath "IpSBS/Users/" //Diretorio dos players.
#define BankPath "IpSBS/Banks/" //Diretorio onde se encontram os dados dos bancos.


#define MaxPlayers 100 //Nъmero mбximo de player no server.
#define MaxBanks 10 //Nъmero mбximo de bancos no mapa e no server.
#define BankName "Banco IpS" //Nome do Banco.


#define Gray 0x999999FF
#define Green 0x00FF00FF
#define Yellow 0xFFFF00FF


#define StartingMoney 500 //Dinheiro com que o player vai comeзar ($500).


enum info_p
{
    Name[40],Money,Balance,Credit,BankID,Ip[20]
};


new PlayerInfo[MaxPlayers][info_p];


enum info_b
{
    BankID,Float:PosX,Float:PosY,Float:PosZ,VirtualWorld,Pickup
};

new BankInfo[MaxBanks][info_b];


forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z); // PlayerToPoint
//Save Account System
forward SavePlayerConfig(playerid); //Save Player System.
forward LoadPlayerConfig(playerid); //Save Player System.


new FilePath[128];
new pname[MAX_PLAYER_NAME];


public SavePlayerConfig(playerid)
{
    GetPlayerName(playerid, pname, sizeof(pname));
    format(FilePath, sizeof(FilePath), "%s%s.ini",UserPath,pname);
    if(dini_Exists(FilePath))
    {
        dini_Set(FilePath,"Name", PlayerInfo[playerid][Name]);
        dini_IntSet(FilePath,"Money", PlayerInfo[playerid][Money]);
        dini_IntSet(FilePath,"Balance", PlayerInfo[playerid][Balance]);
        dini_IntSet(FilePath,"Credit", PlayerInfo[playerid][Credit]);
        dini_IntSet(FilePath,"BankID", PlayerInfo[playerid][BankID]);
        dini_Set(FilePath,"Ip", PlayerInfo[playerid][Ip]);
    }
    return 1;
}

public LoadPlayerConfig(playerid)
{
    GetPlayerName(playerid, pname, sizeof(pname));
    format(FilePath, sizeof(FilePath), "%s%s.ini",UserPath,pname);
    if(!dini_Exists(FilePath))
    {
        dini_Create(FilePath);
        dini_Set(FilePath,"Name", PlayerInfo[playerid][Name]);
        dini_IntSet(FilePath,"Money",StartingMoney);
        dini_IntSet(FilePath,"Balance",0);
        dini_IntSet(FilePath,"BankID",0);
        dini_Set(FilePath,"Ip",PlayerInfo[playerid][Ip]);
    }
    else
    {
        PlayerInfo[playerid][Money] = dini_Int(FilePath, "Money");
        PlayerInfo[playerid][Balance] = dini_Int(FilePath, "Balance");
        PlayerInfo[playerid][Credit] = dini_Int(FilePath, "Credit");
        PlayerInfo[playerid][BankID] = dini_Int(FilePath, "BankID");
        GivePlayerMoney(playerid,PlayerInfo[playerid][Money]);
    }
    return 1;
}


public OnFilterScriptInit()
{
    print("  ");
    print("===============================================================");
    print("|[IpS] Bank System v1.0 made by Chuck Cornfild or Chuck (Igor)|");
    print("|             Powered by IpS Websites®                        |");
    print("|     Copyright ©2010, IpS WebSites & Design.                 |");
    print("|             All Rights Reserved.                            |");
    print("===============================================================");
    print("  ");
    //LOAD BANK's
    new countbank = 0;
    for(new b = 0; b < MaxBanks; b++)
    {
        new bankfile[128];
        format(bankfile,sizeof(bankfile),"%sBank%d.ini",BankPath,b);//Cria caminho para os arquivos que armazenam dados do banco
        if(dini_Exists(bankfile))//Verifica se o banco existe.
        {
            BankInfo[b][BankID] = b; //Atribui "b" como id do banco atual.
            BankInfo[b][PosX] = dini_Float(bankfile,"PosX");//X do banco
            BankInfo[b][PosY] = dini_Float(bankfile,"PosY");//Y do banco
            BankInfo[b][PosZ] = dini_Float(bankfile,"PosZ");//Z do banco
            BankInfo[b][VirtualWorld] = dini_Int(bankfile,"VirtualWorld");//VirtualWorld do banco.
            BankInfo[b][Pickup] = CreatePickup(1274,23,BankInfo[b][PosX],BankInfo[b][PosY],BankInfo[b][PosZ],BankInfo[b][VirtualWorld]);
            countbank++;
            //A linha acima, cria o pickup do banco.
        }//Fim do banco "b", inicia o processo novamente verificando se existe outro banco.
    }
    new string[126];
    format(string,sizeof(string),"Total: %d bank(s).",countbank);
    print(string);
    return 1;
}


public OnFilterScriptExit()
{
    for(new i = 0; i < MaxPlayers; i++)
    {
        SavePlayerConfig(i);
    }
    return 1;
}


public OnPlayerConnect(playerid)
{
    new nick[MAX_PLAYER_NAME];
    new ipofp[20];
    GetPlayerName(playerid,nick,sizeof(nick));
    strmid(PlayerInfo[playerid][Name], nick, 0, strlen(nick), 40);
    PlayerInfo[playerid][Money] = 500;
    PlayerInfo[playerid][Balance] = 0;
    PlayerInfo[playerid][Credit] = 0;                             //Reseta todas variaveis do playerid.
    PlayerInfo[playerid][BankID] = 0;
    GetPlayerIp(playerid,ipofp,20);
    strmid(PlayerInfo[playerid][Ip], ipofp, 0, strlen(ipofp), 20);
    LoadPlayerConfig(playerid); //Carrega as configuraзхes do player.
    for(new b = 0; b < MaxBanks; b++)
    {
        SetPlayerMapIcon(playerid,b,BankInfo[b][PosX],BankInfo[b][PosY],BankInfo[b][PosZ],52,0);
    }
    return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
    SavePlayerConfig(playerid); //Save info of player/Salva as informaзхes do player.
    return 1;
}


public OnPlayerSpawn(playerid)
{
    return 1;
}


public OnPlayerText(playerid, text[])
{
    return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128];
    new idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp("/criarbanco", cmdtext, true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Yellow,"-Comando restrito a administradores RCON.");
        new countfile = 0;
        for(new b = 0; b < MaxBanks; b++)
        {
            new BankFile[128];
            format(BankFile,sizeof(BankFile),"%sBank%d.ini",BankPath,b);
            if(dini_Exists(BankFile)) countfile ++;
        }
        if(countfile < MaxBanks)
        {
            for(new b = 0; b < MaxBanks; b++)
            {
                new BankFile[128];
                format(BankFile,sizeof(BankFile),"%sBank%d.ini",BankPath,b);
                if(!dini_Exists(BankFile))
                {
                    new Float:x,Float:y,Float:z,VirtualWorldB;
                    GetPlayerPos(playerid,x,y,z);
                    VirtualWorldB = GetPlayerVirtualWorld(playerid);
                    dini_Create(BankFile);
                    dini_IntSet(BankFile,"BankID",b);
                    dini_FloatSet(BankFile,"PosX",x);
                    dini_FloatSet(BankFile,"PosY",y);
                    dini_FloatSet(BankFile,"PosZ",z);
                    dini_IntSet(BankFile,"VirtualWorld",VirtualWorldB);
                    new string[128];
                    format(string,sizeof(string),"-Vocк criou um novo banco (BankID: %d), apуs o gmx ele aparecerб.",b);
                    SendClientMessage(playerid,Yellow,string);
                    break;
                }
            }
        }
        else
        {
            SendClientMessage(playerid,Yellow,"-O nъmero mбximo de bancos foi atingido.");
        }
        return 1;
    }
    if (strcmp("/destruirbanco", cmdtext, true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Yellow,"-Comando restrito a administradores RCON.");
        new Float:x,Float:y,Float:z,VirtualWorldB;
        GetPlayerPos(playerid,x,y,z);
        VirtualWorldB = GetPlayerVirtualWorld(playerid);
        for(new b = 0; b < MaxBanks; b++)
        {
            if(PlayerToPoint(2,playerid,BankInfo[b][PosX],BankInfo[b][PosY],BankInfo[b][PosZ]) && VirtualWorldB == BankInfo[b][VirtualWorld])
            {
                new BankFile[128];
                format(BankFile,sizeof(BankFile),"%sBank%d.ini",BankPath,b);
                dini_Remove(BankFile);
                DestroyPickup(BankInfo[b][Pickup]);
                SendClientMessage(playerid,Yellow,"-O banco foi removido com sucesso.");
            }
        }
        return 1;
    }
    if(strcmp(cmd,"/sacar",true)==0)
    {
        new tmp[128];
        tmp = strtok(cmdtext,idx);
        new quantia = strval(tmp);
        if(!IsPlayerInBank(playerid)) SendClientMessage(playerid,Gray,"- Vocк precisa estar em um banco.");
        else if(!strlen(tmp))   SendClientMessage(playerid,Gray,"- /Sacar [quantia].");
        else if(quantia > PlayerInfo[playerid][Balance] || quantia <= 0)    SendClientMessage(playerid,Gray,"- Vocк nгo possui tudo isso de dinheiro ou valor invбlido.");
        else
        {
            new string[128];
            GameTextForPlayer(playerid,"~g~]$$Dinheiro Sacado$$]",5000,4);
            format(string,sizeof(string),"- Seu saldo era de $%d.",PlayerInfo[playerid][Balance]);
            SendClientMessage(playerid,Yellow,string);
            PlayerInfo[playerid][Balance] = PlayerInfo[playerid][Balance]-quantia;
            format(string,sizeof(string),"- Retirado $%d. Seu novo saldo й de $%d.",quantia,PlayerInfo[playerid][Balance]);
            SendClientMessage(playerid,Yellow,string);
            GivePlayerMoney(playerid,quantia);
        }
        return 1;
    }
    if(strcmp(cmd,"/depositar",true)==0)
    {
        new tmp[128];
        tmp = strtok(cmdtext,idx);
        new quantia = strval(tmp);
        if(!IsPlayerInBank(playerid)) SendClientMessage(playerid,Gray,"- Vocк precisa estar em um banco.");
        else if(!strlen(tmp))   SendClientMessage(playerid,Gray,"- /depositar [quantia].");
        else if(quantia > GetPlayerMoney(playerid) || quantia <= 0) SendClientMessage(playerid,Gray,"- Vocк nгo possui tudo isso de dinheiro ou valor invбlido.");
        else
        {
            new string[128];
            GameTextForPlayer(playerid,"~g~]$$Dinheiro Depositado$$]",5000,4);
            format(string,sizeof(string),"- Seu saldo era de $%d.",PlayerInfo[playerid][Balance]);
            SendClientMessage(playerid,Yellow,string);
            PlayerInfo[playerid][Balance] = PlayerInfo[playerid][Balance]+quantia;
            format(string,sizeof(string),"- Depositado $%d. Seu novo saldo й de $%d.",quantia,PlayerInfo[playerid][Balance]);
            SendClientMessage(playerid,Yellow,string);
            GivePlayerMoney(playerid,-quantia);
        }
        return 1;
    }
    if(strcmp(cmd,"/saldo",true)==0)
    {
        if(!IsPlayerInBank(playerid)) SendClientMessage(playerid,Gray,"- Vocк precisa estar em um banco.");
        else
        {
            new string[128];
            GameTextForPlayer(playerid,"~g~]$$Extrato Bancario$$]",5000,4);
            format(string,sizeof(string),"- Seu saldo й de $%d.",PlayerInfo[playerid][Balance]);
            SendClientMessage(playerid,Yellow,string);
        }
        return 1;
    }
    if(!strcmp(cmdtext, "/lol", true))
    {
        SetPlayerPos(playerid, -2691.5767,234.4634,4.3359);
        return 1;
    }
    return 0;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
    new string[128];
    for(new b = 0; b < MaxBanks; b++)
    {
        if(pickupid == BankInfo[b][Pickup])
        {
            format(string,sizeof(string),"~w~Bem vindo ao ~y~%s.",BankName);
            GameTextForPlayer(playerid,string,3000,4);
        }
    }
    return 1;
}



forward IsPlayerInBank(playerid);
public IsPlayerInBank(playerid)
{
    for(new b = 0; b < MaxBanks; b++)
    {
        if(PlayerToPoint(3, playerid, BankInfo[b][PosX], BankInfo[b][PosY], BankInfo[b][PosZ])) return 1;
    }
    return 0;
}


public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}


strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

Nгo esqueзa de criar, no diretуrio scriptfiles, a pasta IpSBS e dentro dela as subpastas Users e Banks .



Para que um banco apareзa apуs ser feito, feche e abra o arquivo samp-server em vez de dar GMX.



Espero ter ajudado .
Reply


Messages In This Thread
Erro FS Bank - by Waldrey - 01.06.2012, 11:00
Re: Erro FS Bank - by Don_Speed - 01.06.2012, 11:04
Re: Erro FS Bank - by Waldrey - 01.06.2012, 11:07
Re: Erro FS Bank - by Edu33 - 01.06.2012, 11:08
Re: Erro FS Bank - by Waldrey - 01.06.2012, 11:10
Re: Erro FS Bank - by Waldrey - 01.06.2012, 11:16
Re: Erro FS Bank - by Edu33 - 01.06.2012, 11:19
Re: Erro FS Bank - by rjjj - 01.06.2012, 13:53

Forum Jump:


Users browsing this thread: 1 Guest(s)