-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteriorFallFix.inc
More file actions
186 lines (160 loc) · 6.61 KB
/
InteriorFallFix.inc
File metadata and controls
186 lines (160 loc) · 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
| English:
- This include fixes players falling through interior floors and mapping. The issue is quite serious and has not been properly resolved in most places.
- The script performs two functions that prevent falling in 99.9% of cases:
- 1. Creates a static platform under the player before teleportation.
- 2. If falling is detected after teleportation, the player is teleported back.
| Ðóññêèé:
- Äàííûé èíêëóä èñïðàâëÿåò ïðîâàëèâàíèÿ èãðîêàìè ïîä ïîëû èíòåðüåðîâ è ìàïïèíã. Ïðîáëåìà äîñòàòî÷íî ñåðüåçíàÿ è ïî÷òè íèãäå ïîëíîöåííî íå èñïðàâëåííàÿ.
- Ñêðèïò âûïîëíÿåò ñðàçó 2 ôóíêöèè, íà 99.9%, èñêëþ÷àþùèå ïðîâàëèâàíèÿ:
- 1. Ñîçäà¸ò ïîä èãðîêîì ñòàòè÷íóþ ïëàòôîðìó ïåðåä òåëåïîðòàöèåé.
- 2. Ïðè îáíàðóæåíèè ïàäåíèÿ èãðîêà ïîñëå òåëåïîðòàöèè - òåëåïîðòèðóåò åãî íàçàä.
- Author: timmylich. (originally for Brentwood Project)
- Version: 2.0.
- Date: 15 June 2025.
- GitHub Repo: https://github.com/timmylich/interiorfallfix
- Connect with author:
- VKontake: https://vk.com/timmylich
- Telegram: https://t.me/timmylich
- Discord: http://discordapp.com/users/523177185062682685 (@timmylich.)
*/
#if defined _IFX_
#endinput
#endif
#define _IFX_
/*
[EN] The time after teleportation during which the player will be checked for falling, in order to "rescue" them if necessary (in milliseconds).
[RU] Âðåìÿ, êîòîðîå ïîñëå òåëåïîðòàöèè áóäåò ïðîâåðÿòüñÿ ïàäàåò ëè èãðîê äëÿ åãî "ñïàñåíèÿ" (â ìèëëèñåêóíäàõ).
*/
#if !defined IFX_FixTime
#define IFX_FixTime 7000
#endif
/*
[EN] The duration for which the static platform will be created under the player in the interior (in milliseconds).
[RU] Âðåìÿ, íà êîòîðîå áóäåò ñîçäàâàòüñÿ ñòàòè÷íàÿ ïëàòôîðìà ïîä èãðîêîì â èíòåðüåðå (â ìèëëèñåêóíäàõ).
*/
#if !defined IFX_InteriorPlatformTime
#define IFX_InteriorPlatformTime 4000
#endif
/*
[EN] The duration for which the static platform will be created under the player in the exterior (in milliseconds).
[RU] Âðåìÿ, íà êîòîðîå áóäåò ñîçäàâàòüñÿ ñòàòè÷íàÿ ïëàòôîðìà ïîä èãðîêîì â ýêñòåðüåðå (â ìèëëèñåêóíäàõ).
*/
#if !defined IFX_InteriorPlatformTime
#define IFX_ExteriorPlatformTime 2000
#endif
/*
[EN] Substitute your own function to get the player's interior, if necessary.
[RU] Ïîäñòàâüòå ñâîþ ôóíêöèþ äëÿ ïîëó÷åíèÿ èíòåðüåðà èãðîêà, åñëè ýòî íåîáõîäèìî.
*/
#if !defined IFX_GetPlayerInterior
#define IFX_GetPlayerInterior(%0) GetPlayerInterior(%0)
#endif
/*
[EN] Timing between checks in OnPlayerUpdate (ms).
[RU] Òàéìèíã ìåæäó ñðàáàòûâàíèÿìè ïðîâåðîê â OnPlayerUpdate (â ìèëëèñåêóíäàõ).
*/
#if !defined IFX_PlayerUpdateCD
#define IFX_PlayerUpdateCD 250
#endif
/*
[EN] Z-axis offset downward at which the script will consider the player falling into the void.
[RU] Ñìåùåíèå ïî êîîðäèíàòå Z âíèç, ïî äîñòèæåíèþ êîòîðîãî ñêðèïò ïîñ÷èòàåò èãðîêà ïàäàþùèì â áåçäíó.
*/
#if !defined IFX_FallZShift
#define IFX_FallZShift 0.2
#endif
/*
| English:
- Function for creating a static surface under the player. Place it inside the teleportation logic, like SetPlayerPosEx, filling in all required arguments (or -1 in certain situations).
* oldworld - the player's virtual world before teleportation.
* newworld - the player's virtual world after teleportation.
* oldint - the player's interior before teleportation.
* newint - the player's interior after teleportation.
| Ðóññêèé:
- Ôóíêöèÿ ñîçäàíèÿ ñòàòè÷íîé ïîâåðõíîñòè ïîä èãðîêîì. Ïîìåñòèòå å¸ âíóòðü òåëåïîðòàöèè, ïî òèïó SetPlayerPosEx, çàïîëíèâ âñå íóæíûå àðãóìåíòû (ëèáî -1 â íåêîòîðûõ ñèòóàöèÿõ).
* oldworld - âèðòóàëüíûé ìèð èãðîêà äî òåëåïîðòàöèè.
* newworld - âèðòóàëüíûé ìèð èãðîêà ïîñëå òåëåïîðòàöèè.
* oldint - èíòåðüåð èãðîêà äî òåëåïîðòàöèè.
* newint - èíòåðüåð èãðîêà ïîñëå òåëåïîðòàöèè.
*/
stock IFX_GeneratePlatform(playerid, oldworld = -1, newworld = -1, oldint = -1, newint = -1, Float:x, Float:y, Float:z)
{
if((newworld >= 0 && newworld != oldworld) || (newint >= 0 && newint != oldint))
{
new Float:_a;
GetPlayerFacingAngle(playerid, _a);
new obj = CreatePlayerObject(playerid, 19890, x, y, z-1.0, 0.0, 0.0, _a, 10000.0);
SetPlayerObjectMaterial(playerid, obj, 0, 19962, !"samproadsigns", !"materialtext1", 0x00000000);
SetTimerEx(!"IFX_ObjectDeletion", newint ? IFX_InteriorPlatformTime : IFX_ExteriorPlatformTime, false, !"dd", playerid, obj);
}
}
forward IFX_ObjectDeletion(playerid, objectid);
public IFX_ObjectDeletion(playerid, objectid) return DestroyPlayerObject(playerid, objectid);
static _disabled;
/*
| English:
- Use before teleportation if you need to disable the fall recovery attempt.
| Ðóññêèé:
- Èñïîëüçóéòå ïåðåä òåëåïîðòàöèåé, åñëè âàì íåîáõîäèìî îòêëþ÷èòü ïîïûòêó ðàáîòû "ñïàñàëêè" îò ïàäåíèé.
*/
stock IFX_DisableAttempt() _disabled = true;
static Float:LastTP[MAX_PLAYERS][3];
static LastTPTime[MAX_PLAYERS];
// SetPlayerPos hook
stock IFX_SetPlayerPos(playerid, Float:x, Float:y, Float:z)
{
new Float:_x, Float:_y, Float:_z;
GetPlayerPos(playerid, _x, _y, _z);
if(!_disabled && (!(-0.5 <= (x-_x) <= 0.5) || !(-0.5 <= (y-_y) <= 0.5) || !(-5.0 <= (z-_z) <= 5.0)))
{
LastTPTime[playerid] = GetTickCount();
LastTP[playerid][0] = x;
LastTP[playerid][1] = y;
LastTP[playerid][2] = z;
}
else if(_disabled) _disabled = false;
return SetPlayerPos(playerid, x, y, z);
}
#if defined _ALS_SetPlayerPos
#undef SetPlayerPos
#else
#define _ALS_SetPlayerPos
#endif
#define SetPlayerPos IFX_SetPlayerPos
static LastPlayerUpdate[MAX_PLAYERS];
// OnPlayerUpdate hook
public OnPlayerUpdate(playerid)
{
if(GetTickCount()-IFX_PlayerUpdateCD > LastPlayerUpdate[playerid])
{
LastPlayerUpdate[playerid] = GetTickCount();
if(LastTPTime[playerid]+IFX_FixTime > GetTickCount() && IFX_GetPlayerInterior(playerid))
{
static Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if((-0.1 <= (x - LastTP[playerid][0]) <= 0.1) && (-0.1 <= (y - LastTP[playerid][1]) <= 0.1))
{
if(LastTP[playerid][2]-IFX_FallZShift > z)
{
SetPlayerPos(playerid, LastTP[playerid][0], LastTP[playerid][1], LastTP[playerid][2]);
return 1;
}
}
}
}
#if defined IFX_OnPlayerUpdate
return IFX_OnPlayerUpdate(playerid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerUpdate
#undef OnPlayerUpdate
#else
#define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate IFX_OnPlayerUpdate
#if defined IFX_OnPlayerUpdate
forward IFX_OnPlayerUpdate(playerid);
#endif