• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problema con sistema de casa
#2
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.


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(playeridHouseInfo[houseID][hIntID]);
    SetPlayerPos(playeridHouseInfo[houseID][hIntX], HouseInfo[houseID][hIntY], HouseInfo[houseID][hIntZ]);
    SetPlayerVirtualWorld(playerid999 houseID);
    PlayerInfo[playerid][pInHouse] = houseID 1;

    SendClientMessage(playeridCOLOR_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 || houseID >= MAX_SERVER_HOUSES || HouseInfo[houseID][hIntID] != GetPlayerInterior(playerid)) return ShowError(playerid"House data is invalid or mismatched!");
    SetPlayerInterior(playerid0);
    SetPlayerPos(playeridHouseInfo[houseID][hExtX], HouseInfo[houseID][hExtY], HouseInfo[houseID][hExtZ]);
    SetPlayerVirtualWorld(playerid0);
    PlayerInfo[playerid][pInHouse] = 0;

    SendClientMessage(playeridCOLOR_GREEN"SERVER: You have exited the house.");
    return 1;

Currently building from 0
  Reply


Messages In This Thread
Problema con sistema de casa - by Nikolay_Staggs - 2024-12-28, 09:50 AM
RE: Problema con sistema de casa - by NoLife - 2024-12-28, 11:47 AM

Forum Jump: