[Help] My own money
#1

Heey guys

Im using my own money on my server. but i want to make a /checkcash command so the player can see how much cash he has.
On the top i have:

pawn Код:
new Cash[MAX_PLAYERS];<< The variable where the cash is stored in..
new CashOnBank[MAX_PLAYERS]; << The variable where the cash on the bank is stored in.
got the following command to show cash in the bank and in pocket

pawn Код:
dcmd_checkcash(playerid, params[])
{
    #pragma unused params
    new cashstring[48];
    new bankstring[48];
    format(cashstring, sizeof(cashstring), "[!] You now have %i cash in your pocket", Cash[playerid]);
    format(bankstring, sizeof(bankstring), "[!] You now have %i cash in you bank", CashOnBank[playerid]);
    SendClientMessage(playerid, COLOR_BLUE, cashstring);
    SendClientMessage(playerid, COLOR_BLUE, bankstring);
    return 1;
}
pawn Код:
stock SetPlayerCash(playerid, value)
{
   Cash[playerid] = 0;
   Cash[playerid] = Cash[playerid] + value;
   return Cash[playerid];
}

stock GivePlayerCash(playerid, value)
{
   Cash[playerid] = Cash[playerid] + value;
   return Cash[playerid];
}

stock GetPlayerCash(playerid)
{
    return Cash[playerid];
}
But when i try to show the player his ammount ofmoney in pocket and bank it shows at the place where the money must be a @ or wird numberor % or a ^.

Im I tryed a lot
Reply
#2

Are you correctly setting the values to those variables?
Reply
#3

How do you mean?
Reply
#4

For example
pawn Код:
Cash[playerid] = GetPlayerMoney(playerid);
Reply
#5

no no, my money system is more like: Pcash (Search on the forum)
But should it work if i add that,?
Reply
#6

What exactly are you trying to do?
What exactly is the problem with you trying to do that?
Reply
#7

Everything works fine, but when is use /checkcash (Posted the command in the topic)
It should print my current Money (Cash) on the screen?
But when i use it it prints somehting like this in the SA-MP chat:
[!] You now have @ cash in your pocket
[!] You now have ^in your bank

It should show the content of Cash[MAX_PLAYERS] but i doesn't

Код:
dcmd_checkcash(playerid, params[])
{
#pragma unused params
new cashstring[48];
new bankstring[48];
format(cashstring, sizeof(cashstring), "[!] You now have %i cash in your pocket", Cash[playerid]);
format(bankstring, sizeof(bankstring), "[!] You now have %i cash in you bank", CashOnBank[playerid]);
SendClientMessage(playerid, COLOR_BLUE, cashstring);
SendClientMessage(playerid, COLOR_BLUE, bankstring);
return 1;
}
Reply
#8

Try changing "%i" to "%d". Even though I thought they did the same thing...
Reply
#9

It works for the /checkcash but when i use my command /deposit and /withdraw and then deposit 500 into bank and then use /checkcash
it shows wierd numbers

My withdraw and deposit command

pawn Код:
dcmd_withdraw(playerid, params[])
{
    new ammount;
    new string[48];
    if (sscanf(params, "u", ammount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/withdraw <ammount>\"");
    if(LoggedBank[playerid] == 1)
    {
      CashOnBank[playerid] = CashOnBank[playerid] - ammount;
    Cash[playerid] = Cash[playerid] + ammount;
        format(string, sizeof(string), "You now have %d cash in your pocket and %d on the bank", Cash[playerid], CashOnBank[playerid]);
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_YELLOW, "|__________________________________ Las Vegas Bank Website _____________________________________|");
        SendClientMessage(playerid, COLOR_WHITE , "You withdrawed money from your bank account:");
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 1;
}

dcmd_deposit(playerid, params[])
{
    new ammount;
    if (sscanf(params, "u", ammount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/deposit <ammount>\"");
    if(LoggedBank[playerid] == 1)
    {
 Cash[playerid] = Cash[playerid] - ammount;
        CashOnBank[playerid] = CashOnBank[playerid] + ammount;
        new string[48];
        format(string, sizeof(string), "[!] You now have %d cash in your pocket and %d on the bank", Cash[playerid], CashOnBank[playerid]);
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_BLUE, "");
        SendClientMessage(playerid, COLOR_YELLOW, "|__________________________________ Las Vegas Bank Website _____________________________________|");
        SendClientMessage(playerid, COLOR_WHITE , "You deposited money to your bank account:");
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 1;
}
Reply
#10

O.o
Are you sure the variables are holding a value and not a string/float?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)