28.05.2011, 13:52
You need to put a check in to see if the player their trying to arrest is the same as the playerid. Something like
should work fine, If you don't want it to say 'you cannot arrest yourself' you could just put
Hopefully something like that should work.
pawn Код:
if(i == playerid) return SendClientMessage(playerid,-1,"You cannot arrest yourself");
pawn Код:
if(i != playerid)
pawn Код:
if(newkeys == KEY_LOOK_BEHIND)
{
if(gTeam[playerid] == TEAM_COPS)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(i,playerid) > 5) return SendClientMessage(playerid,COLOR_WHITE,"Nobody is close enough");
if(GetDistanceBetweenPlayers(i,playerid) < 5)
{
if(i == playerid) return SendClientMessage(playerid, -1,"You cannot arrest yourself.");
if(GetPlayerWantedLevel(i) > 0)
{
TogglePlayerControllable(i,0);
GivePlayerMoney(playerid,500);
GivePlayerMoney(i,-500);
new copname[20];
new wantedname[20];
GetPlayerName(i,wantedname,sizeof(wantedname));
GetPlayerName(playerid,copname,sizeof(copname));
new string[128];
format(string,sizeof(string),"%s(%d) has been arrested by officer %s(%d)",wantedname,i,copname,playerid);
SendClientMessageToAll(COLOR_GREY,string);
}
}
}
}
}