Why not working?
#1

Hi guys, i have made this code... Deposit code....
But it don't work! just tell me i deposited 0 into my account, and really don't deposit nothing... It compile without any warmnings/errors..

Please help me

THANKS
pawn Код:
COMMAND:deposit(playerid, params[])
{
    new depositmoney;
    new string[64];
    if(!sscanf(params, "i", depositmoney))
    {
        if(depositmoney <= 10000000000)
        {
            format(string, sizeof(string), "You deposited %d money into your bank account!", depositmoney);
            SendClientMessage(playerid, 0xB4B5B7FF, string);
            PlayerInfo[playerid][Bank] += depositmoney;
            GivePlayerMoney(playerid, -depositmoney);
            return 1;
        }
        else return SendClientMessage(playerid, 0xB4B5B7FF, "You can't deposit so much!");
    }
    else return SendClientMessage(playerid, 0xB4B5B7FF, "USAGE: /deposit [MoneyAmmount]");
}
THANKS
Reply
#2

try
Код:
COMMAND:deposit(playerid, params[])
{
    new depositmoney;
    new string[64];
    if(sscanf(params, "i", depositmoney)) return SendClientMessage(playerid, 0xB4B5B7FF, "USAGE: /deposit [MoneyAmmount]");
    else if(depositmoney >= 10000000000) return SendClientMessage(playerid, 0xB4B5B7FF, "You can't deposit so much!");
	else
 	{
            format(string, sizeof(string), "You deposited %d money into your bank account!", depositmoney);
            SendClientMessage(playerid, 0xB4B5B7FF, string);
            PlayerInfo[playerid][Bank] += depositmoney;
            GivePlayerMoney(playerid, -depositmoney);
            return 1;
  	}
}
Reply
#3

PlayerInfo[playerid][Bank] += depositmoney;

here you dont need =

You deposited %i money


try ...
Reply
#4

Solved by myself just for changing params "i" to "d"
By the way i don't know how to block teh deposit when player have negative money!
Reply
#5

pawn Код:
if(GetPlayerMoney(playerid) < 0) return SendClientMessage(playerid, COLOR_YELLOW, "you cant deposit money");
Reply
#6

new cash;
GivePlayerMoney(playerid,cash);
if(cash<0) // return error
Reply
#7

Now it don't let me deposit if i have 0 or -something but if i have 5000 and deposit 10000 it let deposit....
Reply
#8

Use:
pawn Код:
if(depositmoney > GetPlayerMoney(playerid))
    return 1;
Reply
#9

Quote:
Originally Posted by antonio112
Посмотреть сообщение
Use:
pawn Код:
if(depositmoney > GetPlayerMoney(playerid)
    return 1;
You mean:

pawn Код:
if(depositmoney > GetPlayerMoney(playerid)) return 1;
You missed a bracket.
Reply
#10

Oh yea, you're right. Sorry for that, I`m a bit tired.

Anyway, edited & thanks for pointing it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)