Player in range?
#1

Let's say i type /lol to place an object anywhere in san andreas and to destroy the object i have to be close to it, how do i do?

I think i'll have to use IsPlayerInRangeOfPoint, but i don't know how that will work with GetPlayerPos..
So, i need some help.
Reply
#2

Use GetPlayerPos, without IsPlayerInRangeOfPoint.
Reply
#3

Quote:
Originally Posted by =WoR=G4M3Ov3r
Посмотреть сообщение
Use GetPlayerPos, without IsPlayerInRangeOfPoint.
Oh, i see what you mean, but how?

Код:
CMD:takeweed(playerid, params[])
{
		if (FakeWeed[playerid] == 1)
	{
		SendClientMessage(playerid,COLOR_GREEN, "You've taken some weed!");
		FakeWeed[playerid] = 0;
		Weed[playerid] += 5;
		new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerFacingAngle(playerid, a);
	    GetPlayerPos(playerid, x, y, z);
	}
		else
	{
	    SendClientMessage(playerid,COLOR_RED, "[ERROR:] You don't have any weed to take!");
	 }
  		return 1;
}
Reply
#4

Quote:
Originally Posted by Chrillzen
Посмотреть сообщение
Oh, i see what you mean, but how?

Код:
CMD:takeweed(playerid, params[])
{
		if (FakeWeed[playerid] == 1)
	{
		SendClientMessage(playerid,COLOR_GREEN, "You've taken some weed!");
		FakeWeed[playerid] = 0;
		Weed[playerid] += 5;
		new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerFacingAngle(playerid, a);
	    GetPlayerPos(playerid, x, y, z);
	}
		else
	{
	    SendClientMessage(playerid,COLOR_RED, "[ERROR:] You don't have any weed to take!");
	 }
  		return 1;
}
Yep, nothing wrong with that.
Reply
#5

Quote:
Originally Posted by =WoR=G4M3Ov3r
Посмотреть сообщение
Yep, nothing wrong with that.
I don't know how to make it read if it IS there..
Reply
#6

Quote:
Originally Posted by Chrillzen
Посмотреть сообщение
I don't know how to make it read if it IS there..
Just leave it as it is, and test it... It should work fine.
Reply
#7

I think that's quite impossible.
Reply
#8

Quote:
Originally Posted by Chrillzen
Посмотреть сообщение
I think that's quite impossible.
Its not, you can use PlayerToPoint, and IsPlayerInRangeOfPoint, I misunderstood you, and said to use GetPlayerPos, when it should've been IsPlayerInRangeOfPoint.

What are your Floats X, Y, and Z, weed enums ?
Reply
#9

Something like this:
pawn Код:
new
        Float: iPos[3];

    GetPlayerPos(playerid, iPos[0], iPos[1], iPos[2]);

    foreach(Player, i)
    {
        if(IsPlayerInRangeOfPoint(i, iPos[0], iPos[1], iPos[2], 25.0) // You might want to use a smaller range if you want the players to be real close
        {
            // Player is near
            // i is near the playerid
        }
    }
?
Reply
#10

To make it more clear..

This is where the object will be, aka X, Y, Z.

Код:
CMD:plantseed(playerid, params[])
{
  		if (Seeds[playerid] == 1)
 {
		SendClientMessage(playerid,COLOR_GREEN, "You've planted one seed!");
		SetTimerEx("Growingtime",9000,0,"i",playerid);
		Seeds[playerid] = 0;
  		new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerFacingAngle(playerid, a);
	    GetPlayerPos(playerid, x, y, z);
	    Seeds[playerid] = CreateObject(3409, x, y, z-1, 0.0, 0.0, a + 90);
	}
		else
	{
	    SendClientMessage(playerid,COLOR_RED, "[ERROR:] You don't have any seeds!");
 	}
  		return 1;
}
This is the code where you have to be close to the planted weed.

Код:
CMD:plantseed(playerid, params[])
{
  		if (Seeds[playerid] == 1)
 {
		SendClientMessage(playerid,COLOR_GREEN, "You've planted one seed!");
		SetTimerEx("Growingtime",9000,0,"i",playerid);
		Seeds[playerid] = 0;
  		new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerFacingAngle(playerid, a);
	    GetPlayerPos(playerid, x, y, z);
	    Seeds[playerid] = CreateObject(3409, x, y, z-1, 0.0, 0.0, a + 90);
	}
		else
	{
	    SendClientMessage(playerid,COLOR_RED, "[ERROR:] You don't have any seeds!");
 	}
  		return 1;
}

CMD:takeweed(playerid, params[])
{
        new Float:x, Float:y, Float:z, Float:a;
		if (FakeWeed[playerid] == 1)
	{
		SendClientMessage(playerid,COLOR_GREEN, "You've taken some weed!");
		FakeWeed[playerid] = 0;
		Weed[playerid] += 5;
	    GetPlayerFacingAngle(playerid, a);
	    GetPlayerPos(playerid, x, y, z);
	}
		else
	{
	    SendClientMessage(playerid,COLOR_RED, "[ERROR:] You don't have any weed to take!");
	 }
  		return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)