Command works on one place...
#1

Well I post a thread about that about 20 minutes ago but a can't understand anything from https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint

I need when player is in this garage

and write /tune opens tuning menu. I only want to know how to make the command /tune to work only in this garage...
Reply
#2

pawn Код:
CMD:tune(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 8.0, posx, posy, posz))
    {
        //Rest of code
        return 1;
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a garage!");
}
Untested, of course. Simply go into the garage, /save the position or what-not, and take the coords from the saved-positions.txt file and put them where the pox, posy, and posz is in the IsPlayerInRangeOfPoint.

Hope I explained it well enough
Reply
#3

Код:
if(PlayerToPoint(range, playerid, x y z)//add coordinates here
{
//codes from your command
else
{
SendClientMessage(playerid, Color, "Wrong Place");
}
or
Код:
if(PlayerInfo[playerid][pInt] == ID)//change pInt with your function from interiors. and id with interior id
{
//codes from your command
else
{
SendClientMessage(playerid, Color, "Wrong Place");
}
Reply
#4

IsPlayerInRangeOfPoint is not that difficult to understand.


Let's say you have your garage command.

You would get the coordinates of the garage, and use IsPlayerInRangeOfPoint
to see if the player is close to the garage by using a line like this.

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, 567, 600, 700))
Okay, now you see some numbers separated by commas. The first word is playerid.
That's the playerid of whoever typed this command.

The second number is the radius, in this case it's 3. So that means the player has to be
within 3 GTA units from the point.

Now the last three numbers are the x,y,z coordinates of where the player needs to be.

Example

pawn Код:
CMD:enter(playerid,params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 2, 300, 400, 599)) // So this line checks if he is near the 'entrance'.
    {
        // So if he IS near the point, then it will run the code below.
        SetPlayerPos(playerid, 8, 9, 10);
        SendClientMessage(playerid, -1, "You have entered the building!");
        return 1;
    }
    else // If he isn't
    {
        SendClientMessage(playerid, -1, "You are not near the entrance.");
    }
    return 1;
}
Hope I helped, goodluck.
Reply
#5

Quote:
Originally Posted by Kindred
Посмотреть сообщение
pawn Код:
CMD:tune(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 8.0, posx, posy, posz))
    {
        //Rest of code
        return 1;
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a garage!");
}
Untested, of course. Simply go into the garage, /save the position or what-not, and take the coords from the saved-positions.txt file and put them where the pox, posy, and posz is in the IsPlayerInRangeOfPoint.

Hope I explained it well enough

Thank you man. This is exactly what I need
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)