My /kidnap is bugged
#1

Hello, My kidnap command is having issues, It says "Player must be a passenger" When they already are.


pawn Код:
if(strcmp(cmd, "/kidnap", true) == 0)
{
  if(IsSpawned[playerid] == 0) {
    SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command.");
    return 1;
  }
  if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_ARMY ||
    gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_CASSEC ||
    gTeam[playerid] == TEAM_JAILTK || gTeam[playerid] == TEAM_DRIVER ||
  gTeam[playerid] == TEAM_MARINE || gTeam[playerid] == TEAM_AIRSUPPORT) {
    SendClientMessage(playerid,COLOR_ERROR,"Law enforcment officers cannnot kidnap players");
    return 1;
  }
  if(gTeam[playerid] != TEAM_KIDNAPPER) {
    SendClientMessage(playerid, COLOR_ERROR, "Only Kidnappers can use this command");
    return 1;
  }
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /kidnap (id)");
    return 1;
  }
  if(cuffed[playerid] == 1) {
    SendClientMessage(playerid,COLOR_ERROR,"You are handcuffed. You cannot use this command");
    return 1;
  }
  if(isKidnapped[playerid] == 1) {
    SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped yourself, pay the kidnapper with /ransom.");
    return 1;
  }
  if(Jailed[playerid] == 1) {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command in jail");
    return 1;
  }
  if(!IsNumeric(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /kidnap (id) ID Must be a number");
    return 1;
  }
  if(strval(tmp) == playerid) {
    SendClientMessage(playerid, COLOR_ERROR, "You cannot kidnap yourself");
    return 1;
  }
  if(GetPlayerState(giveplayerid) != PLAYER_STATE_PASSENGER) {
    SendClientMessage(playerid,COLOR_ERROR,"The player must be a passanger");
    return 1;
  }
  if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) {
    SendClientMessage(playerid, COLOR_ERROR, "You are not the driver of this vehicle. Only the driver can kidnap players");
    return 1;
  }
  if(cuffed[giveplayerid] == 1) {
    SendClientMessage(playerid,COLOR_ERROR,"This player is cuffed, you cannot kidnap him");
    return 1;
  }
  new kidnappername[24];
  new victimname[24];
  GetPlayerName(playerid,kidnappername, 24);
  GetPlayerName(giveplayerid, victimname, 24);
  if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3) {
    format(szstring, sizeof(szstring), "%s(%d) Is not close enough. You cannot kidnap that player",victimname,giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, szstring);
    return 1;
  }
  if(GetPlayerState(giveplayerid) == PLAYER_STATE_PASSENGER) {
    format(szstring, sizeof(szstring), "You have kidnapped %s(%d).",victimname,giveplayerid);
    SendClientMessage(playerid,COLOR_ROYALBLUE,szstring);
    SendClientMessage(giveplayerid,COLOR_ERROR,"You have been kidnapped!");
    format(szstring, sizeof(szstring), "(Kidnapping) %s(%d) Has been kidnapped by $%d",kidnappername,playerid,victimname,giveplayerid);
    SendClientMessageToAll(0x00C7FFAA,szstring);
    TogglePlayerControllable(giveplayerid, 0);
    isKidnapped[giveplayerid] = 1;
    kidnapTimer[giveplayerid] = 180;
    new pcol = GetPlayerColor(playerid);
    new plwl = GetPlayerWantedLevel(playerid);
    plwl = GetPlayerWantedLevel(playerid);
    commitedcrimerecently[playerid] +=120;
    SetPlayerWantedLevel(playerid, plwl +4);
    SendClientMessage(playerid, 0xA9A9A9AA, "|_Crime Commited_|");
    format(szstring, sizeof(szstring), "(KIDNAPPING) Wanted Level %d",plwl);
    SendClientMessage(playerid,pcol,szstring);
    oscore = GetPlayerScore(playerid);
    SetPlayerScore(playerid, oscore +1);
    for(new i=0;i<MAX_PLAYERS;i++) {
      if(LawEnforcementRadio[i] == 1) {
        new szstring1[256];
        new szstring2[256];
        new current_zone;
        current_zone = player_zone[playerid];
        format(szstring1, sizeof(szstring1), "DISPATCH: (KIDNAPPING) Suspect: %s(%d) Victim:",kidnappername,playerid,victimname,giveplayerid);
        format(szstring2, sizeof(szstring2), "ALL UNITS: Please respond to %s and arrest %s(%d)",zones[current_zone][zone_name],kidnappername,giveplayerid);
        SendClientMessage(i, COLOR_ROYALBLUE, szstring1);
        SendClientMessage(i, COLOR_ROYALBLUE, szstring2);
      }
    }
  }
  return 1;
}
Can't seem to see the problem, please help.
Reply
#2

NVM

Use return messagehere;

Instead of brackets and return 1 ect
Reply
#3

Quote:
Originally Posted by Torran
NVM

Use return messagehere;

Instead of brackets and return 1 ect
Huh? lol, i didn't understand
Reply
#4

Well instead of

pawn Код:
if(gTeam[playerid] != TEAM_KIDNAPPER) {
    SendClientMessage(playerid, COLOR_ERROR, "Only Kidnappers can use this command");
return 1;
}

You would have:

pawn Код:
if(gTeam[playerid] != TEAM_KIDNAPPER) return SendClientMessage(playerid, COLOR_ERROR, "Only Kidnappers can use this command");
Reply
#5

Rather keep sticking to

Код:
if(gTeam[playerid] != TEAM_KIDNAPPER) 
{
    SendClientMessage(playerid, COLOR_ERROR, "Only Kidnappers can use this command");
    return 1;
}
Where is giveplayerid defined?
Reply
#6

I don't understand....Torran how will that fix my problem, and Juice what do you mean?




EDIT: I did it Torran, didn't work
Reply
#7

As I said, keep sticking to your prior code

Код:
if(gTeam[playerid] != TEAM_KIDNAPPER) 
{
    SendClientMessage(playerid, COLOR_ERROR, "Only Kidnappers can use this command");
    return 1;
}
The problem is somewhere in your if-clause

Код:
if(GetPlayerState(giveplayerid) != PLAYER_STATE_PASSENGER) {
    SendClientMessage(playerid,COLOR_ERROR,"The player must be a passanger");
    return 1;
}
according to your description.

As there is a variable called "giveplayerid" I wonder where you declare that one.
Reply
#8

This is what i have:


giveplayerid = strval(tmp);
Reply
#9

And why isn't that somewhere in your if-statement "if(strcmp(cmd, "/kidnap", true) == 0)"?
Reply
#10

Quote:
Originally Posted by MWF2
I don't understand....Torran how will that fix my problem, and Juice what do you mean?
I never said it will fix it.. It just makes your code shorter
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)