Bank system problem
#1

Hi,

I'm making a bank system and followed this tutorial http://forum.sa-mp.com/showthread.ph...highlight=Bank

The problem is: the server recognizes the commands, but they don't do what they're supposed to do. Could anyone explain me what's wrong with the code?
Here's the code:

pawn Код:
dcmd_deposit(playerid,params[])//now the deposit command.
{
    new string[256];//the variable which will store the information of a string that we will format after wards.
    new type;//this variable will store player's input.
        {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /deposit [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(GetPlayerMoney(playerid)< type)//this will check that if he is inserting a higher amount of money then he has in hand.
            {
                GivePlayerMoney(playerid,-type);//this minus his money from his hand.
                AccInfo[playerid][pBankAccount] += type;//this will store the minused money in player's file,and will add money to his account.
                format(string, sizeof(string), "INFO: You have successfully deposited $%d to your bank account.", type);//this is the format of the following message of how much money you deposited into your account.
                SendClientMessage(playerid, 0xFFFFFF, string);//this will send the message which we formated above,the information was stored in the variable string.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your hand");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in hand.
        }
        return 1;
}
dcmd_withdraw(playerid,params[])//now the withdraw command.
{
    new string[256];//this is the variable that will store the formated message,we will format it in the following codes.
    new type;////this variable will store player's input.
        {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /withdraw [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(AccInfo[playerid][pBankAccount] >= type)//this will check that if the inputed amount is higher then the amount in the bank account.
            {
                AccInfo[playerid][pBankAccount] -= type;//this will minus the the amount or money he inserted, in the command.
                GivePlayerMoney(playerid, type);//this will give the player money he wanted to withdraw from the bank.
                format(string, sizeof(string), "INFO: You have successfully withdrawn $%d from your bank account.", type);//this is the formated message.This will store the formatted message in the variable we defined as string.
                SendClientMessage(playerid, 0xFFFFFF, string);//will send the formated message we formatted above.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your account");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in bank account.
        }
        return 1;
}
dcmd_balance(playerid,text[]) //balance command
{
    #pragma unused text
    new string[256];//the variable which will store the formatted message we will format in the next line.
    format(string, sizeof(string), "You currently have $%d in your bank account.", AccInfo[playerid][pBankAccount]);//this is the formated message which will tell the player that how much money he deposited in the bank account.
    SendClientMessage(playerid,-1,string);//this will send the formatted above,and which was stored in the variable above.
}
Reply
#2

Quote:
Originally Posted by DaRoderick
Посмотреть сообщение
Hi,

I'm making a bank system and followed this tutorial http://forum.sa-mp.com/showthread.ph...highlight=Bank

The problem is: the server recognizes the commands, but they don't do what they're supposed to do. Could anyone explain me what's wrong with the code?
Here's the code:

pawn Код:
dcmd_deposit(playerid,params[])//now the deposit command.
{
    new string[256];//the variable which will store the information of a string that we will format after wards.
    new type;//this variable will store player's input.
        {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /deposit [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(GetPlayerMoney(playerid)< type)//this will check that if he is inserting a higher amount of money then he has in hand.
            {
                GivePlayerMoney(playerid,-type);//this minus his money from his hand.
                AccInfo[playerid][pBankAccount] += type;//this will store the minused money in player's file,and will add money to his account.
                format(string, sizeof(string), "INFO: You have successfully deposited $%d to your bank account.", type);//this is the format of the following message of how much money you deposited into your account.
                SendClientMessage(playerid, 0xFFFFFF, string);//this will send the message which we formated above,the information was stored in the variable string.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your hand");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in hand.
        }
        return 1;
}
dcmd_withdraw(playerid,params[])//now the withdraw command.
{
    new string[256];//this is the variable that will store the formated message,we will format it in the following codes.
    new type;////this variable will store player's input.
        {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /withdraw [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(AccInfo[playerid][pBankAccount] >= type)//this will check that if the inputed amount is higher then the amount in the bank account.
            {
                AccInfo[playerid][pBankAccount] -= type;//this will minus the the amount or money he inserted, in the command.
                GivePlayerMoney(playerid, type);//this will give the player money he wanted to withdraw from the bank.
                format(string, sizeof(string), "INFO: You have successfully withdrawn $%d from your bank account.", type);//this is the formated message.This will store the formatted message in the variable we defined as string.
                SendClientMessage(playerid, 0xFFFFFF, string);//will send the formated message we formatted above.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your account");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in bank account.
        }
        return 1;
}
dcmd_balance(playerid,text[]) //balance command
{
    #pragma unused text
    new string[256];//the variable which will store the formatted message we will format in the next line.
    format(string, sizeof(string), "You currently have $%d in your bank account.", AccInfo[playerid][pBankAccount]);//this is the formated message which will tell the player that how much money he deposited in the bank account.
    SendClientMessage(playerid,-1,string);//this will send the formatted above,and which was stored in the variable above.
}
by what does it not do?

pawn Код:
dcmd_deposit(playerid,params[])//now the deposit command.
{
    new string[256];//the variable which will store the information of a string that we will format after wards.
    new type;//this variable will store player's input.
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /deposit [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(GetPlayerMoney(playerid)< type)//this will check that if he is inserting a higher amount of money then he has in hand.
            {
                GivePlayerMoney(playerid,-type);//this minus his money from his hand.
                AccInfo[playerid][pBankAccount] += type;//this will store the minused money in player's file,and will add money to his account.
                format(string, sizeof(string), "INFO: You have successfully deposited $%d to your bank account.", type);//this is the format of the following message of how much money you deposited into your account.
                SendClientMessage(playerid, 0xFFFFFF, string);//this will send the message which we formated above,the information was stored in the variable string.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your hand");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in hand.
        }
        return 1;
}
dcmd_withdraw(playerid,params[])//now the withdraw command.
{
    new string[256];//this is the variable that will store the formated message,we will format it in the following codes.
    new type;////this variable will store player's input.
    if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /withdraw [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
    if(type == 0)//this will check that if the type = 0.
    if(AccInfo[playerid][pBankAccount] >= type)//this will check that if the inputed amount is higher then the amount in the bank account.
    {
            AccInfo[playerid][pBankAccount] -= type;//this will minus the the amount or money he inserted, in the command.
           GivePlayerMoney(playerid, type);//this will give the player money he wanted to withdraw from the bank.
                format(string, sizeof(string), "INFO: You have successfully withdrawn $%d from your bank account.", type);//this is the formated message.This will store the formatted message in the variable we defined as string.
                SendClientMessage(playerid, 0xFFFFFF, string);//will send the formated message we formatted above.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your account");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in bank account.
        }
        return 1;
}
dcmd_balance(playerid,text[]) //balance command
{
    #pragma unused text
    new string[256];//the variable which will store the formatted message we will format in the next line.
    format(string, sizeof(string), "You currently have $%d in your bank account.", AccInfo[playerid][pBankAccount]);//this is the formated message which will tell the player that how much money he deposited in the bank account.
    SendClientMessage(playerid,-1,string);//this will send the formatted above,and which was stored in the variable above.
}
try that this might be your mistake below
pawn Код:
dcmd_deposit(playerid,params[])//now the deposit command.
{
    new string[256];//the variable which will store the information of a string that we will format after wards.
    new type;//this variable will store player's input.
        { //this here might make it so the command may not work, Has to be under the if statement.
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /deposit [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(GetPlayerMoney(playerid)< type)//this will check that if he is inserting a higher amount of money then he has in hand.
            {
                GivePlayerMoney(playerid,-type);//this minus his money from his hand.
                AccInfo[playerid][pBankAccount] += type;//this will store the minused money in player's file,and will add money to his account.
                format(string, sizeof(string), "INFO: You have successfully deposited $%d to your bank account.", type);//this is the format of the following message of how much money you deposited into your account.
                SendClientMessage(playerid, 0xFFFFFF, string);//this will send the message which we formated above,the information was stored in the variable string.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your hand");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in hand.
        }
        return 1;
}
Reply
#3

It does not actually deposit or withdraw the money
Reply
#4

Quote:
Originally Posted by DaRoderick
Посмотреть сообщение
It does not actually deposit or withdraw the money
changed, and heres my code for it on my server,

pawn Код:
COMMAND:withdraw(playerid, params[])
{
    new ammount;
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][AdminLevel] >= 0 && PlayerInfo[playerid][pInarea] == 1)
        {
            if(!sscanf(params, "i", ammount))
            {
                if(ammount <= PlayerInfo[playerid][pBank])
                {
                    if(ammount > -1)
                    {
                        new string[64];
                        new PName[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, PName, sizeof(PName));
                        PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+ammount;
                        PlayerInfo[playerid][pBank] = PlayerInfo[playerid][pBank]-ammount;
                        SendClientMessage(playerid, 0xD8D8D8FF, "----Bank Statement----");
                        format(string, sizeof(string), "New Balance %d", PlayerInfo[playerid][pBank]);
                        SendClientMessage(playerid, COLOR_GREEN, string);
                        SetPlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                        return 1;
                    }
                    else return SendClientMessage(playerid, 0xD8D8D8FF, "You Can't withdraw less than $0 nice try tho.");
                }
                else return SendClientMessage(playerid, 0xD8D8D8FF, "You don't have enough cash.");
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /withdraw [amount]");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not near a bank.");
    }
    else return SendClientMessage(playerid, 0xD8D8D8FF, "Player is not connected.");
}

COMMAND:deposit(playerid, params[])
{
    new ammount;
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][AdminLevel] >= 0 && PlayerInfo[playerid][pInarea] == 1)
        {
            if(!sscanf(params, "i", ammount))
            {
                if(ammount <= PlayerInfo[playerid][pCash])
                {
                    if(ammount > -1)
                    {
                        new string[64];
                        new PName[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, PName, sizeof(PName));
                        PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-ammount;
                        PlayerInfo[playerid][pBank] = PlayerInfo[playerid][pBank]+ammount;
                        SendClientMessage(playerid, 0xD8D8D8FF, "----Bank Statement----");
                        format(string, sizeof(string), "New Balance %d", PlayerInfo[playerid][pBank]);
                        SendClientMessage(playerid, COLOR_GREEN, string);
                        SetPlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                        return 1;
                    }
                    else return SendClientMessage(playerid, 0xD8D8D8FF, "You Can't deposit less than $0 nice try tho.");
                }
                else return SendClientMessage(playerid, 0xD8D8D8FF, "You don't have enough cash.");
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /deposit [amount]");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not near a bank.");
    }
    else return SendClientMessage(playerid, 0xD8D8D8FF, "Player is not connected.");
}
Reply
#5

I don't have a function to see the current player cash on hand like [pCash], nor do I require to except for this..
Could you perhaps tweak it a bit so I wouldn't need a [pCash]? Or just tell me what is wrong with my current command.
Reply
#6

Anyone..?
Reply
#7

Seriously nobody?
Reply
#8

Quote:
Originally Posted by DaRoderick
Посмотреть сообщение
Seriously nobody?
pawn Код:
dcmd_deposit(playerid,params[])//now the deposit command.
{
    new string[256];//the variable which will store the information of a string that we will format after wards.
    new type;//this variable will store player's input.
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /deposit [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(GetPlayerMoney(playerid)< type)//this will check that if he is inserting a higher amount of money then he has in hand.
            {
                GivePlayerMoney(playerid,-type);//this minus his money from his hand.
                AccInfo[playerid][pBankAccount] += type;//this will store the minused money in player's file,and will add money to his account.
                format(string, sizeof(string), "INFO: You have successfully deposited $%d to your bank account.", type);//this is the format of the following message of how much money you deposited into your account.
                SendClientMessage(playerid, 0xFFFFFF, string);//this will send the message which we formated above,the information was stored in the variable string.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your hand");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in hand.
        }
        return 1;
}
dcmd_withdraw(playerid,params[])//now the withdraw command.
{
    new string[256];//this is the variable that will store the formated message,we will format it in the following codes.
    new type;////this variable will store player's input.
    if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /withdraw [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
    if(type == 0)//this will check that if the type = 0.
    if(AccInfo[playerid][pBankAccount] >= type)//this will check that if the inputed amount is higher then the amount in the bank account.
    {
            AccInfo[playerid][pBankAccount] -= type;//this will minus the the amount or money he inserted, in the command.
           GivePlayerMoney(playerid, type);//this will give the player money he wanted to withdraw from the bank.
                format(string, sizeof(string), "INFO: You have successfully withdrawn $%d from your bank account.", type);//this is the formated message.This will store the formatted message in the variable we defined as string.
                SendClientMessage(playerid, 0xFFFFFF, string);//will send the formated message we formatted above.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your account");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in bank account.
        }
        return 1;
}
try that.
Reply
#9

Код:
warning 209: function "dcmd_deposit" should return a value
error 010: invalid function or declaration
warning 209: function "dcmd_withdraw" should return a value
error 010: invalid function or declaration
While compiling the code on your last post.
Reply
#10

Quote:
Originally Posted by DaRoderick
Посмотреть сообщение
Hi,

I'm making a bank system and followed this tutorial http://forum.sa-mp.com/showthread.ph...highlight=Bank

The problem is: the server recognizes the commands, but they don't do what they're supposed to do. Could anyone explain me what's wrong with the code?
Here's the code:

pawn Код:
dcmd_deposit(playerid,params[])//now the deposit command.
{
    new string[256];//the variable which will store the information of a string that we will format after wards.
    new type;//this variable will store player's input.
        {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /deposit [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(GetPlayerMoney(playerid)< type)//this will check that if he is inserting a higher amount of money then he has in hand.
            {
                GivePlayerMoney(playerid,-type);//this minus his money from his hand.
                AccInfo[playerid][pBankAccount] += type;//this will store the minused money in player's file,and will add money to his account.
                format(string, sizeof(string), "INFO: You have successfully deposited $%d to your bank account.", type);//this is the format of the following message of how much money you deposited into your account.
                SendClientMessage(playerid, 0xFFFFFF, string);//this will send the message which we formated above,the information was stored in the variable string.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your hand");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in hand.
        }
        return 1;
}
dcmd_withdraw(playerid,params[])//now the withdraw command.
{
    new string[256];//this is the variable that will store the formated message,we will format it in the following codes.
    new type;////this variable will store player's input.
        {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, -1, "[USAGE]: /withdraw [amount]");//this will check that if he inserted the write format or not,if it is and incorrect format,it will break the codes there and end the process with an error message.
            if(type == 0)//this will check that if the type = 0.
            if(AccInfo[playerid][pBankAccount] >= type)//this will check that if the inputed amount is higher then the amount in the bank account.
            {
                AccInfo[playerid][pBankAccount] -= type;//this will minus the the amount or money he inserted, in the command.
                GivePlayerMoney(playerid, type);//this will give the player money he wanted to withdraw from the bank.
                format(string, sizeof(string), "INFO: You have successfully withdrawn $%d from your bank account.", type);//this is the formated message.This will store the formatted message in the variable we defined as string.
                SendClientMessage(playerid, 0xFFFFFF, string);//will send the formated message we formatted above.
            }
            else SendClientMessage(playerid, 0xFFFFFF, "SERVER: You do not have that much amount in your account");//this will send an error message that if a player enter's an invalid amount.Or in simple words that if he enter's a higher amount then he has in bank account.
        }
        return 1;
}
dcmd_balance(playerid,text[]) //balance command
{
    #pragma unused text
    new string[256];//the variable which will store the formatted message we will format in the next line.
    format(string, sizeof(string), "You currently have $%d in your bank account.", AccInfo[playerid][pBankAccount]);//this is the formated message which will tell the player that how much money he deposited in the bank account.
    SendClientMessage(playerid,-1,string);//this will send the formatted above,and which was stored in the variable above.
}
Make sure you check all the code before posting on here but other than that it looks good i cant see any problems that should cause errors
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)