Deposit Command
#1

Hey guys. This is my deposit command:
Код:
CMD:deposit(playerid, params[])
{
	new string[128], input;

	if(sscanf(params, "i", input)) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} /deposit [amount]");
	if(GetPlayerMoney(playerid) < input) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You don't have that much money!");

	if(IsPlayerInRangeOfPoint(playerid, 3.0, 290.2423, 1895.1035, 499.2859))
	{
		pOldBalance[playerid] = pInfo[playerid][BankMoney]; // save old var
		pInfo[playerid][BankMoney] += input, GivePlayerMoney(playerid, -input);

		format(string, sizeof(string), "SERVER:{FFFFFF} You have deposited $%d into your bank account.", input);
		SendClientMessage(playerid, 0x46E850FF, string);

		format(string, sizeof(string), "SERVER:{FFFFFF} Old balance: $%d | New balance: $%d", pOldBalance[playerid], pInfo[playerid][BankMoney]);
		SendClientMessage(playerid, 0x46E850FF, string);
	}

	else SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not near the bank!");

	return 1;
}
At the moment It's only letting me deposit at ONE position. How do i make it so that I can deposit at that position Plus these 2:
Код:
	if(IsPlayerInRangeOfPoint(playerid, 3.0, 280.8637, 1895.0920, 499.2859))
	if(IsPlayerInRangeOfPoint(playerid, 3.0, 285.8258, 1895.0934, 499.2859))
Reply
#2

Use this:

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, 290.2423, 1895.1035, 499.2859) || IsPlayerInRangeOfPoint(playerid, 3.0, 280.8637, 1895.0920, 499.2859) || IsPlayerInRangeOfPoint(playerid, 3.0, 285.8258, 1895.0934, 499.2859))
"||" is the compiler's way of reading "or"
Reply
#3

pawn Код:
new Float: bankPos[][ 3 ] = {
{ 290.2423, 1895.1035, 499.2859},
{ 280.8637, 1895.0920, 499.2859},
{ 285.8258, 1895.0934, 499.2859}
//More banks
};

stock IsPlayerInRangeOfBank(playerid, Float: range)
{
    for(new i = 0; i < sizeof bankPos; i++) {
        if(IsPlayerInRangeOfPoint(playerid, range, bankPos[i][0], bankPos[i][1], bankPos[i][2])) return 1;
    }
    return 0;
}

CMD:deposit(playerid, params[])
{
    new string[128], input;

    if(sscanf(params, "i", input)) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} /deposit [amount]");
    if(GetPlayerMoney(playerid) < input) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You don't have that much money!");

    if(IsPlayerInRangeOfBank(playerid, 3.0))
    {
        pOldBalance[playerid] = pInfo[playerid][BankMoney]; // save old var
        pInfo[playerid][BankMoney] += input, GivePlayerMoney(playerid, -input);

        format(string, sizeof(string), "SERVER:{FFFFFF} You have deposited $%d into your bank account.", input);
        SendClientMessage(playerid, 0x46E850FF, string);

        format(string, sizeof(string), "SERVER:{FFFFFF} Old balance: $%d | New balance: $%d", pOldBalance[playerid], pInfo[playerid][BankMoney]);
        SendClientMessage(playerid, 0x46E850FF, string);
    }

    else SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not near the bank!");

    return 1;
}
Whenever you want to add banks, just get X, Y and Z and add to the array.
Reply
#4

He got his answer in the first reply, lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)