SA-MP Forums Archive
Why not working? - 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: Why not working? (/showthread.php?tid=244117)



Why not working? - ricardo178 - 26.03.2011

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


Re: Why not working? - Unknown1234 - 26.03.2011

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



Re: Why not working? - iJumbo - 26.03.2011

PlayerInfo[playerid][Bank] += depositmoney;

here you dont need =

You deposited %i money


try ...


Re: Why not working? - ricardo178 - 26.03.2011

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!


Re: Why not working? - iJumbo - 26.03.2011

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



Re: Why not working? - Unknown1234 - 26.03.2011

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


Re: Why not working? - ricardo178 - 26.03.2011

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


Re: Why not working? - antonio112 - 26.03.2011

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



Re: Why not working? - Calgon - 26.03.2011

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.


Re: Why not working? - antonio112 - 26.03.2011

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

Anyway, edited & thanks for pointing it out.