Trouble with a simple command!
#5

I think that will work..
pawn Код:
CMD:lockhouse(playerid, params[])
{
    new id = IsPlayerNearHouseEnt(playerid);
    new id2 = IsPlayerInsideHouse(playerid);

    if(!GetPlayerInterior(playerid)) // He is outside any house ( interior = 0)
    {
        if(id != PlayerInfo[playerid][HouseID]) return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not own this house.");
    }
    else // He isn't outside
    {
        if(id2 != PlayerInfo[playerid][HouseID])) return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not own this house.");
    }
    if(HouseInfo[id][hLocked] == 1)
    {
        HouseInfo[id][hLocked] = 0;
        GameTextForPlayer(playerid, "~w~house ~g~ UNLOCKED", 3000, 6);
        PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);

        new file4[40];
        format(file4, sizeof(file4), HPATH, id);
        new INI:File = INI_Open(file4);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"hLocked", HouseInfo[id][hLocked]);
        INI_Close(File);
    }
    else
    {
        HouseInfo[id][hLocked] = 1;
        GameTextForPlayer(playerid, "~w~house ~r~ LOCKED", 3000, 6);
        PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);

        new file4[40];
        format(file4, sizeof(file4), HPATH, id);
        new INI:File = INI_Open(file4);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"hLocked", HouseInfo[id][hLocked]);
        INI_Close(File);
    }
    return 1;
}
I just check where the player is before checking if he's the owner, If he is outside, Then I don't have to check if he's inside his house(Because he isn't inside any house).. Outside interior is always 0, So I just depend on that and check is he outside or inside any interior before checking if he's the owner

Note: I think you should add that check to your function as well.
Reply


Messages In This Thread
Trouble with a simple command! - by Chrillzen - 27.11.2013, 23:09
Re: Trouble with a simple command! - by xVIP3Rx - 27.11.2013, 23:22
Re: Trouble with a simple command! - by Loot - 27.11.2013, 23:28
Re: Trouble with a simple command! - by Chrillzen - 27.11.2013, 23:34
Re: Trouble with a simple command! - by xVIP3Rx - 27.11.2013, 23:49

Forum Jump:


Users browsing this thread: 1 Guest(s)