Command for near Player
#1

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?
Reply
#2

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.
Reply
#3

i needed it to Thanks
Reply
#4

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;
	}
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)