/enter command not checking positions.
#7

Quote:
Originally Posted by milanosie
View Post
Explain that please.
Look:
pawn Code:
CMD:enter(playerid, params[])
{
    for(new i = 0; i < sizeof(HouseInfo); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[i][X], HouseInfo[i][Y], HouseInfo[i][Z]))
        {
            if(HouseInfo[i][Lock] == 0)
            {
                SetPlayerPos(playerid, HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ]);
                SetPlayerInterior(playerid, HouseInfo[i][Int]);
                SetPlayerVirtualWorld(playerid, HouseInfo[i][Vw]);
                return 1;
            }
            else return SendClientMessage(playerid, 0xFFFFFFFF, "This house is locked.");
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
    }
    return 1;
}
That's the original code. Now I will make it different so that you might understand it.
pawn Code:
CMD:enter(playerid, params[]) //The command is performed
{
    for(new i = 0; i < sizeof(HouseInfo); i++) //Loop through the variable HouseInfo (=300)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[i][X], HouseInfo[i][Y], HouseInfo[i][Z])) //Is the player in the X+Y+Z? (Range 10 - Way too big)
        {
            if(HouseInfo[i][Lock] == 0) //When the variable 'Lock' is 0 (unlocked)
            {
                SetPlayerPos(playerid, HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ]);
                SetPlayerInterior(playerid, HouseInfo[i][Int]);
                SetPlayerVirtualWorld(playerid, HouseInfo[i][Vw]); //Set pos etc
                return 1;
            }
            else //When the house is locked
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "This house is locked.");
                return 1; //The return! Does the same as 'return SendClientMessage...' in the previous command. Loop stopped
            }
        }
        else //When the player ain't near a house
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
            return 1; //Again...
        }
    }
    return 1;
}
This code is exactly doing the same. In fact, this is what the code Ricardo provided actually does.
Reply


Messages In This Thread
/enter command not checking positions. - by ricardo178 - 18.02.2012, 22:03
Re: /enter command not checking positions. - by milanosie - 18.02.2012, 22:10
Re : /enter command not checking positions. - by ricardo178 - 18.02.2012, 22:11
Re: /enter command not checking positions. - by Vince - 18.02.2012, 22:22
Re: /enter command not checking positions. - by IceCube! - 18.02.2012, 22:24
Re: /enter command not checking positions. - by milanosie - 18.02.2012, 22:27
Re: /enter command not checking positions. - by Kwarde - 18.02.2012, 22:34
Re: /enter command not checking positions. - by Vince - 18.02.2012, 22:38
Re: /enter command not checking positions. - by milanosie - 18.02.2012, 22:39
Re: /enter command not checking positions. - by milanosie - 18.02.2012, 22:41

Forum Jump:


Users browsing this thread: 2 Guest(s)