Detain/Drag Command Help
#1

Hi, I'm a new scripter and I'm trying to create a detain command but I can't create it. So, I came here to take help from the professionals.

pawn Код:
if(strcmp(cmd, "/detain", 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) {
    SendClientMessage(playerid,COLOR_ERROR,"You are not Law Enforcement");
    return 1;
    }
    if(Jailed[playerid] ==1) {
    SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command in jail");
    return 1;
    }
    if(InDerby[playerid] == 1) {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command while you are in the stadium");
    return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /detain (id)");
    return 1;
    }
    giveplayerid = strval(tmp);
    if(!IsPlayerConnected(giveplayerid)) {
    format(string, sizeof(string), "ID (%d) is not an active player", giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }
    new oname[24];
    new pname[24];
    GetPlayerName(playerid,oname, 24);
    GetPlayerName(giveplayerid, pname, 24);

    if(!IsNumeric(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /detain (id) ID Must be a number");
    return 1;
    }

    if(gTeam[giveplayerid] <= 2) {
    SendClientMessage(playerid, COLOR_ERROR, "You cannot drag a Law Enforcement agent");
    return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 4) {
    format(string, sizeof(string), "%s(%d) Is not close enough you cannot drag that player",pname, giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }

    if(InAdminMode[giveplayerid] == 1337) {
    format(string, sizeof(string), "%s(%d) Is a server Admin. He / She is in Admin Mode. You cannot use this command on this player at this time",pname, giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    format(string, sizeof(string), "(ADMIN MODE) %s(%d) Has attempted to drag you. You are in Admin mode. You cannot be dragged",oname,playerid);
    SendClientMessage(giveplayerid, 0xFF7F50AA, string);
    return 1;
    }
    if(Jailed[giveplayerid] == 1) {
    format(string, sizeof(string), "%s(%d) Is in jail. You cannot drag a prisoner",pname, giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
    SendClientMessage(playerid, COLOR_ERROR, "You cannot drag a player from inside a car");
    return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) {
    SendClientMessage(playerid, COLOR_ERROR, "You cannot drag a player from inside a car");
    return 1;
    }
    if(GetPlayerState(giveplayerid) == PLAYER_STATE_PASSENGER) {
    format(string, sizeof(string), "%s(%d) Is in a vehicle. Ask the player to get out before trying to drag him", pname, giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }
    if(GetPlayerState(giveplayerid) == PLAYER_STATE_DRIVER) {
    format(string, sizeof(string), "%s(%d) Is in a vehicle. Ask the player to get out before trying to drag him", pname, giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }
    if(gTeam[playerid] == TEAM_CASSEC && GetPlayerWantedLevel(giveplayerid) <=3) {
    SendClientMessage(playerid, COLOR_ERROR, "Casino Security agents can only handcuff suspects.");
    return 1;
    }

    if(GetPlayerState(giveplayerid) == PLAYER_STATE_ONFOOT) {
    SendClientMessage(giveplayerid, 0xA9A9A9AA, "| Dragged |");
    format(string, sizeof(string), "%s(%d): Has dragged you into his car",oname, playerid);
    SendClientMessage(giveplayerid, COLOR_DODGERBLUE, string);
    PutPlayerInVehicle(giveplayerid, gLastCar[playerid], 0);
    SendClientMessage(playerid, 0xA9A9A9AA, "| Suspect Dragged |");
    format(string, sizeof(string), "You have dragged %s(%d) into your vehicle", pname, giveplayerid);
    SendClientMessage(playerid, COLOR_DODGERBLUE, string);
    }
    return 1;
    }
This is what I came up with so far.
As I said, I'm new and there will be many mistakes here, so please help me with creating a detain command.

EDIT: There are no errors in compiler but when I try the command it doesn't put him in the vehicle. Please tell me my mistake and what to put where to solve this.
Reply


Messages In This Thread
Detain/Drag Command Help - by humayunaftabkhan02 - 24.04.2016, 17:06
Re: Detain/Drag Command Help - by mongi - 24.04.2016, 20:45
Re: Detain/Drag Command Help - by DTV - 24.04.2016, 20:57
Re: Detain/Drag Command Help - by humayunaftabkhan02 - 25.04.2016, 10:13

Forum Jump:


Users browsing this thread: 1 Guest(s)