CMD:ar(playerid,params[])
{
new id, string[128], pwl = GetPlayerWantedLevel(id);
if(GetPlayerTeam(playerid) != Cops)
{
SendClientMessage(playerid, COLOR_RED,"Only law enforcement can arrest wanted suspects.");
return 1;
}
if(!IsPlayerConnected(id))
{
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot arrest them.",id);
SendClientMessage(playerid, COLOR_RED,string);
return 1;
}
if(Jailed[id] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You cannot arrest players that are already jailed.");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"You cannot arrest a suspect while in a vehicle. Exit the vehicle first.");
return 1;
}
if(GetPlayerState(id) == PLAYER_STATE_DRIVER || GetPlayerState(id) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(Civilian[id] == 1)
{
if(Cuffed[id] == 1)
{
if(GetDistanceBetweenPlayers(playerid, id) <= 2)
{
if(pwl >= 4)
{
GivePlayerMoney(playerid, 3000);
IncreaseScore(playerid, 1);
IncreaseCoprank(playerid, 1);
Jailed[id] = 1;
JailTime[id] = 60;
Cuffed[id] = 0;
SetPlayerInterior(id, 6);
SetPlayerPos(id, 264.29999, 77.4, 1001);
SendClientMessage(id, COLOR_LIGHTBLUE, "**LOS SANTOS PRISON**");
SendClientMessage(id, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison, you will be out of prison in 60 seconds");
SetPlayerWantedLevel(id, 0);
SetPlayerHealth(id,99999);
SetPlayerSpecialAction(id,SPECIAL_ACTION_NONE);
ResetPlayerWeapons(id);
format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d) and was given $3000 for arresting him.",GetName(playerid),playerid,GetName(id),id);
SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}
}
else return SendClientMessage(playerid,COLOR_RED,"There is no player near you that you can arrest, please search for cuffed players and make sure to be near them to be able to arrest them.");
}
}
return 1;
}
else return SendClientMessage(playerid,COLOR_RED,"There is no player near you that you can arrest, please search for cuffed players and make sure to be near them to be able to arrest them.");
GetDistanceBetweenPlayers(playerid, id)
IsPlayerInRangeOfPlayer(playerid, id, Float:range)
{
new Float:pX, Float:pY, Float: pZ;
GetPlayerPos(id, pX, pY, pZ);
if(IsPlayerInRangeOfPoint(playerid, range, pX, pY, pZ))
return 1;
else
return 0;
}
CMD:ar(playerid,params[])
{
new id, string[128], pwl = GetPlayerWantedLevel(id);
if(GetPlayerTeam(playerid) != Cops)
{
SendClientMessage(playerid, COLOR_RED,"Only law enforcement can arrest wanted suspects.");
return 1;
}
if(!IsPlayerConnected(id))
{
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot arrest them.",id);
SendClientMessage(playerid, COLOR_RED,string);
return 1;
}
if(Jailed[id] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You cannot arrest players that are already jailed.");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"You cannot arrest a suspect while in a vehicle. Exit the vehicle first.");
return 1;
}
if(GetPlayerState(id) == PLAYER_STATE_DRIVER || GetPlayerState(id) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(Civilian[id] == 1)
{
if(Cuffed[id] == 1)
{
if(GetDistanceBetweenPlayers(playerid, id, 2)
//not if(GetDistanceBetweenPlayers(playerid, id) <= 2)
{
if(pwl >= 4)
{
GivePlayerMoney(playerid, 3000);
IncreaseScore(playerid, 1);
IncreaseCoprank(playerid, 1);
Jailed[id] = 1;
JailTime[id] = 60;
Cuffed[id] = 0;
SetPlayerInterior(id, 6);
SetPlayerPos(id, 264.29999, 77.4, 1001);
SendClientMessage(id, COLOR_LIGHTBLUE, "**LOS SANTOS PRISON**");
SendClientMessage(id, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison, you will be out of prison in 60 seconds");
SetPlayerWantedLevel(id, 0);
SetPlayerHealth(id,99999);
SetPlayerSpecialAction(id,SPECIAL_ACTION_NONE);
ResetPlayerWeapons(id);
format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d) and was given $3000 for arresting him.",GetName(playerid),playerid,GetName(id),id);
SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}
}
else return SendClientMessage(playerid,COLOR_RED,"There is no player near you that you can arrest, please search for cuffed players and make sure to be near them to be able to arrest them.");
}
}
return 1;
}
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));
}
Here is the call back that i am using for it and sorry for late reply i was sleeping at the time
pawn Код:
|
GetDistanceBetweenPlayers(playerid, otherid, Float:dist)
{
new
Float:Pos[3]
;
if( IsPlayerConnected( targetid ) && IsPlayerConnected( otherid ) )
{
GetPlayerPos( otherid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
IsPlayerInRangeOfPoint( playerid, dist, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
return true;
}
return false;
}
if( !GetDistanceBetweenPlayers(playerid, otherid, Float:dist) ) //if the player is not near.
if( GetDistanceBetweenPlayers(playerid, otherid, Float:dist) ) //if the player is near.
for(new i = 0; i < MAX_PLAYERS; i++)
{
// Put code here
}