Player doesn't have enough money ?
#1

I have this command
pawn Код:
if (strcmp("/m4", cmdtext, true, 10) == 0){
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerMoney(playerid, -500);
        return 1;
    }
How can I make it when the player doesn't have the money to give him this message :
pawn Код:
SendClientMessage(playerid, COLOR_RED, "YOU NEED MORE MONEY TO BUY THIS WEAPON !");
Reply
#2

pawn Код:
if(GetPlayerMoney(playerid) < 500)
{
    SendClientMessage(playerid, COLOR_RED, "YOU NEED MORE MONEY TO BUY THIS WEAPON !");
}
Reply
#3

Quote:
Originally Posted by Bumper
Посмотреть сообщение
I have this command
[pawn]
if (strcmp("/m4", cmdtext, true, 10) == 0){
GivePlayerWeapon(playerid, 31, 200);
GivePlayerMoney(playerid, -500);
return 1;
}

How can I make it when the player doesn't have the money to give him this message :
[pawn]
SendClientMessage(playerid, COLOR_RED, "YOU NEED MORE MONEY TO BUY THIS WEAPON !");
pawn Код:
if (strcmp("/m4", cmdtext, true, 10) == 0){
        If(GetPlayerMoney( <1000);
        GivePlayerWeapon(playerid,m4id,ammo;
        else
        {
           SendClientMessage(playerid, COLOR_RED, "You don't have enough money");
        }
        return 1;
    }
Reply
#4

pawn Код:
if (strcmp("/m4", cmdtext, true, 10) == 0){
       if (GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_COLOR,"You don't have enough money!");
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerMoney(playerid, -500);
        return 1;
    }
E: Badboy, check your code before posting it
Reply
#5

Quote:
Originally Posted by [BADBOY]
Посмотреть сообщение
if (strcmp("/m4", cmdtext, true, 10) == 0){
If(GetPlayerMoney( <1000);
GivePlayerWeapon(playerid,m4id,ammo;
else
{
SendClientMessage(playerid, COLOR_RED, "You don't have enough money");
}
return 1;
}
Did you even try compile that?
Reply
#6

Simply add a check for the players money before:

pawn Код:
if(GetPlayerMoney(playerid) < 500) {
    SendClientMessage(playerid, COLOR_RED, "YOU NEED MORE MONEY TO BUY THIS WEAPON !");
    return 1;
} else {
    ...
}
Reply
#7

pawn Код:
if (strcmp("/m4", cmdtext, true, 10) == 0){
        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,COLOR_RED,"YOU NEED MORE MONEY TO BUY THIS WEAPON !");
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerMoney(playerid, -500);
        return 1;
    }
To mikkel: You're not returning anything, so the command will continue.
Reply
#8

Badboy wrote it wrong.
Reply
#9

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
if (strcmp("/m4", cmdtext, true, 10) == 0){
        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,COLOR_RED,"YOU NEED MORE MONEY TO BUY THIS WEAPON !");
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerMoney(playerid, -500);
        return 1;
    }
To mikkel: You're not returning anything, so the command will continue.
I simply gave him what he needed.

I expect him to do 'else if' or 'else' himself.
Reply
#10

Tnx for the help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)