22.07.2013, 22:47
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:
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
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; }
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