You can't create a GangZone using only X, Y, Z.I did a little script to give you an idea of how to do it.
I'm sorry if there are a few mistakes, kinda wrote it in a hurry.
PHP код:
#define MAX_LANDS 100 //Maximum number of lands
#define INVALID_LAND_ID -1
new playerLand[MAX_PLAYERS]; //Stores the land id of the player
enum lInfo
{
Float:lID, //Used to store the result of GangZoneCreate
Float:lMinX, //Needed for gangZone
Float:lMinY, //Needed for gangZone
Float:lMaxX, //Needed for gangZone
Float:lMaxY, //Needed for gangZone
lOwner[MAX_PLAYER_NAME], //Owner's name
lOwned, //Set it to 0 it none owns it, or 1 if someone does
lCreated //Set it to 1 if the land exists, or 0 if it doesn't
};
new landInfo[MAX_LANDS][sizeof(lInfo)];
public OnPlayerConnect(playerid)
{
playerLand[playerid] = INVALID_LAND_ID;
return 1;
}
stock getFreeLandID()
{
for(int i = 0; i < MAX_LANDS; i++)
if(!landInfo[i][lCreated])
return i;
return INVALID_LAND_ID;
}
/*
You will need minX, minY, maxX, maxY coords to create a gangzone.A gangzone doesn't care about Z.
*/
stock createLand(playerid, Float:minX, Float:minY, Float:maxX, Float:maxY) //Function used by admins to create the land
{
new landID = getFeeLandID(); //Store a free land ID
if(landID != INVALID_LAND_ID)
{
landInfo[landID][lMinX] = minX;
landInfo[landID][lMinY] = minY;
landInfo[landID][lMaxX] = maxX;
landInfo[landID][lMaxY] = maxY;
strcpy(landInfo[landID][lOwner], "No-one");
landInfo[landID][lOwned] = 0;
landInfo[landID][lCreated] = 1;
landInfo[landID][lID] = GangZoneCreate(minX, minY, maxX, maxY); //Same as: GangZoneCreate(landInfo[landID][lMinX], landInfo[landID][lMinY], landInfo[landID][lMaxX] = maxX, landInfo[landID][lMaxY] = maxY);
GangZoneShowForAll(landInfo[landID][lID], 0xFFFFFF93); //0xFFFFFF93 can be replaced with any color.
//Send message that a land has been created
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "All the land zones are used.");
}
//returns the landID a specific player is inside of or INALID_LAND_ID if the player isn't inside any land
stock getPlayerLandID(playerid)
{
for(int i = 0; i < MAX_LANDS; i++)
if(landInfo[i][lCreated])
if(IsPlayerInArea(playerid, landInfo[i][lMinX], landInfo[i][lMinY], landInfo[i][lMaxX], landInfo[i][lMaxY]))
return i;
return INVALID_LAND_ID;
}
stock isPlayerInOwnLand(playerid)
{
if(playerLand[playerid] != INVALID_LAND_ID) //Checks if the player owns any land
{
new landID = playerLand[playerid]; //Store the land ID
if(landInfo[landID][lCreated]) //Checks to see if the land exists
if(IsPlayerInArea(playerid, landInfo[landID][lMinX], landInfo[landID][lMinY], landInfo[landID][lMaxX], landInfo[landID][lMaxY])) //Check to see if player is in his own land
return 1;
}
return 0;
}
stock onLandBought(playerid, landID)
{
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, sizeof(playerName));
//
playerLand[playerid] = landID;
//Update the land info
landInfo[landID][lOwned] = 1;
strcpy(landInfo[landID][lOwner], playerName);
}
CMD:buyland(playerid, params[])
{
new landID = getPlayerLandID(playerid);
if(landID != INVALID_LAND_ID)
{
//Your code
onLandBought(playerid, landID);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "Message to let him know he's not in any zone.");
return 1;
}
//Cmd for admins
CMD:createland(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new Float:minX, Float:minY, Float:maxX, Float:maxY;
if(sscanf(params, "ffff", minX, minY, maxX, maxY))
return SCM(playerid, 0xFFFFFFFF, "/createland [minX] [minY] [maxX] [maxY]");
createLand(playerid, minX, minY, maxX, maxY;
return 1;
}
return 0;
}
//Useful functions
stock strcpy(dest[], const source[], maxlength=sizeof dest)
{
strcat((dest[0] = EOS, dest), source, maxlength);
}
/*
We'll use this function to see if playerid is inside a land
*/
public IsPlayerInArea(playerid, Float:minx2, Float:miny2, Float:maxx2, Float:maxy2)
{
new Float:xa, Float:ya, Float:za;
GetPlayerPos(playerid, xa, ya, za);
if (xa > minx2 && xa < maxx2 && ya > miny2 && ya < maxy2) return 1;
return 0;
}