Entrance_Inside(playerid)
{
if (PlayerData[playerid][pEntrance] != -1)
{
for (new i = 0; i != MAX_ENTRANCES; i ++) 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 i = 0; i != MAX_ENTRANCES; i ++) if (EntranceData[i][entranceExists] && EntranceData[i][entranceID] == GetPlayerVirtualWorld(playerid) - 7000)
return EntranceData[i][entranceID];
}
return -1;
}
Entrance_Nearest(playerid)
{
for (new i = 0; i != MAX_ENTRANCES; i ++) if (EntranceData[i][entranceExists] && IsPlayerInRangeOfPoint(playerid, 2.5, EntranceData[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(playerid, newkeys, oldkeys)
{
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] == 2 && !PlayerData[playerid][pBankTask])
{
PlayerData[playerid][pBankTask] = 1;
Dialog_Show(playerid, ShowOnly, DIALOG_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] == 1 && !PlayerData[playerid][pTestTask])
{
PlayerData[playerid][pTestTask] = 1;
Dialog_Show(playerid, ShowOnly, DIALOG_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(playerid, EntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]);
else
SetPlayerPos(playerid, EntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]);
SetPlayerFacingAngle(playerid, EntranceData[id][entranceInt][3]);
SetPlayerInterior(playerid, EntranceData[id][entranceInterior]);
SetPlayerVirtualWorld(playerid, EntranceData[id][entranceWorld]);
SetCameraBehindPlayer(playerid);
PlayerData[playerid][pEntrance] = EntranceData[id][entranceID];
return 1;
}
if ((id = Entrance_Inside(playerid)) != -1 && IsPlayerInRangeOfPoint(playerid, 2.5, EntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]))
{
if (EntranceData[id][entranceCustom])
SetPlayerPosEx(playerid, EntranceData[id][entrancePos][0], EntranceData[id][entrancePos][1], EntranceData[id][entrancePos][2]);
else
SetPlayerPosEx(playerid, EntranceData[id][entrancePos][0], EntranceData[id][entrancePos][1], EntranceData[id][entrancePos][2]);
SetPlayerFacingAngle(playerid, EntranceData[id][entrancePos][3] - 180.0);
SetPlayerInterior(playerid, EntranceData[id][entranceExterior]);
SetPlayerVirtualWorld(playerid, EntranceData[id][entranceExteriorVW]);
SetCameraBehindPlayer(playerid);
PlayerData[playerid][pEntrance] = Entrance_GetLink(playerid);
return 1;
}
0: None | 1: DMV | 2: Bank | 3: Warehouse | 4: City Hall | 5: Shooting Range | 6: Police Department | 7: Strip Club, 8: Gas Station | 9: Sex Shop | 10: Gym | 11: LS PD Exit
|
'static' remembers its old value.
And that is why he is exiting from the same entrance or whatever.. |