Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _entrance_included
- #endinput
- #endif
- #if !defined _streamer_included
- #tryinclude <streamer>
- #if !defined _streamer_included
- #error You must have Streamer include in order to use this one.
- #endif
- #endif
- #define _entrance_included
- #if !defined MAX_ENTRANCES
- #define MAX_ENTRANCES (Entrance:50)
- #endif
- #if !defined MAX_ENTRANCE_NAME
- #define MAX_ENTRANCE_NAME (32)
- #endif
- #define INVALID_ENTRANCE (Entrance:-1)
- enum E_ENTRANCE_DATA
- {
- E_ENTRANCE_NAME[MAX_ENTRANCE_NAME],
- Float:E_ENTRANCE_OUT_X,
- Float:E_ENTRANCE_OUT_Y,
- Float:E_ENTRANCE_OUT_Z,
- Float:E_ENTRANCE_OUT_A,
- E_ENTRANCE_OUT_I,
- E_ENTRANCE_OUT_V,
- Float:E_ENTRANCE_IN_X,
- Float:E_ENTRANCE_IN_Y,
- Float:E_ENTRANCE_IN_Z,
- Float:E_ENTRANCE_IN_A,
- E_ENTRANCE_IN_I,
- E_ENTRANCE_IN_V,
- Text3D:E_ENTRANCE_OUT_LBL,
- Text3D:E_ENTRANCE_IN_LBL
- }
- static
- gEntranceData[MAX_ENTRANCES][E_ENTRANCE_DATA],
- Entrance:gTotalEntrances;
- forward OnPlayerEnterEntrance(playerid, Entrance:entranceid);
- forward OnPlayerExitEntrance(playerid, Entrance:entranceid);
- // ------------------------------------------------------------------------------------
- stock Entrance:CreateEntrance(name[], Float:out_x, Float:out_y, Float:out_z, Float:out_a, out_i, out_v, Float:in_x, Float:in_y, Float:in_z, Float:in_a, in_i, in_v)
- {
- if (gTotalEntrances >= MAX_ENTRANCES)
- return INVALID_ENTRANCE;
- strcat(gEntranceData[gTotalEntrances][E_ENTRANCE_NAME], name);
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_X] = out_x;
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_Y] = out_y;
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_Z] = out_z;
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_A] = out_a;
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_I] = out_i;
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_V] = out_v;
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_X] = in_x;
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_Y] = in_y;
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_Z] = in_z;
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_A] = in_a;
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_I] = in_i;
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_V] = in_v;
- gEntranceData[gTotalEntrances][E_ENTRANCE_OUT_LBL] = CreateDynamic3DTextLabel(name, 0xFFD9D7FF, out_x, out_y, out_z - 0.5, 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, out_v, out_i);
- gEntranceData[gTotalEntrances][E_ENTRANCE_IN_LBL] = CreateDynamic3DTextLabel("Exit", 0xFFD9D7FF, in_x, in_y, in_z - 0.5, 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, in_v, in_i);
- return gTotalEntrances ++;
- }
- // ------------------------------------------------------------------------------------
- stock GetEntranceName(Entrance:index, name[], length = sizeof(name))
- {
- name[0] = EOS;
- strcat(name, gEntranceData[index][E_ENTRANCE_NAME], length);
- }
- // ------------------------------------------------------------------------------------
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if ((newkeys & KEY_SECONDARY_ATTACK))
- {
- for (new Entrance:i; i < gTotalEntrances; i ++)
- {
- if (IsPlayerInRangeOfEntrance(playerid, i))
- {
- if (OnPlayerEnterEntrance(playerid, i) != 0)
- {
- SetPlayerPos(playerid, gEntranceData[i][E_ENTRANCE_IN_X], gEntranceData[i][E_ENTRANCE_IN_Y], gEntranceData[i][E_ENTRANCE_IN_Z]);
- SetPlayerFacingAngle(playerid, gEntranceData[i][E_ENTRANCE_IN_A]);
- SetPlayerInterior(playerid, gEntranceData[i][E_ENTRANCE_IN_I]);
- SetPlayerVirtualWorld(playerid, gEntranceData[i][E_ENTRANCE_IN_V]);
- SetCameraBehindPlayer(playerid);
- }
- }
- else if (IsPlayerInEntrance(playerid, i, 3.0))
- {
- if (OnPlayerExitEntrance(playerid, i) != 0)
- {
- SetPlayerPos(playerid, gEntranceData[i][E_ENTRANCE_OUT_X], gEntranceData[i][E_ENTRANCE_OUT_Y], gEntranceData[i][E_ENTRANCE_OUT_Z]);
- SetPlayerFacingAngle(playerid, gEntranceData[i][E_ENTRANCE_OUT_A]);
- SetPlayerInterior(playerid, gEntranceData[i][E_ENTRANCE_OUT_I]);
- SetPlayerVirtualWorld(playerid, gEntranceData[i][E_ENTRANCE_OUT_V]);
- SetCameraBehindPlayer(playerid);
- }
- }
- }
- }
- #if defined inc_Ent_OnPlayerKeyStateChange
- return inc_Ent_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
- #else
- return 0;
- #endif
- }
- #if defined _ALS_OnPlayerKeyStateChange
- #undef OnPlayerKeyStateChange
- #else
- #define _ALS_OnPlayerKeyStateChange
- #endif
- #define OnPlayerKeyStateChange inc_Ent_OnPlayerKeyStateChange
- #if defined inc_Ent_OnPlayerKeyStateChange
- forward inc_Ent_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
- #endif
- // ------------------------------------------------------------------------------------
- stock IsPlayerInRangeOfEntrance(playerid, Entrance:index, Float:range = 3.0)
- return (IsPlayerInRangeOfPoint(playerid, range, gEntranceData[index][E_ENTRANCE_OUT_X], gEntranceData[index][E_ENTRANCE_OUT_Y], gEntranceData[index][E_ENTRANCE_OUT_Z]) ? true : false);
- // ------------------------------------------------------------------------------------
- stock IsPlayerInEntrance(playerid, Entrance:index, Float:range = 20.0)
- return ((IsPlayerInRangeOfPoint(playerid, range, gEntranceData[index][E_ENTRANCE_IN_X], gEntranceData[index][E_ENTRANCE_IN_Y], gEntranceData[index][E_ENTRANCE_IN_Z]) && GetPlayerVirtualWorld(playerid) == gEntranceData[index][E_ENTRANCE_IN_V]) ? true : false);
- // ------------------------------------------------------------------------------------
- stock GetPlayerClosestEntranceID(playerid, Float:range = 3.0)
- {
- new Entrance:index = INVALID_ENTRANCE, Float:dist = range, Float:tempdist;
- for (new Entrance:i; i < gTotalEntrances; i ++)
- {
- tempdist = GetPlayerDistanceFromPoint(playerid, gEntranceData[i][E_ENTRANCE_OUT_X], gEntranceData[i][E_ENTRANCE_OUT_Y], gEntranceData[i][E_ENTRANCE_OUT_Z]);
- if (tempdist > range)
- continue;
- if (tempdist <= dist)
- {
- dist = tempdist;
- index = i;
- }
- }
- return _:index;
- }
- // ------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement