27.11.2013, 23:49
I think that will work..
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.
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;
}
Note: I think you should add that check to your function as well.