29.07.2012, 13:56
To check what key has player pressed use OnPlayerKeyStateChange
To check if there is a suspect next to him
you can use this code(in my opinion the fastest way of doing this):
To check if there is a suspect next to him
you can use this code(in my opinion the fastest way of doing this):
pawn Код:
//global variable
new Suspects[MAX_PLAYERS+1];
//_________________________________
// under OnPlayerKeyStateChange when pressed key
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
for(new i=0;Suspects[i]!=-1;i++)
if(IsPlayerInRangeOfPoint(Suspects[i],5,x,y,z))//chage 5 if too big or small range
{
//your code
}
//_______________________________________
// once player becomes wanted/suspect
new i;
for(i=0;Suspects[i]!=-1;i++){}
Suspects[i]=playerid;//suspectid
Suspects[i+1]=-1;
//----------------------------------
//once player is no loger wanted/suspect - of is jailed, prisoned, DON'T FORGET DISCONNECTED, or something else
new i;
for(i=0;Suspects[i]!=playerid;i++){}//playerid=suspectid
while(Suspects[i]!=-1)Suspects[i]=Suspects[i+1];