my /enter system only works for house 1
#1

Hey, I made a house system, every time a house is placed, it is assigned a unique ID (HouseID) and my /enter command is failing since I can only enter the house of HouseId 1.

The house id is also the virtual world it sets them to.

pawn Код:
if(strcmp(cmd, "/enter", true) == 0)
    {
        for(new i = 0; i < houses; i++)
        {
                if(PlayerToPoint(2.0, playerid,HouseInfo[i][hHousex], HouseInfo[i][hHousey], HouseInfo[i][hHousez]))
                {
                        SetPlayerInt(playerid,HouseInfo[i][hHouseInterior]);
                        SetPlayerVirtualWorld(playerid, HouseInfo[i][hHouseId]);
                        PlayerInfo[playerid][pInside] = 1;
                        GetPlayerPos(playerid, x, y, z);
                        PlayerInfo[playerid][pExitx] = x;
                    PlayerInfo[playerid][pExity] = y;
                        PlayerInfo[playerid][pExitz] = z;
                        return 1;
                    }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near an entrace");
                    return 1;
                    }
                }
            }
the variable "houses" is read from a file.
Reply
#2

remove the 2 "return 1;"
Reply
#3

pawn Код:
if(strcmp(cmd, "/enter", true) == 0)
    {
        for(new i = 0; i < houses; i++)
        {
                if(PlayerToPoint(2.0, playerid,HouseInfo[i][hHousex], HouseInfo[i][hHousey], HouseInfo[i][hHousez]))
                {
                        SetPlayerInt(playerid,HouseInfo[i][hHouseInterior]);
                        SetPlayerVirtualWorld(playerid, HouseInfo[i][hHouseId]);
                        PlayerInfo[playerid][pInside] = 1;
                        GetPlayerPos(playerid, x, y, z);
                        PlayerInfo[playerid][pExitx] = x;
                    PlayerInfo[playerid][pExity] = y;
                        PlayerInfo[playerid][pExitz] = z;
                        return 1;
                    }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near an entrace");
                    }
                }
            }
Works like a broken charm, I can now enter and exit all houses, but even when I do it gives me this "SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near an entrace");"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)