If player not in range, disable command
#1

Hello,
i'm trying to disable command to players, but it seems not working. I want to make, that if ONLY, the player is near the coordinates, can use the commands. The code seems good, but it's not working Any ideas, to get that to work?

Code:
if(playerDB[playerid][vip] == true)
{
   GetPlayerPos( playerid, Xaa, Yaa, Zaa );
   if(Xaa <= -2069 && Xaa >= -2064 && Yaa <= -262 && Yaa >= -268)
   {
       SendClientMessage(playerid, 0xFF9900FF, " You are to far away!");
       return 1;
    } else {
       if (!strcmp("/gates", cmdtext, true)) return MoveDynamicObject(zon1, -2067.7896, -265.9207, 36.4651, 5);
    }
}
Thanks.
Reply
#2

Have you tried this?

Code:
IsPlayerInRangeOfPoint (playerid, Float:range, Float:x, Float:y, Float:z);
Reply
#3

Yes, but I do not want to make a "circle" just for certain height. I do not want to use a Z coordinates. I want that for, only in area of X and Y coordinates, will be allowed the command.
Reply
#4

Somewhere inside the Gamemode:

Code:
IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
	new Float:X, Float:Y, Float:Z;

	GetPlayerPos(playerid, X, Y, Z);
	if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) {
		return 1;
	}
	return 0;
}
Your Command:
Code:
if(strcmp("/code",cmdtext, true))
{

    if(IsPlayerInArea(playerid,LowCornerX,LowCornerY, HighCornerX,HighCornerY)) 
    {
        //If the player is in the area let him do the code stuff
    } else {
        //You're too far away
    }
    return 1;
}
I highly recommend the using of ZCMD since it's way more efficient than strcmp: https://sampforum.blast.hk/showthread.php?tid=91354

You can obviously add before IsPlayerInArea the check if the player is a VIP or not and the other stuff.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)