arrest o.o
#1

hi guys , i have this command right here

pawn Код:
CMD:ar(playerid,params[])
{
    new targetid;
    if(gTeam[playerid] == TEAM_CIA && gTeam[targetid] == TEAM_CIA) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_CIA && gTeam[targetid] == TEAM_COPS) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_CIA && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_COPS && gTeam[targetid] == TEAM_CIA) return SendClientMessage(playerid,-1,"You Can't Cuff This Player");
    if(gTeam[playerid] == TEAM_COPS && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_COPS && gTeam[targetid] == TEAM_COPS) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_ARMY && gTeam[targetid] == TEAM_CIA) return SendClientMessage(playerid,-1,"You Can't Cuff This Player");
    if(gTeam[playerid] == TEAM_ARMY && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_ARMY && gTeam[targetid] == TEAM_COPS) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_MADTH || gTeam[playerid] == TEAM_THGANG || gTeam[playerid] == TEAM_ROBBERS) return SendClientMessage(playerid,-1,"You Can't arrest any player");
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid,-1, "[USAGE]: /arrest [name/id]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player not found.");
    if(targetid == playerid) return SendClientMessage(playerid, -1, "You cant arrest yourself.");
    if(IsPlayerInAnyVehicle(targetid) && IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You cant arrest players through vehicles.");//this will check that if the player you want to arrest is connected to the server or not.
    if(!SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000)) return SendClientMessage(playerid,-1,"Player is not cuffed!");
    {
    new Float:x, Float:y, Float:z;//these are the defines of your x,y and z position.
    GetPlayerPos(playerid, x, y, z);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
    if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
    {
        GameTextForPlayer(targetid, "~g~arrested", 3000, 5);
        GameTextForPlayer(playerid, "~r~Suspect arrested", 3000, 5);
        new str[512];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
        new name[MAX_PLAYER_NAME];//this is the variable you created to store the your name.
        GetPlayerName(playerid, name, sizeof(name));//this will get your name and store it in the variable you defines as name.
        new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
        GetPlayerName(targetid, target, sizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
        format(str, sizeof(str), "INFO: You have arrested %s!",target);//explained at the end of the tutorial.
        SendClientMessage(playerid, 0xE01B1B, str);//this will send the formated message to you that you created before.
        format(str, sizeof(str), "WARNING: You have been arrested by %s!",name);//explained at the end of the tutorial.
        SendClientMessage(targetid, 0xE01B1B, str);//this will send the formated message to the player you cuffed.
        SetPlayerSpecialAction(targetid,SPECIAL_ACTION_HANDSUP);
        SetPlayerWantedLevel(targetid,0);
        if(GetPlayerWantedLevel(playerid) >= 4)
        {
        TextDrawShowForPlayer(targetid, Textdraw0);
        }
        pInfo[playerid][CopScores] ++;
        pInfo[targetid][arrested] ++;
        return 1;
        }

}
return 1;
}
now the problem that , when i try to arrest a player even if this player is not a cop it tells me the error : you can't arrest this player
Reply
#2

why you are using all this code ?
pawn Код:
if(gTeam[playerid] == TEAM_CIA && gTeam[targetid] == TEAM_CIA) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_CIA && gTeam[targetid] == TEAM_COPS) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_CIA && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_COPS && gTeam[targetid] == TEAM_CIA) return SendClientMessage(playerid,-1,"You Can't Cuff This Player");
    if(gTeam[playerid] == TEAM_COPS && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_COPS && gTeam[targetid] == TEAM_COPS) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_ARMY && gTeam[targetid] == TEAM_CIA) return SendClientMessage(playerid,-1,"You Can't Cuff This Player");
    if(gTeam[playerid] == TEAM_ARMY && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_ARMY && gTeam[targetid] == TEAM_COPS) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
    if(gTeam[playerid] == TEAM_MADTH || gTeam[playerid] == TEAM_THGANG || gTeam[playerid] == TEAM_ROBBERS) return SendClientMessage(playerid,-1,"You Can't arrest any player");
just use
pawn Код:
{
     if(gTeam[targetid] != TEAM_COPS)
     {
           //arrest code here  
     }else{
     SendClientMessage(playerid,-1,"target is a cop :D"); }
  }
Reply
#3

what do you mean? sorry don't understand you can you please give me it totally?

i mean give me the edited code
Reply
#4

help pls pls pls pls pls pls
Reply
#5

i dont know what team is allowed or not u need to explain more!
Reply
#6

my teams that can arrest :

TEAM_ARMY,TEAM_SWAT,TEAM_COPS,TEAM_CIA

teams that can't arrest :

TEAM_MADTH , TEAM_ROBBERS, TEAM_THGANG

my problem :

i don't want a cop or cia or a swat or an army to be arrested/cuffed/uncuffed by a police or a swat or an army or a cia

enough?
Reply
#7

this is ur check then
pawn Код:
//check if the player can use it first
if(gTeam[playerid] != TEAM_COPS || gTeam[playerid] != TEAM_SWAT || gTeam[playerid] != TEAM_CIA || gTeam[playerid] != TEAM_ARMY) return SendClientMessage(playerid,-1,"You are not allowed to arrest players!");
//now the team check
if(gTeam[targetid] == TEAM_COPS || gTeam[targetid] == TEAM_SWAT || gTeam[targetid] == TEAM_CIA || gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
//continue
simpler version, dont know if it will work though

pawn Код:
if(gTeam[playerid] != (TEAM_COPS ,TEAM_SWAT , TEAM_CIA ,TEAM_ARMY)) return SendClientMessage(playerid,-1,"You are not allowed to arrest players!");
if(gTeam[targetid] == (TEAM_COPS , TEAM_SWAT , TEAM_CIA ,TEAM_ARMY)) return SendClientMessage(playerid,-1,"You Can't arrest This Player");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)