2024-12-28, 11:47 AM
Hi Nikolay,
I understand that your issue is when a player enters house ID 1 and then exits, they end up in a different house.
Simple solution:
Track the house ID the player enters and verify it when they exit to ensure they return to the correct location.
See a simple example below and i hope it helps you.
I understand that your issue is when a player enters house ID 1 and then exits, they end up in a different house.
Simple solution:
Track the house ID the player enters and verify it when they exit to ensure they return to the correct location.
See a simple example below and i hope it helps you.
PHP Code:
CMD:enter(playerid)
{
new houseID = GetHouseID(playerid);
if (houseID == -1)
return ShowError(playerid, "You are not near any house!");
if (PlayerInfo[playerid][pHouseID] != HouseInfo[houseID][hID])
{
return ShowError(playerid, "You are not the owner of this house. Use /visit if the house is unlocked.");
}
SetPlayerInterior(playerid, HouseInfo[houseID][hIntID]);
SetPlayerPos(playerid, HouseInfo[houseID][hIntX], HouseInfo[houseID][hIntY], HouseInfo[houseID][hIntZ]);
SetPlayerVirtualWorld(playerid, 999 + houseID);
PlayerInfo[playerid][pInHouse] = houseID + 1;
SendClientMessage(playerid, COLOR_GREEN, "SERVER: You have entered your house.");
return 1;
}
CMD:exit(playerid)
{
if (PlayerInfo[playerid][pInHouse] < 1)
return ShowError(playerid, "You are not inside any interior!");
new houseID = PlayerInfo[playerid][pInHouse] - 1;
if (houseID < 0 || houseID >= MAX_SERVER_HOUSES || HouseInfo[houseID][hIntID] != GetPlayerInterior(playerid)) return ShowError(playerid, "House data is invalid or mismatched!");
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, HouseInfo[houseID][hExtX], HouseInfo[houseID][hExtY], HouseInfo[houseID][hExtZ]);
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pInHouse] = 0;
SendClientMessage(playerid, COLOR_GREEN, "SERVER: You have exited the house.");
return 1;
}
Currently building from 0