interior problem
#1

So, I've created interior system with stock but I have a problem with /enter and /exit.
When I /enter in one interior and I do /exit, it'll teleport me infront of another interior..

This is enter:
pawn Код:
CMD:enter(playerid,params[])
{
    for(new x=0; x < MAX_INTS; x++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[x][EnterPos][0], InterInfo[x][EnterPos][1], InterInfo[x][EnterPos][2]))
        {
            SendClientMessage(playerid, BLUE, "You have entered the interior successfully. /exit to leave it.");
            SetPlayerInterior(playerid, InterInfo[x][Interiorid]);
            SetPlayerPos(playerid, InterInfo[x][IntPos][0], InterInfo[x][IntPos][1], InterInfo[x][IntPos][2]);
        }
    }
    return 1;
}
And this is exit:
pawn Код:
CMD:exit(playerid,params[])
{
    for(new x=0; x < MAX_INTS; x++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[x][IntPos][0], InterInfo[x][IntPos][1], InterInfo[x][IntPos][2]))
        {
            SendClientMessage(playerid, BLUE, "You have left the interior successfully. /enter to enter it.");
            SetPlayerPos(playerid, InterInfo[x][EnterPos][0], InterInfo[x][EnterPos][1], InterInfo[x][EnterPos][2]);
            SetPlayerInterior(playerid, 0);
        }
    }
    return 1;
}
Any solution?
Reply
#2

Well, I added new variable in enum of PlayerInfo - inter, so I've changed the command to:

pawn Код:
CMD:exit(playerid,params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[PlayerInfo[playerid][Inter]][IntPos][0], InterInfo[PlayerInfo[playerid][Inter]][IntPos][1], InterInfo[PlayerInfo[playerid][Inter]][IntPos][2]))
    {
        SendClientMessage(playerid, BLUE, "You have left the interior successfully. /enter to enter it.");
        SetPlayerPos(playerid, InterInfo[PlayerInfo[playerid][Inter]][EnterPos][0], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][1], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][2]);
        SetPlayerInterior(playerid, 0);
    }
    return 1;
}
It's working now.

Though, you can still say if I could change something in better way..
Reply
#3

I'm sorry for triple posting, you can reduce my posts, I've faced another problem now;
When I use /enter and try to do /exit it says ''SERVER: Unknown command", any solution?

pawn Код:
CMD:enter(playerid,params[])
{
    for(new x=0; x < MAX_INTS; x++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[x][EnterPos][0], InterInfo[x][EnterPos][1], InterInfo[x][EnterPos][2]))
        {
            SendClientMessage(playerid, BLUE, "You have entered the interior successfully. /exit to leave it.");
            PlayerInfo[playerid][Inter] = x;
            SetPlayerInterior(playerid, InterInfo[x][Interiorid]);
            SetPlayerPos(playerid, InterInfo[x][IntPos][0], InterInfo[x][IntPos][1], InterInfo[x][IntPos][2]);
        }
    }
    return 1;
}
pawn Код:
CMD:exit(playerid,params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[PlayerInfo[playerid][Inter]][IntPos][0], InterInfo[PlayerInfo[playerid][Inter]][IntPos][1], InterInfo[PlayerInfo[playerid][Inter]][IntPos][2]))
    {
        SendClientMessage(playerid, BLUE, "You have left the interior successfully. /enter to enter it.");
        PlayerInfo[playerid][Inter] = -1;
        SetPlayerPos(playerid, InterInfo[PlayerInfo[playerid][Inter]][EnterPos][0], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][1], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][2]);
        SetPlayerInterior(playerid, 0);
    }
    return 1;
}
Reply
#4

so weird i can't find any problem !!
Reply
#5

Quote:
Originally Posted by LocMax
Посмотреть сообщение
I'm sorry for triple posting, you can reduce my posts, I've faced another problem now;
When I use /enter and try to do /exit it says ''SERVER: Unknown command", any solution?
Apparently it is not loading the player to be close enough to the coordinates.

The range you have selected is 3.0, I suggest changing it to something like 15.0 just to test, and then modify it as necessary
Reply
#6

I don't know if it was the cause, I changed position of

PlayerInfo[playerid][Inter] = -1;

Before:
pawn Код:
CMD:exit(playerid,params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[PlayerInfo[playerid][Inter]][IntPos][0], InterInfo[PlayerInfo[playerid][Inter]][IntPos][1], InterInfo[PlayerInfo[playerid][Inter]][IntPos][2]))
    {
        SendClientMessage(playerid, BLUE, "You have left the interior successfully. /enter to enter it.");
        PlayerInfo[playerid][Inter] = -1;
        SetPlayerPos(playerid, InterInfo[PlayerInfo[playerid][Inter]][EnterPos][0], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][1], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][2]);
        SetPlayerInterior(playerid, 0);
    }
    else SendClientMessage(playerid, RED, "You are not near to an interior exit.");
    return 1;
}
After:
pawn Код:
CMD:exit(playerid,params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, InterInfo[PlayerInfo[playerid][Inter]][IntPos][0], InterInfo[PlayerInfo[playerid][Inter]][IntPos][1], InterInfo[PlayerInfo[playerid][Inter]][IntPos][2]))
    {
        SendClientMessage(playerid, BLUE, "You have left the interior successfully. /enter to enter it.");
        SetPlayerPos(playerid, InterInfo[PlayerInfo[playerid][Inter]][EnterPos][0], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][1], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][2]);
        SetPlayerInterior(playerid, 0);
        PlayerInfo[playerid][Inter] = -1;
    }
    else SendClientMessage(playerid, RED, "You are not near to an interior exit.");
    return 1;
}
Reply
#7

So is it working?
Reply
#8

on player exit try to set SetPlayerInterrior before SetPlayerPos !
Reply
#9

If you wan't to take the "has to be near the exit" to exit part, just remove the if statement and the else statement as well:

pawn Код:
CMD:exit(playerid,params[])
{
        SendClientMessage(playerid, BLUE, "You have left the interior successfully. /enter to enter it.");
        SetPlayerPos(playerid, InterInfo[PlayerInfo[playerid][Inter]][EnterPos][0], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][1], InterInfo[PlayerInfo[playerid][Inter]][EnterPos][2]);
        SetPlayerInterior(playerid, 0);
        PlayerInfo[playerid][Inter] = -1;
    return 1;
}
Note: indent the code provided so that it doesn't show a warning
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)