SA-MP Forums Archive
Command for near Player - 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: Command for near Player (/showthread.php?tid=174292)



Command for near Player - HardstylerNiko - 05.09.2010

Hey Guys, i need again your help >.<
I need a piece of a cmd, that allows me to ''catch'' near player with the ID, but i don't know how to get the Distance between the Player wich is using it, and the Player he wants to catch >.<
What Thing do i have to use?


Re: Command for near Player - Mauzen - 05.09.2010

There are some includes or functions that offer a PointToPoint or PlayerToPlayer function. You can look for this, or use this formula to create one yourself

distance = floatsqroot( (px - tx) * (px - tx) - (py - ty) * (py - ty) + (pz - tz) * (pz - tz) )

With px/py/pz beeing the coordinates of player 1 and tx/ty/tz of player 2 (the order does not matter). You would just have to get them with GetPlayerPos.


Re: Command for near Player - sickem - 05.09.2010

i needed it to Thanks


Re: Command for near Player - HardstylerNiko - 05.09.2010

okay, thanks, but i have NO IDEA how to add that -.-
Please, a last time: can anyone inject it into my script?
Код:
if(strcmp("/catch", cmdtext, true, 10) ==0)
	{
	    if(AccInfo[playerid][hns] == 1)
		{
			if(GetDistanceFromMeToPoint(GetPlayerPos(playerid,x,y,z), player1) <= 50)
		    {
				if(GetPlayerTeam(playerid) == GetPlayerTeam(player1))
				{
			    	SendClientMessage(playerid,red,"Error, you can't catch your own Teammember!");
			    	return 1;
				}
				else
				{
   				SendClientMessage(playerid,red,"You Caughted %s. You earned +1 Score and 2000$!" ,playername);
      			SendClientMessage(playerid,red,"You got caught by %s . Next time pay more attention to those Players!" ,playername);
        		SetPlayerSpecialAction(player1,SPECIAL_ACTION_HANDSUP);
	        	GameTextForPlayer(player1,"~r~Caught by %s",3000,3, playername);
	        	SpawnPlayer(player1);
	        	return 1;
			}
			}
			else
			{
   				SendClientMessage(playerid,red,"Error: There's no Enemie you could catch!");
				return 1;
		}
		}
		else
		{
		SendClientMessage(playerid,red,"Sorry Dude, you have to be in ''Hide'n'Seak to use this cmd!");
		return 1;
	}
	}