16.04.2018, 18:41
Try this m8
PHP код:
#define MAX_HOUSES 500
//Don't store information such as ID of entered house in player data enum, it has nothing to do with it. Instead, you can create a new variable:
// Top
new bool:IsInHouse[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
bool:IsInHouse[playerid] = false;
return 1;
}
CMD:exit(playerid)
{
for(new i = 0; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.5, HouseData[i][houseInt][0], HouseData[i][houseInt][1], HouseData[i][houseInt][2])
{
SetPlayerPos(playerid, HouseData[i][housePos][0], HouseData[i][housePos][1], HouseData[i][housePos][2]);
SetPlayerFacingAngle(playerid, HouseData[i][housePos][3] - 180.0);
SetPlayerVirtualWorld(playerid, HouseData[i][houseExteriorVW]); // I don't know why you use this, you should have a default virtual world and reset it
SetCameraBehindPlayer(playerid);
IsInHouse[playerid] = false;
break;
}
}
return 1;
}
CMD:enter(playerid)
{
for(new i = 0; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.5, HouseData[i][houseInt][0], HouseData[i][houseInt][1], HouseData[i][houseInt][2])
{
if(HouseData[i][houseLocked]) return SendErrorMessage(playerid, "You cannot enter a locked house.");
SetPlayerPos(playerid, HouseData[i][houseInt][0], HouseData[i][houseInt][1], HouseData[i][houseInt][2]);
SetPlayerFacingAngle(playerid, HouseData[i][houseInt][3]);
SetPlayerInterior(playerid, HouseData[i][houseInterior]);
SetPlayerVirtualWorld(playerid, i); // You can just use house id as virtual world, it won't mix with others
SetCameraBehindPlayer(playerid);
IsInHouse[playerid] = true;
break;
}
}
return 1;
}