SA-MP Forums Archive
Command is doing nothing... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command is doing nothing... (/showthread.php?tid=66901)



Command is doing nothing... - Robbin237 - 25.02.2009

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;
}



Re: Command is doing nothing... - Rks25 - 25.02.2009

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


Re: Command is doing nothing... - Robbin237 - 25.02.2009

yes


Re: Command is doing nothing... - Rks25 - 25.02.2009

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.


Re: Command is doing nothing... - 1337pr0 - 26.02.2009

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 :/