Bug in this command
#4

Here you go, a working code. Fixed also a couple of other small errors.
pawn Код:
dcmd_givecash(playerid,params[])
{
  new
    targetid,
    amount;

  if(sscanf(params, "ui", targetid, amount))
  {
    SendClientMessage(playerid, COLOUR_RED, "Use: /givecash [playerid] [amount]");
    return true;
  }
  if(!IsPlayerConnected(targetid))
  {
    SendClientMessage(playerid, COLOUR_RED, "Incorrect playerid.");
    return true;
  }
  if(amount < 1)
  {
    SendClientMessage(playerid, COLOUR_RED, "Invalid transaction amount");
    return 1;
  }
  new
    string[128],
    pname[MAX_PLAYER_NAME],
    pname2[MAX_PLAYER_NAME];

  GetPlayerName(playerid, pname, sizeof(pname));
  GetPlayerName(targetid, pname2, sizeof(pname2));

  format(string, sizeof(string), "%s sent you $%d", pname, amount);
  SendClientMessage(targetid,COLOUR_GREEN, string);

  format(string, sizeof(string), "You sent %s, $%d", pname2, amount);
  SendClientMessage(playerid,COLOUR_GREEN, string);
 
  GivePlayerMoney(targetid, amount);
  GivePlayerMoney(playerid, -amount);

  return true;
}
Reply


Messages In This Thread
Bug in this command - by _ERO_ - 30.08.2009, 14:40
Re: Bug in this command - by Andom - 30.08.2009, 14:43
Re: Bug in this command - by Correlli - 30.08.2009, 15:23
Re: Bug in this command - by Vince - 30.08.2009, 15:30

Forum Jump:


Users browsing this thread: 1 Guest(s)