Disable commands in an area
#1

How to disable commands exept teleports in areas you choose?
it's in pawn, and for a derby map...
Reply
#2

Depends what kind of area you think of. If you're talking about a sphere, use IsPlayerInRangeOfPoint in the same if-condition, where the strcmp is located, or just right before.
If you're talking about a square, use this IsPlayerInArea(playerid,maxX, maxY, minX, minY)
pawn Code:
IsPlayerInArea(playerid,Float:maxX, Float:maxY, Float:minX, Float:minY)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPosition(playerid, X, Y, Z);
if(X>=minX&&X<=maxX&&Y>=minY&&Y<=maxY)return 1;
else return 0;
}
I don't give guarantee about this code, cuz i just scripted this here right now.
Reply
#3

and btw DeathOnaStick this thing isn't easy , u mean that the float:X and Y and Z is the co-ordinates
cuz it will be much harded to did it , like 50 co-ordinates for 1 area , i don't get it , plz answer me fast
Reply
#4

I made a map for a good derby the map is at the bikeschool, but the server also has a /fix command , for cars, how can I make the derby map a real derby ? whitout fixing cars?
Reply
#5

Do I have to set virtual world at teleport spawn in pawno?
Reply
#6

yea , its soooooo important
Reply
#7

Ok what settings should I set for that virtual world?
Reply
#8

You don't need a virtual world, except you want to seperate the teleported player from the others.

Quote:
Originally Posted by MBX97
View Post
and btw DeathOnaStick this thing isn't easy , u mean that the float:X and Y and Z is the co-ordinates
cuz it will be much harded to did it , like 50 co-ordinates for 1 area , i don't get it , plz answer me fast
If you want to check for an square-like area, you just need 4 coordinates, which are the corners (maxX, maxY, minX, minY). I don't understand the problem.
Reply
#9

I just don't know how to make it....
I want a square where you can't use /fix command...
Reply
#10

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/fix", true) == 0)
    {
        if(IsPlayerInArea(playerid, 1000.0000, -1000.0000, 1000.0000, -1000.0000)) return SendClientMessage(playerid, 0xFFFFFFFF, "You can't use this command in this area!");
        RepairVehicle(GetPlayerVehicleID(playerid));
        return 1;
    }
    return 0;
}

stock IsPlayerInArea(playerid, Float:xmax, Float:xmin, Float:ymax, Float:ymin)
{
    new
        Float:x,
        Float:y,
        Float:z;
   
    GetPlayerPos(playerid, x, y, z);
    if((x < xmax) && (x > xmin) && (y > ymax) && (y < ymin)) return 1;
    return 0;
}
Remember changing the 1000.0000s and -1000.0000s for your coordinates.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)