Flying object
#1

Hi guys.
1. I add grassplant (marihuana) as object use this:
pawn Код:
CreateObject(3409, 2461.7163, -1714.4058 ,13.5238, 0.00000000,0.00000000,91.49511719);
and my object is flying.
Question, why?

2. How to spawn this object opposite the player, only if player stay on the green grass (ID: 289?
Reply
#2

1. Well the reason because it's flying is: It is too high. Decrease the Z Position ( 13.5238 ) to lower it.

2. What do you mean with this exactly?
Reply
#3

1. Yep, that's was the reason. Thank you!
2. I mean that i need function to spawnly object only on the grass.
When i stay on the grass and i type example: /spawnbush then bush will spawn.
But if i not on the grass, then shows message: "You must stay on the grass to spawn bush".
I hope now you understand
Reply
#4

Use a simple area detection for this.

Method A:

Is the area where you can spawn a bush a rectangle?

If yes, simply save the coordinates of the upper right and lower left corner with /save.

Here is the function for the area detection:

Код:
stock IsPlayerInRectangle(playerid, Float:llX, Float:llY, Float:urX, Float:urY) // aka IsPlayerInZone
{
new Float:pPos[3];
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);

if(pPos[0] > urX) return 0;
if(pPos[0] < llX) return 0;
if(pPos[1] > urY) return 0;
if(pPos[1] < llY) return 0;

return 1;
}
llX is the Lower Left X Coord,
llY is the Lower Left Y Coord,
urX is the Upper Right X Coord, and
urY is the Upper Right Y Coord.

Fill in the coordinates from above and use it in an if statement. If the condition is true, the player can spawn a bush.

Method B:

Get the center of the area and radius and use the function IsPlayerInRangeOfPoint(..). This is much more simple but not that exact.
I recommend using Method A.


Or... simply use Incognito's Streamer area functions with CreateDynamicRectangle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)