A weird bug in my house system:(
#1

So, I have a bug.
my /lock and /enterhouse are almost exactly the same, but.. /lock works.
/enterhouse gives me the error "You are not near an unlocked house!"

The code for my /enterhouse is:

pawn Код:
CMD:enterhouse(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayerInfo[playerid][Banned] != 9999)
    {
        for(new h = 0; h < sizeof(House); h++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 10, House[h][henx], House[h][heny], House[h][henz]) && House[h][hlocked] == 0)
            {
                if(IsInHouse[playerid] == 0)
                {
                    GetPlayerPos(playerid, PP, PP2, PP3);
                    SetPlayerPos(playerid, House[h][hexx], House[h][hexy], House[h][hexz]);
                    SetPlayerInterior(playerid, House[h][hint]);
                    SetPlayerVirtualWorld(playerid, House[h][hvw]);
                    IsInHouse[playerid] = 1;
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You are already in a house!");
            }
            else return SendClientMessage(playerid, COLOR_GREY, "You are not near any unlocked houses!");
        }
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_GREY, "You are not banned:D");
}
while my code for /lock:

pawn Код:
CMD:lockhouse(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayerInfo[playerid][Banned] != 9999)
    {
        for(new h = 0; h < sizeof(House); h++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 10, House[h][henx], House[h][heny], House[h][henz]) && PlayerInfo[playerid][Housekey] == h)
            {
                if(House[h][hlocked] == 0)
                {
                    House[h][hlocked] = 1;
                    GameTextForPlayer(playerid, "House Locked!!", 4000, 5);
                }
                else
                {
                    House[h][hlocked] = 0;
                    GameTextForPlayer(playerid, "House UnLocked!!", 4000, 5);
                }
            }
        }
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_GREY, "You are not banned:D");
}
(ps: The You are not banned thing is just cause I left space to make it a different if(blablabla)

anyone sees the problem?
Reply
#2

Not sure, but try:

pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 10, House[h][henx], House[h][heny], House[h][henz]) && House[h][hlocked] == 0)
Reply
#3

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
Not sure, but try:

pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 10, House[h][henx], House[h][heny], House[h][henz]) && House[h][hlocked] == 0)
No?
That makes it enter every house its not close to
Reply
#4

pawn Код:
CMD:enterhouse(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayerInfo[playerid][Banned] == 9999)
        SendClientMessage(playerid, COLOR_GREY, "You are not banned:D");
    if(IsInHouse[playerid] != 0) return SendClientMessage(playerid, COLOR_GREY, "You are already in a house!");
    for(new h = 0; h < sizeof(House); h++)
    {
        if(!IsPlayerInRangeOfPoint(playerid, 10, House[h][henx], House[h][heny], House[h][henz])) continue;
        GetPlayerPos(playerid, PP, PP2, PP3);
        SetPlayerPos(playerid, House[h][hexx], House[h][hexy], House[h][hexz]);
        SetPlayerInterior(playerid, House[h][hint]);
        SetPlayerVirtualWorld(playerid, House[h][hvw]);
        IsInHouse[playerid] = 1;
        break;
    }
    SendClientMessage(playerid, COLOR_GREY, "You are not near any unlocked houses!");
    return 1;
}
Reply
#5

thanks will test it
Reply
#6

does not work
Reply
#7

Bump
Reply
#8

How do i make it then that it will still return an error message but without using else?
Never did it any other way
Reply
#9

fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)