15.02.2012, 20:15
pawn Код:
#include < a_samp >
#include < zcmd >
#include < sscanf2 >
#define red -1
#define blue -1
#define TEAM_COP 1
#define TEAM_CIV 2
new gTeam[MAX_PLAYERS], IsSpawned[MAX_PLAYERS];
CMD:ar(playerid,params[])
{
new ID, id,n[MAX_PLAYER_NAME], on[MAX_PLAYER_NAME];
if(gTeam[playerid] != TEAM_COP && gTeam[playerid] != TEAM_CIV)
{
SendClientMessage(playerid,red,"Only law enforcement can arrest wanted suspects.");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
new string2[128];
format(string2,sizeof(string2),"%s(%d) is too far away. You cannot reach him to arrest him.",on,id);
SendClientMessage(playerid,red,string2);
return 1;
}
if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,red,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(GetPlayerWantedLevel(ID) < 3)
{
new string4[128];
format(string4,sizeof(string4),"%s(%d)'s wanted level is too low. You cannot jail them. Use /ticket (Player ID).",n,playerid);
SendClientMessage(playerid,red,string4);
return 1;
}
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't arrest a suspect if you are in a vehicle.");
if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Invalid Player ID.");
if(playerid == id) return SendClientMessage(playerid,red, "You cannot arrest yourself.");
if(sscanf(params,"uz",id)) return SendClientMessage(playerid,red,"Usage:/ar [ID]");
else {
GetPlayerName(playerid,n,sizeof(n));
GetPlayerName(id,on,sizeof(on));
new string[100];
format(string,sizeof(string),"You've arrested %s(%d).",n,id);
SendClientMessage(playerid,blue,string);
new string2[128];
format(string2, sizeof(string), "%s has been arrested by %s",n,playerid,on,id);
SendClientMessageToAll(red,string2);
}
return true;
}
stock GetDistanceBetweenPlayers(playerid, playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
pawn Код:
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase