How can I see if target is in range?
#4

Quote:
Originally Posted by IzadorO
Посмотреть сообщение
First of all, you need a stock, like so:

Код:
stock GetDistanceBetweenPlayers(playerid, playerid2)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	new Float:dis;
	GetPlayerPos(playerid,x1,y1,z1);
	GetPlayerPos(playerid2,x2,y2,z2);
	dis = floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
	return floatround(dis);
}
Once you have got a stock like the above, which measures the distance between one player and the other, you would do the following:

Create the command, which would be "
Код:
CMD:pay(playerid, params[])
".

Afterwards, we have to create a 1 time variable, which would hold the ID of the player who is being paid.

Example: new id;

Once you have done everything including both IDs and the initial command itself, measure the distance between both players, via the following:

if(GetDistanceBetweenPlayers(playerid, id) < 7) - You can choose whichever range you need.

That is pretty much all there is too it.
Use that function in different virtual worlds or even spectating the player and see what happens (if you don't know yet).

And it's not a stock, it's a function.
Reply


Messages In This Thread
How can I see if target is in range? - by Zloto - 02.05.2015, 18:10
Re: How can I see if target is in range? - by SickAttack - 02.05.2015, 18:11
Re: How can I see if target is in range? - by IzadorO - 02.05.2015, 18:14
Re: How can I see if target is in range? - by SickAttack - 02.05.2015, 18:16

Forum Jump:


Users browsing this thread: 2 Guest(s)