Loading houses (should be easy to fix)
#1

- done -
Reply
#2

Here is the code I use in my script.

pawn Код:
enum KHouseInfo {
    HouseID,
    Owner[MAX_PLAYER_NAME],
    Float:OutX,
    Float:OutY,
    Float:OutZ,
    Interiorlevel,
    Price,
    SellPrice,
    VSlots,
    PickupID,
    Locked,
    Password[50],
    UsedSlots,
}
As you see I have the variable PickupID.

And I use not OnPLayerpickuppickup, but OnPlayerKeyStateChange so that whenever someone presses enter, he enters the house.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new houseid = kPlayerInfo[playerid][IsInHouse];
    new InteriorSet = HouseInfo[houseid][Interiorlevel];
    if ((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
    {

        if(kPlayerInfo[playerid][IsInHouse] != 0)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0,Interiors[InteriorSet][IntX], Interiors[InteriorSet][IntY], Interiors[InteriorSet][IntZ]))
            {
                SetPlayerPos(playerid, HouseInfo[houseid][OutX],HouseInfo[houseid][OutY],HouseInfo[houseid][OutZ]);
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerInterior(playerid, 0);
                kPlayerInfo[playerid][IsInHouse] = 0;
            }
        }
        else
        {
            for (new HouseiD = 1; HouseiD < MAX_HOUSES; HouseiD++)
            {
                if (HouseInfo[HouseiD][PickupID] != 0)
                {
                    if(strcmp(HouseInfo[HouseiD][Owner], "System", false, 24))
                    {
                        if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[HouseiD][OutX], HouseInfo[HouseiD][OutY], HouseInfo[HouseiD][OutZ]))
                        {
                            if(HouseInfo[HouseiD][Locked] == 0)
                            {
                                EnterHouse(playerid, HouseiD);
                            }
                            else
                            if(HouseInfo[HouseiD][Locked] == 1)
                            {
                                if(strcmp(HouseInfo[HouseiD][Owner], kPlayerInfo[playerid][Name], false, 24))
                                {
                                    EnterHouse(playerid, HouseiD);
                                }
                                else
                                {
                                    SendClientMessage(playerid, 0xFFFFFFFF, "House is closed for public, only with password you can enter.");
                                    ShowPlayerDialog(playerid, 3,DIALOG_STYLE_INPUT, "House Password", "Please enter the password from the house:", "Enter", "Cancel");
                                }
                            }
                            else
                            if(HouseInfo[HouseiD][Locked] == 2)
                            {
                                if(strcmp(HouseInfo[HouseiD][Owner], kPlayerInfo[playerid][Name], false, 24))
                                {
                                    EnterHouse(playerid, HouseiD);
                                }
                                else
                                {
                                    SendClientMessage(playerid, 0xFFFFFFFF, "House closed for public, you cannot enter it!");
                                }
                               
                            }
                        }
                    }
                    else
                    {
                        if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[HouseiD][OutX], HouseInfo[HouseiD][OutY], HouseInfo[HouseiD][OutZ]))
                        {
                            SendClientMessage(playerid, 0xFFFFFFFF, "This house is for sale! If you want to buy it, type /buyhouse!");
                        }
                    }
                }
            }
        }
    }
    return 1;
}
I hoped I helped you a bit understand it more.
Reply
#3

But, do you know, why did I use local variable in LoadHouses(); to create pickup?

pawn Код:
new pickupid;
Because, I'm not using iterations to check which house is which one. I don't have to loop through all houses, your code is even worse. And I'm not using OnPlayerPickUpDynamicPickup to set player position in house, did you read this callback? There's a message to show dialog, if player enters a pickup. And that's why I have this there:

pawn Код:
PlayerData[playerid][E_PLAYER_PICKEDUP_PICKUP] = pickupid;
To check in which house I'm currently standing. But probably, I'm gonna add a checkpoints there, because, when player leaves pickup his array doesn't get changed to -1.
Reply
#4

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
But, do you know, why did I use local variable in LoadHouses(); to create pickup?

pawn Код:
new pickupid;
Because, I'm not using iterations to check which house is which one. I don't have to loop through all houses, your code is even worse. And I'm not using OnPlayerPickUpDynamicPickup to set player position in house, did you read this callback? There's a message to show dialog, if player enters a pickup. And that's why I have this there:

pawn Код:
PlayerData[playerid][E_PLAYER_PICKEDUP_PICKUP] = pickupid;
To check in which house I'm currently standing. But probably, I'm gonna add a checkpoints there, because, when player leaves pickup his array doesn't get changed to -1.
Oh sorry I've read it wrong. My bad.
Reply
#5

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
Oh sorry I've read it wrong. My bad.
Nevermind.. you tried to help. However, I'm start thinking, isn't UpdateDynamic3DTextLabel problem, because all other things working, entering/exiting house, positions, texts... I hope it's not streamer function fault.
Reply
#6

Okey, so I made a command: /edit2, where I have to put two parameters now, for house_uid and new house text.
pawn Код:
YCMD:edit2(playerid, params[], help)
{
    new text[32],
        string[128];

    new house_uid;

    if(sscanf(params, "ds[32]", house_uid, text))return SendClientMessage(playerid, -1, "Wpisz: /edit (uid_domu) (tekst)");
    {
        strset(HouseData[house_uid][E_HOUSE_DESCRIPTION], text);
       
        SendClientMessage(playerid, -1, "Aktualny opis tego domu to:");
        format(string, sizeof(string), "%s", HouseData[house_uid][E_HOUSE_DESCRIPTION]);
        SendClientMessage(playerid, -1, string);
       
       
        UpdateDynamic3DTextLabelText(HouseData[house_uid][E_HOUSE_LABEL], 0xFFC973FF, text);
    }
    return true;
}
And I went to game and checked this command, and the result was same. Anyway, why did I do that? it's simple, because I wanted to check editing house text without being in house pickup. So, for the logic, it's seems like there's a problem with UpdateDynamic3DTextLabe, right? But I am not sure.

Sorry for double post with bump, but maybe some people will be interested (if they're trying to help me).
Reply
#7

I am using SA:MP's defaults 3dtextlayer functions. update3dtextlabel, works basically the same, maybe just a little slower, but who is the one that sees the difference?
Reply
#8

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
I am using SA:MP's defaults 3dtextlayer functions. update3dtextlabel, works basically the same, maybe just a little slower, but who is the one that sees the difference?
But, to be honest, it should work normally. I will try later to convert it to the default functions and gonna give some result.
Reply
#9

Got the results... it's the same. Doesn't matter that is Dynamic or not.. so, where the hell error is?
Reply
#10

How do u know If a new textdraw is created on top of it ?

And what is "strset"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)