How would I..
#1

In a command, I want to make it check what the player money is, then if its below the defined ammount, then it sends them a message saying not enough money bla bla.

I've tried..

pawn Код:
if(GetPlayeMoney(playerid < 800))
{
SendClientMessage(playerid,COLOR_RED,"ERROR: Not enough money!");
}
But I get bugs.
Reply
#2

Read your errors dude, you should be able to see what is wrong there.
Reply
#3

pawn Код:
if(GetPlayeMoney(playerid < 800))
{
SendClientMessage(playerid,COLOR_RED,"ERROR: Not enough money!");
return 1;
}
simple as that.

or

pawn Код:
if(GetPlayeMoney(playerid < 800))
{
//do somthing here
}else{SendClientMessage(playerid,COLOR_RED,"ERROR: Not enough money!");
return 1;
}
Reply
#4

That's still wrong Shady, look at the statement line.
Reply
#5

pawn Код:
}
    if(strcmp(cmd, "/yourcmd", true) == 0)
    {
    if(GetPlayerMoney(playerid) > 800)
    {
       // do somthing here
    }
    else
    {
    SendClientMessage(COLOR_DBLUE, playerid, "You Need At Least $800");
}
    return 1;
Reply
#6

Good man.

Would be better like this though IMO:

pawn Код:
if ( !strcmp( cmdtext, COMMAND, true, LENGTH ) )
{
  if ( GetPlayeMoney( playerid ) < 800 ) ) return SendClientMessage(playerid,COLOR_RED,"You Need At Least $800");
  //success code goes here
  return 1;
}
I like coding for false, it makes your code smaller so it takes like lines and is easier to debug as there is less of it etc but that's just my style, each to their own.
Reply
#7

Quote:
Originally Posted by Donny
Good man.

Would be better like this though IMO:

pawn Код:
if ( !strcmp( cmdtext, COMMAND, true, LENGTH ) )
{
  if ( GetPlayeMoney( playerid ) < 800 ) ) return SendClientMessage(playerid,COLOR_RED,"You Need At Least $800");
  //success code goes here
  return 1;
}
I like coding for false, it makes your code smaller so it takes like lines and is easier to debug as there is less of it etc but that's just my style, each to their own.
im exactly like that two :]
Reply
#8

or

pawn Код:
if(GetPlayerMoney(playerid)   < 800 ) return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough money !");
Reply
#9

Quote:
Originally Posted by Hiitch[WS
- WestSide Servers ]
or

pawn Код:
if(GetPlayerMoney(playerid)  < 800 ) return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough money !");
thats what donny did.
Reply
#10

Thanks for all your help, guys.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)