Help with Check if player is in gangzone -
LeXuZ - 12.11.2014
Hello, okay, I have been working on a gang system, and have got a gangzone working, as well as a gang turf attack command, but the problem is i haven't got a check if player is in a gangzone, and i don't really know how to check something like that, So when i do /attack it will make the gangzone flash and it checks if player is on the gangzone, and if not sends a message like "You're not on a gang turf", but if he is on a gangzone, then it will attack with the flashing turf, If you can help me i will be grateful.
Код:
public OnFilterScriptInit()
{
GangZone = GangZoneCreate(1855.5659, -1254.5380, 2067.8911, -1178.7740);
return 1;
}
Код:
CMD:attack(playerid, params[])
{
GangZoneFlashForAll(GangZone, blue);
return 1;
}
Thank you
Re: Help with Check if player is in gangzone -
HY - 12.11.2014
Check if player it's in your GangZone.
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, RANGE, X,Y,Z))
pawn Код:
CMD:attack(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, RANGE, X,Y,Z))
{
GangZoneFlashForAll(GangZone, blue);
}
else
{
SendClientMessage(playerid, -1, ''You aren't in GangZone'');
}
return 1;
}
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Re: Help with Check if player is in gangzone -
LeXuZ - 12.11.2014
Ah, thank you, but how is the easiest way of checking what the range of the positions are?
Re: Help with Check if player is in gangzone -
HY - 12.11.2014
Range = distance;
E.G:
pawn Код:
CMD:movegate(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, X, Y, Z))
{
MoveObject(971, // ( ..... );
}
else
{
SendClientMessage(playerid, -1, ''You aren't next to gate !'');
}
return 1;
}
If he isn't at a bigger distance than 5.0 (range), he can't use command.
Re: Help with Check if player is in gangzone -
DavidBilla - 12.11.2014
Substitute (min x + max x)/2 for x value in IsPlayerInRangeOfPoint, and similarly for y (min y + max y)/2
Re: Help with Check if player is in gangzone -
M4D - 12.11.2014
also you can use this function:
pawn Код:
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
if(Pos[0] > minx && Pos[0] < maxx && Pos[1] > miny && Pos[1] < maxy) return 1;
else return 0;
}