SA-MP Forums Archive
Distance For /Ar - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Distance For /Ar (/showthread.php?tid=113139)



Distance For /Ar - Lajko1 - 12.12.2009

Hello Guys i Made my first Command With zcmd + sscanf (i think so)

so i want to know how i can add Distance Between players i know there is 1 function but ...

so here is the full command /ar

Code:
CMD:ar(playerid, params[])
{
  new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	
	new PlayerScore;
	GetPlayerScore(PlayerScore);
	
  new string[256];
  
  new
    giveplayerid;

  if (sscanf(params, "u", giveplayerid))return SendClientMessage(playerid, 0xFF9900AA, "Usage: \"/ar [playerid/name]\"");
  else if (giveplayerid == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF9900AA, "Player Not Found");
  else if (giveplayerid == playerid)return SendClientMessage(playerid,0xFF9900AA,"You Can't Arrest Yourself!");
  else if (GetPlayerWantedLevel(giveplayerid) >= 3)return SendClientMessage(playerid,0xFF9900AA,"This Player Is Low Wanted Level!");
  else if (gTeam[playerid] != TEAM_COP)return SendClientMessage(playerid,0xFF9900AA,"Only Cops Can Use This Command!");
  else if (giveplayerid == TEAM_COP)return SendClientMessage(playerid,0xFF9900AA,"You Can't Arrest Law Enforcement Officer");
  else
  {
  	if(GetPlayerWantedLevel(giveplayerid) == 6)
  	{
  	GivePlayerMoney(playerid,8000);
  	SetPlayerScore(playerid,PlayerScore +2);
  	format(string, sizeof(string), "Most Wanted Suspect %s(%d) Has Been Arrested By Officer %s(%d).",playername,giveplayerid,playername,playerid);
		SendClientMessageToAll(0x33CCFFAA,string);
		
		format(string, sizeof(string), "You Have Been Arrested By Officer %s(%d).",playername,playerid);
		SendClientMessage(giveplayerid,0x33CCFFAA,string);
		GameTextForPlayer(giveplayerid,"~r~BUSTED",3000,3);
		SetPlayerScore(giveplayerid,PlayerScore -1);
		new rand = random(sizeof(JailedPlayerSpawns));
		SetPlayerPos(playerid, JailedPlayerSpawns[rand][0], JailedPlayerSpawns[rand][1], JailedPlayerSpawns[rand][2]); // Warp the player
		
		format(string, sizeof(string), "You Arrested Most Wanted Suspect %s(%d) And Earn $8000!",playername,giveplayerid);
		SendClientMessage(playerid,0x33CCFFAA,string);
		GameTextForPlayer(playerid,"~b~PERFECT",3000,3);
		
		ResetPlayerWeapons(giveplayerid);
		
		// ANIMATIONS
		SetPlayerSpecialAction(giveplayerid,SPECIAL_ACTION_HANDSUP);
		ApplyAnimation(playerid,"PED","ARRESTgun",4.1,1,1,1,1,1);
		}
		if(GetPlayerWantedLevel(giveplayerid) == 5)
		{
		GivePlayerMoney(playerid,6000);
		SetPlayerScore(playerid,PlayerScore +1);
		format(string, sizeof(string), "Suspect %s(%d) Has Been Arrested By Officer %s(%d).",playername,giveplayerid,playername,playerid);
		SendClientMessageToAll(0x33CCFFAA,string);
		
		format(string, sizeof(string), "You Have Been Arrested By Officer %s(%d).",playername,playerid);
		SendClientMessage(giveplayerid,0x33CCFFAA,string);
		GameTextForPlayer(giveplayerid,"~r~BUSTED",3000,3);
		SetPlayerScore(giveplayerid,PlayerScore -1);
		new rand = random(sizeof(JailedPlayerSpawns));
		SetPlayerPos(playerid, JailedPlayerSpawns[rand][0], JailedPlayerSpawns[rand][1], JailedPlayerSpawns[rand][2]); // Warp the player
		
		format(string, sizeof(string), "You Arrested Suspect %s(%d) And Earn $6000!",playername,giveplayerid);
		SendClientMessage(playerid,0x33CCFFAA,string);
		GameTextForPlayer(playerid,"~b~GREAT",3000,3);
		
		ResetPlayerWeapons(giveplayerid);
		
		// ANIMATIONS
		SetPlayerSpecialAction(giveplayerid,SPECIAL_ACTION_HANDSUP);
		ApplyAnimation(playerid,"PED","ARRESTgun",4.1,1,1,1,1,1);
		}
		if(GetPlayerWantedLevel(giveplayerid) == 4)
		{
		GivePlayerMoney(playerid,5000);
		SetPlayerScore(playerid,PlayerScore +1);
		format(string, sizeof(string), "Suspect %s(%d) Has Been Arrested By Officer %s(%d).",playername,giveplayerid,playername,playerid);
		SendClientMessageToAll(0x33CCFFAA,string);
		
		format(string, sizeof(string), "You Have Been Arrested By Officer %s(%d).",playername,playerid);
		SendClientMessage(giveplayerid,0x33CCFFAA,string);
		GameTextForPlayer(giveplayerid,"~r~BUSTED",3000,3);
		SetPlayerScore(giveplayerid,PlayerScore -1);
		new rand = random(sizeof(JailedPlayerSpawns));
		SetPlayerPos(playerid, JailedPlayerSpawns[rand][0], JailedPlayerSpawns[rand][1], JailedPlayerSpawns[rand][2]); // Warp the player
		
		format(string, sizeof(string), "You Arrested Suspect %s(%d) And Earn $5000!",playername,giveplayerid);
		SendClientMessage(playerid,0x33CCFFAA,string);
		GameTextForPlayer(playerid,"~b~GREAT",3000,3);
		
		ResetPlayerWeapons(giveplayerid);
		
		// ANIMATIONS
		SetPlayerSpecialAction(giveplayerid,SPECIAL_ACTION_HANDSUP);
		ApplyAnimation(playerid,"PED","ARRESTgun",4.1,1,1,1,1,1);
		}
	}
	return 1;
}
just tell me how i can make that Cop and Wanted Suspect must be closer for /ar ? how to make that

ty for any help


Re: Distance For /Ar - Finn - 12.12.2009

Write / search for a GetDistanceBetweenPlayers function and make it check the distance at some point in your command.


Re: Distance For /Ar - Donny_k - 12.12.2009

pawn Code:
if ( IsPlayerInRangeOfPoint( otherid, 1.0, my_x, my_y, my_z ) ) //or whatever the args for that func are.
{
  //arrest them
}
else
{
  //they are out of range
}



Re: Distance For /Ar - Lajko1 - 12.12.2009

ty