Command is doing nothing...
#1

Hey guys, i made a ransom command, but when i type like /ransom 0, it wont do anything.
Please help me!

pawn Код:
dcmd_ransom(playerid, params[])
{
    new torelease;
    torelease = strval(params);

    if (!IsPlayerConnected(torelease))
    {
        SendClientMessage(COLOR_RED, playerid, "Player Is Not Connected Or Kidnapped!");
    } else {
        if(GetPlayerMoney(playerid) > PlayerRansom[torelease])
        {
            GivePlayerMoney(PlayerKidnapper[torelease], PlayerRansom[torelease]);
            Kidnapped[torelease] = 0;
            TogglePlayerControllable(torelease, 1);
        } else {
          SendClientMessage(COLOR_RED, playerid, "You Dont Have Enough Money To Pay His/Her Ransom!");
        }
    }
    return 1;
}
Reply
#2

did you place an dcmd(ransom,6,cmdtext); to start with?
Reply
#3

yes
Reply
#4

Try:
pawn Код:
dcmd_ransom(playerid, params[]) {
#pragma unused params
  new id;
  new pname[24];
  new str[128];
  if(sscanf(params, "is", id, text))
    return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Correct Usage: /ransom [id]");
  if(!IsPlayerConnected(id))
  {
    format(str, sizeof(str), "* ID %d is not an active player.", id);
    SendClientMessage(playerid, COLOR_RED, str);
    return 1;
  }
  if(GetPlayerMoney(playerid) > PlayerRansom[id])
  {
    GivePlayerMoney(PlayerKidnapper[id], PlayerRansom[id]);
    Kidnapped[id] = 0;
    TogglePlayerControllable(id, 1);
  } else {
    SendClientMessage(COLOR_RED, playerid, "You Dont Have Enough Money To Pay His/Her Ransom!");
  }
  return true;
}
You do need function sscanf for this.
Reply
#5

Quote:
Originally Posted by Rks_
Try:
pawn Код:
dcmd_ransom(playerid, params[]) {
#pragma unused params
  new id;
  new pname[24];
  new str[128];
  if(sscanf(params, "is", id, text))
    return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Correct Usage: /ransom [id]");
  if(!IsPlayerConnected(id))
  {
    format(str, sizeof(str), "* ID %d is not an active player.", id);
    SendClientMessage(playerid, COLOR_RED, str);
    return 1;
  }
  if(GetPlayerMoney(playerid) > PlayerRansom[id])
  {
    GivePlayerMoney(PlayerKidnapper[id], PlayerRansom[id]);
    Kidnapped[id] = 0;
    TogglePlayerControllable(id, 1);
  } else {
    SendClientMessage(COLOR_RED, playerid, "You Dont Have Enough Money To Pay His/Her Ransom!");
  }
  return true;
}
You do need function sscanf for this.
Why did you do "#pragma unused params"? That's silly, as you use the params variable like, 4 lines down :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)