27.11.2013, 23:22
I guess IsPlayerInsideHouse(playerid) returns the house id, but what if you aren't in any house, can you show IsPlayerInsideHouse(playerid) or try to check what is it returning ?
Just to debug it, Check if any of them are different and that's where the problem is..
pawn Код:
CMD:lockhouse(playerid, params[])
{
new id = IsPlayerNearHouseEnt(playerid);
new id2 = IsPlayerInsideHouse(playerid);
if(id != PlayerInfo[playerid][HouseID] || id2 != PlayerInfo[playerid][HouseID])
{
printf("id = %i", id);
printf("id2 = %i", id2);
printf("HouseID = %i", 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;
}