House spawns you at 0,0,0 instead of set value.
#1

So, I've been busy on a new house system, although when the player is entering the house, it spawns the player at 0,0,0 coordinates.

OnPlayerEnterDynamicCP
pawn Код:
for(new i = 0; i < sizeof(HouseData); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseData[i][heX],HouseData[i][heY],HouseData[i][heZ]))
        {
            new housestring[128];
            watchingHouse[playerid] = HouseData[i][hHouseID];

            format(housestring, sizeof(housestring), "House Menu for house ID %d!", watchingHouse[playerid]);
            ShowPlayerDialog(playerid, DIALOG_ENTERHOUSE, DIALOG_STYLE_LIST, housestring, "Enter House\nBuy House", "Continue", "Cancel");
        }
    }
Dialog Response
pawn Код:
case DIALOG_ENTERHOUSE:
        {  
            if(response) {
                switch(listitem) {
                    case 0: EnterHouse(playerid, watchingHouse[playerid]);
                    case 1: BuyHouse(playerid, watchingHouse[playerid]);
                }
            }
        }
EnterHouse function
pawn Код:
stock EnterHouse(playerid, houseid)
{
    if(HouseData[houseid][hLocked] == 1 && HouseData[houseid][hOwnedBy] != PlayerData[playerid][Username]) return SendClientMessage(playerid, -1, "{E74C3C}Error: This house is currently locked!");
    SetPlayerInterior(playerid, HouseData[houseid][hInterior]);
    SetPlayerPos(playerid, HouseData[houseid][hiX],HouseData[houseid][hiY],HouseData[houseid][hiZ]);
    SendClientMessage(playerid, 0xE74C3CFF, "Press ENTER to leave the house.");
    printf("%d is houseid - %d is interior id - %f is x - %f is y- %f is z", houseid, HouseData[houseid][hInterior], HouseData[houseid][hiX],HouseData[houseid][hiY],HouseData[houseid][hiZ]);
    isInsideHouse[playerid] = 1;
    return 1;
}
Thanks!
Reply
#2

First:
pawn Код:
HouseData[houseid][hOwnedBy] != PlayerData[playerid][Username])
Are those actually integer values?

And second:
is it possible the houseid var is wrong?
Reply
#3

Quote:
Originally Posted by Abagail
Посмотреть сообщение
First:
pawn Код:
HouseData[houseid][hOwnedBy] != PlayerData[playerid][Username])
Are those actually integer values?

And second:
is it possible the houseid var is wrong?
1. With that I'm trying to see if the owner of the house is not the current user.
2. I'm not sure what you mean, but as far as I know, that's the correct house ID I'm looking for.

Although when loading the houses in the server, it's all fine, the marker and all are on the right position.
On top of that, with the printf which was included, it printed this:
Reply
#4

Does it hold the username or the id of the user ? If it's a real name then use strcmp and not !=.
Reply
#5

Quote:
Originally Posted by FSAOskar
Посмотреть сообщение
Does it hold the username or the id of the user ? If it's a real name then use strcmp and not !=.
Fixed that as well although that was not where I needed help with.
Reply
#6

Show us the house array + enum.
Also try to make a command to teleport into a specific house and see if it works.
Reply
#7

Tried making a command out of it, worked and put me in the house successfully.
pawn Код:
CMD:enterhouse(playerid, param[])
{
    SetPlayerInterior(playerid, HouseData[1][hInterior]);
    SetPlayerPos(playerid, HouseData[1][hiX],HouseData[1][hiY],HouseData[1][hiZ]);
    return 1;
}
Here is the array + enum:
pawn Код:
enum _HouseData
{
    hHouseID,
    hOwnedBy[24],
    hLocation[128],
    hPrice,
    hInterior,
    Float:hiX,
    Float:hiY,
    Float:hiZ,
    Float:heX,
    Float:heY,
    Float:heZ,
    Text3D:hHouseText,
    hPickupID,
    hSlots,
    hForSale,
    hLocked,
    hDefaultPrice,
    hMapIcon,
};
new HouseData[MAX_HOUSES][_HouseData];
Reply
#8

I'm not sure if that's the problem but try it like this:
Код:
watchingHouse[playerid] = i;
Reply
#9

Just use an /enter command or button and then loop through the houses.
Reply
#10

Strangely, that worked.
It seems weird though, both return the same value for some reason.

Although thanks again Oskar!

Quote:
Originally Posted by BleverCastard
Посмотреть сообщение
Just use an /enter command or button and then loop through the houses.
That wouldn't have changed a single thing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)