how a point can be in a 2D zone - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how a point can be in a 2D zone (
/showthread.php?tid=665552)
how a point can be in a 2D zone -
Benzi - 08.04.2019
Hi, I want to create a point. Players can use command plantseed it inside point , but I want to be a point square
For example I would plant in this area
https://imgur.com/VmnFuop
Code:
CMD:plantseed(playerid,params[])
{
if(pinfo[playerid][seeds] < 1) return SendClientMessage(playerid,-1,"[SERVER] You haven't enought seeds");
if(IsPlayerInVehicle(playerid,GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,-1,"[SERVER] You can't do it in a vehicle");
new id = plantcount
CreateObject(2247, winfo[id][poswx], winfo[id][poswy], winfo[id][poswz]-1,-1,-1,-1,100.0);
pinfo[playerid][seeds] = pinfo[playerid][seeds] - 1;
Re: how a point can be in a 2D zone -
raydx - 08.04.2019
Streamer areas.
https://github.com/samp-incognito/sa...Natives-(Areas)
Re: how a point can be in a 2D zone -
Benzi - 08.04.2019
Quote:
Originally Posted by raydx
|
Can you show the code please
Re: how a point can be in a 2D zone -
Crayder - 08.04.2019
Quote:
Originally Posted by Benzi
Can you show the code please
|
No, this isn't a place where you come and just get someone to code for you. It's a learning zone. xD
But, if you are using streamer streamer areas are definitely the way to go. Go to the link raydx sent to you. The code reference is there.
CreateDynamicRectangle to create your square area, you'll need the min and max X as well as the min/max Y.
Then you simply just use IsPlayerInDynamicArea(playerid, areaid).
Re: how a point can be in a 2D zone -
Benzi - 09.04.2019
Quote:
Originally Posted by Crayder
No, this isn't a place where you come and just get someone to code for you. It's a learning zone. xD
But, if you are using streamer streamer areas are definitely the way to go. Go to the link raydx sent to you. The code reference is there.
CreateDynamicRectangle to create your square area, you'll need the min and max X as well as the min/max Y.
Then you simply just use IsPlayerInDynamicArea(playerid, areaid).
|
Code:
CreateDynamicRectangle(Float:minx, Float:miny, Float:maxx, Float:maxy, worldid = -1, interiorid = -1, playerid = -1)
Re: how a point can be in a 2D zone -
CONTROLA - 09.04.2019
If you don't want to use the streamer, you could simply do a check on the player's X and Y:
pawn Code:
new Float:X, Float:Y, Float:Z;
GetPlayerPosition(playerid, X, Y, Z);
if(X >= minx && X <= maxx && Y >= miny && Y <=maxy)
{ // do something
}