/detain doens't work.
#1

It says the message and all, but it doens't put the player in the vehicle

pawn Код:
if(strcmp(cmd, "/detain", true) == 0)
{
  if(!IsPlayerConnected(playerid)) {
    SendClientMessage(playerid, COLOR_RED, "You must be logged in to use this command!");
    return 1;
  }
  if(PlayerInfo[playerid][pFaction] != 11) {
    SendClientMessage(playerid, COLOR_RED, "You arent a police officer!");
    return 1;
  }
  if(giveplayerid == playerid) {
    SendClientMessage(playerid, COLOR_GREY, "You cannot detain yourself!");
    return 1;
  }
  if(IsPlayerInAnyVehicle(playerid)) {
    SendClientMessage(playerid, COLOR_RED, "You cannot be in a vehicle to use this command!");
    return 1;
  }
  tmp = strtok(cmdtext, idx);
  if (!strlen(tmp))
    return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [playerid] [seatid(1-3)]");
  if(IsStringAName(tmp)) {
    giveplayerid = GetPlayerID(tmp);
  }
  else {
    giveplayerid = strval(tmp);
  }
  tmp = strtok(cmdtext, idx);
  if (!strlen(tmp))
    return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [playerid] [seatid(1-3)]");
  new seat = strval(tmp);
  if(!IsPlayerConnected(giveplayerid)) {
    SendClientMessage(playerid, COLOR_RED, "That player isnt connected!");
    return 1;
  }
  if(giveplayerid == INVALID_PLAYER_ID) {
    SendClientMessage(playerid, COLOR_RED, "Invalid Player ID");
    return 1;
  }
  if(seat < 1 || seat > 3) {
    SendClientMessage(playerid, COLOR_GRAD1, "Seat ID must be below 3 and above 1");
    return 1;
  }
  if(gTeam[giveplayerid] == 2) {
    SendClientMessage(playerid, COLOR_RED, "You cannot detain other police officers!");
    return 1;
  }
  if(IsPlayerInAnyVehicle(giveplayerid)) {
    SendClientMessage(playerid, COLOR_RED, "The suspect you are trying to detain is in a vehicle!");
    return 1;
  }
  if(!ProxDetectorS(8.0, playerid, giveplayerid)) {
    SendClientMessage(playerid, COLOR_RED, "You arent close enough to the suspect!");
    return 1;
  }
  if(cuffed[giveplayerid] != 1) {
    SendClientMessage(playerid, COLOR_RED, "That player isnt cuffed!");
    return 1;
  }
  new carid = gLastCar[playerid];
  new Float:carx,Float:cary,Float:carz;
  GetVehiclePos(carid,carx,cary,carz);
  IsPlayerInRangeOfPoint(playerid, 15, carz, cary, carz);
  {
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* You were detained by Officer %s", sendername);
    SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "* You detained %s", giveplayer);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "* %s throws %s into his/her car", sendername ,giveplayer);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    GameTextForPlayer(giveplayerid, "~r~Detained", 2500, 3);
    PutPlayerInVehicle(giveplayerid,carid,seat);
    ClearAnimations(giveplayerid);
    TogglePlayerControllable(giveplayerid, 0);
  }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)