11.06.2013, 00:28
hi guys , i have this command right here
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
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;
}