how a point can be in a 2D zone
#1

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;
Reply
#2

Streamer areas.

https://github.com/samp-incognito/sa...Natives-(Areas)
Reply
#3

Quote:
Originally Posted by raydx
View Post
Can you show the code please
Reply
#4

Quote:
Originally Posted by Benzi
View Post
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).
Reply
#5

Quote:
Originally Posted by Crayder
View Post
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)
Reply
#6

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
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)