Making other cases work
#1

Hi, i have a problem, which is only "RW's house" case is working perfectly, if you walk to the other houses position, it wont be recognized and it will say You are not in the house's door, so what is wrong here ?

pawn Код:
if (strcmp("/hlock", cmdtext, true, 10) == 0)
    {
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641)) // RW's house
    {
    SendClientMessage(playerid,RED,"You are not in the house's door!");
    return 1;
    }
    if(PlayerData[playerid][OWNER] != 1)
    {
    SendClientMessage(playerid,RED,"You don't own this house!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
    if(PlayerData[playerid][OWNER] == 1)
    {
    SendClientMessage(playerid,RED,"The house has been locked.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerData[i][HLock] = 1;
    }
    return 1;
    }
    else if(!IsPlayerInRangeOfPoint(playerid, 1.0, 1955.8412,-1115.7360,27.8305)) // Shot's house
    {
    SendClientMessage(playerid,RED,"You are not in the house's door!");
    return 1;
    }
    if(PlayerData[playerid][OWNER] != 2)
    {
    SendClientMessage(playerid,RED,"You don't own this house!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
    if(PlayerData[playerid][OWNER] == 2)
    {
    SendClientMessage(playerid,RED,"The house has been locked.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerData[i][HLock] = 2;
    }
    return 1;
    }
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2091.0439,-1278.5629,26.1797)) // Lake B's house
    {
    SendClientMessage(playerid,RED,"You are not in the house's door!");
    return 1;
    }
    if(PlayerData[playerid][OWNER] != 3)
    {
    SendClientMessage(playerid,RED,"You don't own this house!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
    if(PlayerData[playerid][OWNER] == 3)
    {
    SendClientMessage(playerid,RED,"The house has been locked.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerData[i][HLock] = 3;
    }
    return 1;
    }
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2153.9307,-1243.5135,25.3672)) // Jamsta's house
    {
    SendClientMessage(playerid,RED,"You are not in the house's door!");
    return 1;
    }
    if(PlayerData[playerid][OWNER] != 4)
    {
    SendClientMessage(playerid,RED,"You don't own this house!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
    if(PlayerData[playerid][OWNER] == 4)
    {
    SendClientMessage(playerid,RED,"The house has been locked.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerData[i][HLock] = 4;
    }
    return 1;
    }
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2133.4910,-1232.1007,24.1563)) // Lil Hustlah's house
    {
    SendClientMessage(playerid,RED,"You are not in the house's door!");
    return 1;
    }
    if(PlayerData[playerid][OWNER] != 5)
    {
    SendClientMessage(playerid,RED,"You don't own this house!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
    if(PlayerData[playerid][OWNER] == 5)
    {
    SendClientMessage(playerid,RED,"The house has been locked.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerData[i][HLock] = 5;
    }
    return 1;
    }
}
Reply
#2

pawn Код:
if(strcmp("/hlock", cmdtext, true, 10) == 0)
{
    if(PlayerData[playerid][OWNER] != 1)
    {
        SendClientMessage(playerid,RED,"You don't own this house!");
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
        if(PlayerData[playerid][OWNER] == 1)
        {
            SendClientMessage(playerid,RED,"The house has been locked.");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                PlayerData[i][HLock] = 1;
            }
            return 1;
        }
    }
    if(PlayerData[playerid][OWNER] != 2)
    {
        SendClientMessage(playerid,RED,"You don't own this house!");
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
        if(PlayerData[playerid][OWNER] == 2)
        {
            SendClientMessage(playerid,RED,"The house has been locked.");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                PlayerData[i][HLock] = 2;
            }
            return 1;
        }
    }
    if(PlayerData[playerid][OWNER] != 3)
    {
        SendClientMessage(playerid,RED,"You don't own this house!");
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
        if(PlayerData[playerid][OWNER] == 3)
        {
            SendClientMessage(playerid,RED,"The house has been locked.");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                PlayerData[i][HLock] = 3;
            }
            return 1;
        }
    }
    if(PlayerData[playerid][OWNER] != 4)
    {
        SendClientMessage(playerid,RED,"You don't own this house!");
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
        if(PlayerData[playerid][OWNER] == 4)
        {
            SendClientMessage(playerid,RED,"The house has been locked.");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                PlayerData[i][HLock] = 4;
            }
            return 1;
        }
    }
    if(PlayerData[playerid][OWNER] != 5)
    {
        SendClientMessage(playerid,RED,"You don't own this house!");
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641))
    {
        if(PlayerData[playerid][OWNER] == 5)
        {
            SendClientMessage(playerid,RED,"The house has been locked.");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                PlayerData[i][HLock] = 5;
            }
            return 1;
        }
    }
    return 1;
}
Se ajudei da reputation ae
Reply
#3

pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641)) // RW's house
That statement checks if IsPlayerInRangeOfPoint returns 0 (player isn't close to the house), which will always be true when the player isn't close to RW's house. Remove the exclamation point.
Reply
#4

but if i remove the exclamation point then person who is at that position will say

"You don't own this house"

and your version didnt work seu madruga
Reply
#5

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 1906.2339,-1113.1035,26.6641)) // RW's house
That statement checks if IsPlayerInRangeOfPoint returns 0 (player isn't close to the house), which will always be true when the player isn't close to RW's house. Remove the exclamation point.
That's how it should be. It's a check to see if they aren't in range.


This entire thing is wrong though
Reply
#6

wat you mean
Reply
#7

Quote:
Originally Posted by stix
Посмотреть сообщение
wat you mean
well, I don't know how you check if the house is locked when they try to enter but...Two houses wont be able to be locked at the same time


The other thing is, you should only have IsPlayerInRangeOfPoint checks in the start then add the other checks inside of each range check instead of other things outside. Like Vince said (though I did say what you did was correct because it would be in other cases)

You can only lock instead of being able to unlock (not really needed to make 2 commands for it)
Reply
#8

well i managed to fix it but thanks anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)