05.08.2013, 10:49
(
Последний раз редактировалось Vanter; 05.08.2013 в 13:34.
)
here it goes, it's really simple
pawn Код:
CMD:pullover(playerid,params[])
{
new string[128];
new ID;
new pname[MAX_PLAYER_NAME];
new tname[MAX_PLAYER_NAME];
if(gTeam[playerid] == TEAM_CIVIL) //To check if player is NOT a law enforcement, "use your team defining"
{
SendClientMessage(playerid,COLOR_RED,"[ERROR] Only law enforcement officers can use this command.");
return 1;
}
if(sscanf(params, "u", ID)) //you must have sscanf2 installed in order to use this command, if not request a normal one, I'll post
{
SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /pullover (Player Name/ID)");
return 1;
}
if(!IsPlayerConnected(ID)) //if you entered a wrong ID
{
format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
if(playerid == ID) //if you're asking yourself to pull over
{
SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot ask yourself to pull over.");
return 1;
}
//removed isspawned for you.
GetPlayerName(playerid,pname,sizeof(pname));
GetPlayerName(ID,tname,sizeof(tname));
if(GetDistanceBetweenPlayers(playerid,ID) > 30) //stock below
{
format(string,sizeof(string),"[ERROR] %s(%d) is too far away to ask them to pull over.",tname,ID);
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
if(IsPlayerInAnyVehicle(ID) == 0) //doesn't need defining, checking if ID is not in a vehicle
{
format(string,sizeof(string),"[ERROR] %s(%d) must be in a vehicle in order to ask them to pull over.",tname,ID);
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
//finally through all stages, now the stage of pulling them over
format(string,sizeof(string),"[POLICE] Law Enforcement Officer %s(%d) asked you to pull over.",pname,playerid);
SendClientMessage(ID,COLOR_BLUE,string);
format(string, sizeof(string), "~b~pull over!");
GameTextForPlayer(ID, string, 2000, 5);
format(string,sizeof(string),"[POLICE] You have asked %s(%d) to pull over.",tname,ID);
SendClientMessage(playerid,COLOR_BLUE,string);
return 1;
}
//GetDistanceBetweenPlayers
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}