Bombs problem
#1

I've this code to buy bombs:

pawn Код:
format(message, sizeof(message), "You bought %d bombs for %d CSCash each - Total Spent: %d CSCash", bombs,BOMBPRICE,BOMBPRICE * bombs);
                SCM(playerid, 0x33CCFFAA, message);
                pInfo[playerid][Bombs] += bombs;
                GiveCash(playerid, -BOMBPRICE * bombs);
                new Year, Month, Day, Hour, Minute, Second;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                new pname[MAX_PLAYER_NAME];
                new msg[400];
                new ok[400];
                GetPlayerName(playerid, pname, 24);
                format(msg, sizeof(msg), "%s (%d) bought %d bombs for %d CSCash each - Total Spent: %d CSCash - CSCash Left: %i - %02d/%02d/%02d - %02d:%02d:%02d", pname,playerid,bombs,BOMBPRICE * bombs,GetCash(playerid),Day,Month,Year,Hour,Minute,Second);
                format(ok, sizeof(ok), "1,7%s (%d) bought %d bombs for %d CSCash each - Total Spent: %d CSCash - CSCash Left: %i - %02d/%02d/%02d - %02d:%02d:%02d", pname,playerid,bombs,BOMBPRICE * bombs,GetCash(playerid),Day,Month,Year,Hour,Minute,Second);
                SendMessageToAdmins(0xA86EFC77, msg);
                IRC_Say(gGroupID, IRC_ACHANNEL, ok);
                ShopLog(msg);
The problem is in the message:

pawn Код:
%s (%d) bought %d bombs for %d CSCash each - Total Spent: %d CSCash - CSCash Left: %i
It should be:

Playername (id) bought 5 bombs (example) for 15000 CSCash each (already defined BOMBPRICE). Total Spent: It should do 15000 x 5 bombs = 75000

But it shows the "Total Spent" and "For %d CSCash each" with wrong values.

Whats wrong?
Reply
#2

Try this:
pawn Код:
format(message, sizeof(message), "You bought %d bombs for %d CSCash each - Total Spent: %d CSCash", bombs,BOMBPRICE,BOMBPRICE * bombs);
                SCM(playerid, 0x33CCFFAA, message);
                pInfo[playerid][Bombs] += bombs;
                new OldCash=GetCash(playerid); //I added this
                GiveCash(playerid, -BOMBPRICE * bombs);
                new Year, Month, Day, Hour, Minute, Second;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                new pname[MAX_PLAYER_NAME];
                new msg[400];
                new ok[400];
                GetPlayerName(playerid, pname, 24);
                format(msg, sizeof(msg), "%s (%d) bought %d bombs for 15.000$ CSCash each - Total Spent: %d CSCash - CSCash Left: %i - %02d/%02d/%02d - %02d:%02d:%02d", pname,playerid,bombs,BOMBPRICE * bombs,OldCash-(BOMBPRICE * bombs),Day,Month,Year,Hour,Minute,Second);
                format(ok, sizeof(ok), "1,7%s (%d) bought %d bombs for 15.000$ CSCash each - Total Spent: %d CSCash - CSCash Left: %i - %02d/%02d/%02d - %02d:%02d:%02d", pname,playerid,bombs,BOMBPRICE * bombs,OldCash-(BOMBPRICE * bombs),Day,Month,Year,Hour,Minute,Second);
                SendMessageToAdmins(0xA86EFC77, msg);
                IRC_Say(gGroupID, IRC_ACHANNEL, ok);
                ShopLog(msg);
Question: Why you enter %d for each bomb's price? A single bomb costs a specific value doesn't it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)