SA-MP Forums Archive
[Help] My own money - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] My own money (/showthread.php?tid=115832)



[Help] My own money - Oxside - 26.12.2009

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


Re: [Help] My own money - Grim_ - 26.12.2009

Are you correctly setting the values to those variables?


Re: [Help] My own money - Oxside - 26.12.2009

How do you mean?


Re: [Help] My own money - Grim_ - 26.12.2009

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



Re: [Help] My own money - Oxside - 26.12.2009

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


Re: [Help] My own money - Grim_ - 26.12.2009

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


Re: [Help] My own money - Oxside - 26.12.2009

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;
}



Re: [Help] My own money - Grim_ - 26.12.2009

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


Re: [Help] My own money - Oxside - 26.12.2009

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;
}



Re: [Help] My own money - Grim_ - 26.12.2009

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