[SOLVED] Need help with /buylevel command
#1

Hello guys, I need little help with this command...
Here is the code
pawn Код:
dcmd_buylevel(playerid, cmdtext[]) {
  #pragma unused cmdtext
  new str[256];
  if(PlayerInfo[playerid][Level] == 10) return SendClientMessage(playerid, COLOR_RED, "You have reached highest level and can't buy any more");
  if(PlayerInfo[playerid][Level] == 0 && PlayerInfo[playerid][Exppoints] >= LVL_1 && GetPlayerMoney(playerid) >= MLVL_1)
  {
//something
  }
  if(PlayerInfo[playerid][Level] == 1 && PlayerInfo[playerid][Exppoints] >= LVL_2 && GetPlayerMoney(playerid) >= MLVL_2)
  {
//something
  }
  if(PlayerInfo[playerid][Level] == 2 && PlayerInfo[playerid][Exppoints] >= LVL_3 && GetPlayerMoney(playerid) >= MLVL_3)
  {
//something

//MORE OF THESE BELOW....
//..............
//..............
  }
  else
  {
  SendClientMessage(playerid, COLOR_RED, "You don't have enough cash or experience.");
  }
  return 1;
}
Everything works fine, except when I try /buylevel it does everything good but it shows "You don't have enough cash or experience." even it works... it always show that message, can anyone help please!?
Reply
#2

Change the middle part to else if

pawn Код:
dcmd_buylevel(playerid, cmdtext[]) {
  #pragma unused cmdtext
  new str[256];
  if(PlayerInfo[playerid][Level] == 10) return SendClientMessage(playerid, COLOR_RED, "You have reached highest level and can't buy any more");
  if(PlayerInfo[playerid][Level] == 0 && PlayerInfo[playerid][Exppoints] >= LVL_1 && GetPlayerMoney(playerid) >= MLVL_1)
  {
//something
  }
  else if(PlayerInfo[playerid][Level] == 1 && PlayerInfo[playerid][Exppoints] >= LVL_2 && GetPlayerMoney(playerid) >= MLVL_2)
  {
//something
  }
  else if(PlayerInfo[playerid][Level] == 2 && PlayerInfo[playerid][Exppoints] >= LVL_3 && GetPlayerMoney(playerid) >= MLVL_3)
  {
//something

//MORE OF THESE BELOW....
//..............
//..............
  }
  else
  {
  SendClientMessage(playerid, COLOR_RED, "You don't have enough cash or experience.");
  }
  return 1;
}
Reply
#3

Thanks MadeMan, it's working now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)