[Houses] Virtual Worlds
#1

Hello SA:MP scripters,

I have a question about houses and interiors/worlds.

Each house needs to have a different world (Because if you have two houses with the same interior and world, you'll see each other if you both enter the two different houses with the same interior and world)

How would you go about assigning a house with interiors and worlds? Obviously, is the house is sold, you want it to be up for sale again..

Me and a friend bought a script and we are needing the house system re-done, as we want it to be dynamic where we can add houses in game, with the same interior but we need it where the script assigns each house a different world (Even if it doesn't have the same interior).

Regards,
X3nZ.
Reply
#2

Regarding the worlds, just make it so when you enter a house, you use the house id as the virtual world. So if playerid 1 entered house id 2, you set playerids 1 virtual world to 2.

Here's an example from my system:
pawn Код:
for(new i = 1; i < sizeof(HouseInfo); i++)
            {
                if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][hOutsideX], HouseInfo[i][hOutsideY], HouseInfo[i][hOutsideZ]))
                {
                    if(HouseInfo[i][hCreated] == 1)
                    {
                        if(HouseInfo[i][hLocked] == 0)
                        {
                            SetPlayerPos(playerid, HouseInfo[i][hInsideX], HouseInfo[i][hInsideY], HouseInfo[i][hInsideZ]);
                            SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
                            SetPlayerVirtualWorld(playerid, i);
                            SetPlayerFacingAngle(playerid, HouseInfo[i][hInsideA]);
                            format(string, sizeof(string), "* %s has entered the house.", PlayerName(playerid));
                            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            return 1;
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, " This house is locked!");
                            return 1;
                        }
                    }
                }
            }
Reply
#3

Ok, is that code you posted apart of your /enter command?

Cause that looks similar to have I have.

Please explain that
pawn Код:
HouseInfo[i][hInsideA]
Like, what's that "A" for? I know that hInside is to tell that the player is inside the house.

Here is mine

pawn Код:
for(new i = 0; i < sizeof(HouseInfo); i++)
        {
            if (PlayerToPoint(2.0, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
            {
                ////printf("Found House :%d",i);
                if(PlayerInfo[playerid][pHousekey] == i || HouseInfo[i][hLock] == 0 || AdminDuty[playerid] == 1)
                {
                    SetPlayerFacingAngle( playerid,0);
                    //TogglePlayerControllable(playerid, 0);
                    SetPlayerInterior(playerid,HouseInfo[i][hInt]);
                    if(i == 28) SetPlayerVirtualWorld(playerid, 88888);
                    else SetPlayerVirtualWorld(playerid, HouseInfo[i][hWorld]);
                //  Pause(playerid);
                    DOO_SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
                    PlayerInfo[playerid][pInt] = HouseInfo[i][hInt];
                    PlayerInfo[playerid][pLocal] = i;
                    HouseEntered[playerid] = i;
                    Streamer_Update(playerid);
                }
                else GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
            }
        }
Reply
#4

Eh.. maybe you bought one of my scripts that have been stolen, lol. That is the enter command yes. Mind telling me if there's a "/house" command?
Reply
#5

I assure you, this isn't your script.

This is Harry Kirby's script.

And yes, there is a /house command.
Please re-read my second post as I have updated it.
Reply
#6

Funny how the only house system I've seen scripted with a /house command is my script...

Any way, the hInsideA is the facing angle the person faces when they enter the house.
A = Angle
Reply
#7

Ah ok.

I'm sorry about this confusion.
Harry Kirby was the owner of this script, which was the Infinitum Gaming Roleplay script.

Also, if I were to take your code above, put it into mine, would it change the whole system of how it would set worlds?
Reply
#8

Just insert:
SetPlayerVirtualWorld(playerid, i);

then on exit,
SetPlayerVirtualWorld(playerid, 0);
Reply
#9

Ok, here is a legend of what I'm replacing, to help me understand

Alright, now look at the code were I commented my current SetPlayerVirtualWorld

pawn Код:
for(new i = 0; i < sizeof(HouseInfo); i++)
        {
            if (PlayerToPoint(2.0, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
            {
                ////printf("Found House :%d",i);
                if(PlayerInfo[playerid][pHousekey] == i || HouseInfo[i][hLock] == 0 || AdminDuty[playerid] == 1)
                {
                    SetPlayerFacingAngle( playerid,0);
                    //TogglePlayerControllable(playerid, 0);
                    SetPlayerInterior(playerid,HouseInfo[i][hInt]);
                    SetPlayerVirtualWorld(playerid, i);
                    /*if(i == 28) SetPlayerVirtualWorld(playerid, 88888);
                    else SetPlayerVirtualWorld(playerid, HouseInfo[i][hWorld]);*/

                    SetPlayerVirtualWorld(playerid, i);
                //  Pause(playerid);
                    DOO_SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
                    PlayerInfo[playerid][pInt] = HouseInfo[i][hInt];
                    PlayerInfo[playerid][pLocal] = i;
                    HouseEntered[playerid] = i;
                    Streamer_Update(playerid);
                }
                else GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
            }
        }
EDIT: Well, it's not going to read the colors in the [pawn] tags. But you get the idea

EDIT: Actually, I'm failing hardcore right now, I'm doing the SetPlayerInterior not world :P
Reply
#10

Okay, use one of these:
pawn Код:
for(new i = 0; i < sizeof(HouseInfo); i++)
        {
            if (PlayerToPoint(2.0, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
            {
                ////printf("Found House :%d",i);
                if(PlayerInfo[playerid][pHousekey] == i || HouseInfo[i][hLock] == 0 || AdminDuty[playerid] == 1)
                {
                    SetPlayerFacingAngle( playerid,0);
                    //TogglePlayerControllable(playerid, 0);
                    SetPlayerInterior(playerid,HouseInfo[i][hInt]);
                    if(i == 28) SetPlayerVirtualWorld(playerid, 88888); // What would I do with this current SetPlayerVirtualWorld as I have an else to check and see if something is going on, which I'm not sure about
                    else SetPlayerVirtualWorld(playerid, i);
                    DOO_SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
                    PlayerInfo[playerid][pInt] = HouseInfo[i][hInt];
                    PlayerInfo[playerid][pLocal] = i;
                    HouseEntered[playerid] = i;
                    Streamer_Update(playerid);
                }
                else GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
            }
        }
pawn Код:
for(new i = 0; i < sizeof(HouseInfo); i++)
        {
            if (PlayerToPoint(2.0, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
            {
                ////printf("Found House :%d",i);
                if(PlayerInfo[playerid][pHousekey] == i || HouseInfo[i][hLock] == 0 || AdminDuty[playerid] == 1)
                {
                    SetPlayerFacingAngle( playerid,0);
                    //TogglePlayerControllable(playerid, 0);
                    SetPlayerInterior(playerid,HouseInfo[i][hInt]);
                    SetPlayerVirtualWorld(playerid, i);
                    DOO_SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
                    PlayerInfo[playerid][pInt] = HouseInfo[i][hInt];
                    PlayerInfo[playerid][pLocal] = i;
                    HouseEntered[playerid] = i;
                    Streamer_Update(playerid);
                }
                else GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
            }
        }
Try both and see which one seems to work better. I'd recommend the second one but for some odd reason there's a check if the houseid is 28.. must be something to do with the house system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)