This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathk_transfendersync.inc
89 lines (79 loc) · 2.42 KB
/
k_transfendersync.inc
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
/*
This include syncs TransFenders (mod shops) with all passengers of the
vehicles and avoids vehicle collision with other vehicles
@licence: GPLv3
@credits: Y_Less (foreach for SA-MP)
(c) Kar 2015
*/
#if !defined inc_transfendersync_
#define inc_transfendersync_
#else
#endinput
#endif
#include <a_samp>
#tryinclude <foreach>
GetVehicleMaxPassengers(iModel) // The include isn't about this, so no stock incase people already use it in their gamemodes
{
if(400 <= iModel <= 611)
{
static s_MaxPassengers[] =
{
271782163, 288428337, 288559891, -2146225407, 327282960, 271651075, 268443408, 286339857, 319894289, 823136512, 805311233,
285414161, 286331697, 268513553, 18026752, 286331152, 286261297, 286458129, 856765201, 286331137, 856690995, 269484528,
51589393, -15658689, 322109713, -15527663, 65343
};
new result = ((s_MaxPassengers[(iModel -= 400) >>> 3] >>> ((iModel & 7) << 2)) & 0xF);
switch(iModel)
{
case 483: result = 2; // Camper (originally 1, which is wrong)
}
return result;
}
return 0xF;
}
public K_TSync_OnEnterExitModShop(playerid, enterexit, interiorid)
{
printf("[System: OnEnterExitModShop] - playerid: %d - enterexit: %d - interiorid: %d", playerid, enterexit, interiorid);
new vehicleid = GetPlayerVehicleID(playerid), maxPassengers, passengerCount;
maxPassengers = GetVehicleMaxPassengers(GetVehicleModel(vehicleid)) + 1; // counting driver
if(enterexit) {
SetVehicleVirtualWorld(vehicleid, playerid);
#if defined _FOREACH_LOCAL_VERSION
foreach(Player, i)
#else
for(new i = 0; i < MAX_PLAYERS; ++i)
#endif
{
if(GetPlayerVehicleID(i) == vehicleid) {
SetPlayerVirtualWorld(i, playerid);
if(++passengerCount == maxPassengers)
break;
}
}
}
else {
SetVehicleVirtualWorld(vehicleid, 0);
#if defined _FOREACH_LOCAL_VERSION
foreach(Player, i)
#else
for(new i = 0; i < MAX_PLAYERS; ++i)
#endif
{
if(GetPlayerVehicleID(i) == vehicleid) {
SetPlayerVirtualWorld(i, 0);
if(++passengerCount == maxPassengers)
break;
}
}
}
return 1;
}
#if defined _ALS_OnEnterExitModShop
#undef OnEnterExitModShop
#else
#define _ALS_OnEnterExitModShop
#endif
#define OnEnterExitModShop K_TSync_OnEnterExitModShop
#if defined K_TSync_OnEnterExitModShop
forward K_TSync_OnEnterExitModShop(playerid);
#endif