Entrance System: Wanting to link two different entrances together
#1

Hi there. This is probably going to be a pretty long topic. I need some ideas in how to script this.

I have an entrance system, which allows people to enter an entrance say for example the front of LSPD and it'll put them in the LSPD interior at the front.

I also have another entrance which is LSPD Garage from the garage and it puts you in the same virtual world and all that but it spawns you in the LSPD interior at the back.

What I'm wanting to do is have it so that whatever entrance you came in. Only Entrance Type 6 (LSPD FRONT) and 11(LSPD BACK) to be able to enter and exit wherever you like.

Here are my codes that I have.

PHP код:
Entrance_Inside(playerid)
{
    if (
PlayerData[playerid][pEntrance] != -1)    
    {
        for (new 
0!= MAX_ENTRANCES++) if (EntranceData[i][entranceExists] && EntranceData[i][entranceID] == PlayerData[playerid][pEntrance] && GetPlayerInterior(playerid) == EntranceData[i][entranceInterior] && GetPlayerVirtualWorld(playerid) == EntranceData[i][entranceWorld])
            return 
i;
    }
    return -
1;
}
Entrance_GetLink(playerid)
{
    if (
GetPlayerVirtualWorld(playerid) > 0)
    {
        for (new 
0!= MAX_ENTRANCES++) if (EntranceData[i][entranceExists] && EntranceData[i][entranceID] == GetPlayerVirtualWorld(playerid) - 7000)
            return 
EntranceData[i][entranceID];
    }
    return -
1;
}
Entrance_Nearest(playerid)
{
    for (new 
0!= MAX_ENTRANCES++) if (EntranceData[i][entranceExists] && IsPlayerInRangeOfPoint(playerid2.5EntranceData[i][entrancePos][0], EntranceData[i][entrancePos][1], EntranceData[i][entrancePos][2]))
    {
        if (
GetPlayerInterior(playerid) == EntranceData[i][entranceExterior] && GetPlayerVirtualWorld(playerid) == EntranceData[i][entranceExteriorVW])
            return 
i;
    }
    return -
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
newkeys KEY_SECONDARY_ATTACK)
     {
        static
            
id = -1;
        if ((
id Entrance_Nearest(playerid)) != -1)
        {
            if (
EntranceData[id][entranceLocked])
                return 
SendErrorMessage(playerid"This entrance is locked at the moment.");
            if (
PlayerData[playerid][pTask])
            {
                if (
EntranceData[id][entranceType] == && !PlayerData[playerid][pBankTask])
                {
                    
PlayerData[playerid][pBankTask] = 1;
                    
Dialog_Show(playeridShowOnlyDIALOG_STYLE_MSGBOX"Banking""This is one of the banks of San Andreas. You can manage your bank accounts here.\nEach player has a standard bank account and a savings account for extra funds.\n\nYou can type /bank inside this building to manage either of your bank accounts.\nIf you are near any ATM machine, you can use the /atm command for your banking needs.""Close""");
                    if (
IsTaskCompleted(playerid))
                    {
                        
PlayerData[playerid][pTask] = 0;
                        
ShowPlayerFooter(playerid"You have ~g~completed~w~ all your tasks!");
                    }
                }
                else if (
EntranceData[id][entranceType] == && !PlayerData[playerid][pTestTask])
                {
                    
PlayerData[playerid][pTestTask] = 1;
                    
Dialog_Show(playeridShowOnlyDIALOG_STYLE_MSGBOX"DMV""The DMV is where a player can attempt the driving test to obtain their licenses.\nYou must avoid hitting obstacles, damaging the vehicle or speeding during the test.\n\nIt is legally required to possess a driving license to drive in San Andreas.\nDriving without a license can result in several consequences by law enforcement.""Close""");
                    if (
IsTaskCompleted(playerid))
                    {
                        
PlayerData[playerid][pTask] = 0;
                        
ShowPlayerFooter(playerid"You have ~g~completed~w~ all your tasks!");
                    }
                }                    
            }
            if (
EntranceData[id][entranceCustom])
                
SetPlayerPosEx(playeridEntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]);
            else
                
SetPlayerPos(playeridEntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]);
            
SetPlayerFacingAngle(playeridEntranceData[id][entranceInt][3]);
            
SetPlayerInterior(playeridEntranceData[id][entranceInterior]);
            
SetPlayerVirtualWorld(playeridEntranceData[id][entranceWorld]);
            
SetCameraBehindPlayer(playerid);
            
PlayerData[playerid][pEntrance] = EntranceData[id][entranceID];
            return 
1;
        }
        if ((
id Entrance_Inside(playerid)) != -&& IsPlayerInRangeOfPoint(playerid2.5EntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]))
        {
            if (
EntranceData[id][entranceCustom])
                
SetPlayerPosEx(playeridEntranceData[id][entrancePos][0], EntranceData[id][entrancePos][1], EntranceData[id][entrancePos][2]);
            else
                
SetPlayerPosEx(playeridEntranceData[id][entrancePos][0], EntranceData[id][entrancePos][1], EntranceData[id][entrancePos][2]);
            
SetPlayerFacingAngle(playeridEntranceData[id][entrancePos][3] - 180.0);
            
SetPlayerInterior(playeridEntranceData[id][entranceExterior]);
            
SetPlayerVirtualWorld(playeridEntranceData[id][entranceExteriorVW]);
            
SetCameraBehindPlayer(playerid);
            
PlayerData[playerid][pEntrance] = Entrance_GetLink(playerid);
            return 
1;
        } 
I think my brain just isn't working. But I need to be able to check and see if the entrance that the player is equal to type 6 or 11 and if it is, I need to get the opposite ID, and change it to that. And check if it's in range of that exit position.

I hope this makes sense.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)