@@ -51,6 +51,9 @@ new const kUnoccupiedSyncMarkTimeMs = 185000;
5151// The area that describes the insides of Las Venturas. Made available and managed by the streamer.
5252new STREAMER_TAG_AREA: g_areaLasVenturas;
5353
54+ // Time (in milliseconds) until when damage issued by a particular player should be disabled.
55+ new g_damageDisabledExpirationTime[MAX_PLAYERS] = { 0 , ... };
56+
5457// Boolean that indicates whether a particular player is currently in Las Venturas.
5558new bool: g_inLasVenturas[MAX_PLAYERS] = { false , ... };
5659
@@ -148,6 +151,11 @@ public OnPlayerConnect(playerid) {
148151 return PlayerEvents (playerid)- > onPlayerConnect ();
149152}
150153
154+ public OnPlayerSpawn (playerid) {
155+ g_damageDisabledExpirationTime[playerid] = 0 ;
156+ return LVPPlayerSpawn (playerid);
157+ }
158+
151159public OnPlayerDisconnect (playerid, reason) {
152160 g_isDisconnecting[playerid] = true ;
153161
@@ -453,6 +461,14 @@ public OnPlayerStateChange(playerid, newstate, oldstate) {
453461 if (oldstate == PLAYER_STATE_DRIVER)
454462 ProcessDriftLeaveVehicleForPlayer (playerid);
455463
464+ // When the player is leaving a vehicle, disable their damage for a predefined amount of time
465+ // to avoid players from abusing vehicle bugs to give them an advantage in a fight.
466+ if ((oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
467+ && g_abuseFakeCarEntryPreventionSec > 0 ) {
468+ g_damageDisabledExpirationTime[playerid] =
469+ GetTickCount () + g_abuseFakeCarEntryPreventionSec * 1000 ;
470+ }
471+
456472 return LegacyPlayerStateChange (playerid, newstate, oldstate);
457473}
458474
@@ -525,6 +541,15 @@ public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float: fX, Float:
525541#if Feature: : EnableServerSideWeaponConfig == 0
526542 DetectAbuseOnWeaponShot (playerid, hittype, hitid);
527543
544+ // If damage has been disabled for the |playerid|, discard the shots entirely. It will expire
545+ // automatically when the time has passed.
546+ if (g_damageDisabledExpirationTime[playerid] > 0 ) {
547+ if (g_damageDisabledExpirationTime[playerid] < GetTickCount ())
548+ g_damageDisabledExpirationTime[playerid] = 0 ;
549+ else
550+ return 0 ;
551+ }
552+
528553 // We might want to ignore damage done by players who are passengers as the sole occupant of a
529554 // vehicle. They can only be damaged with a chainsaw, making this very unfair in fights.
530555 if (g_abuseIgnoreSolePassengerDamage && hittype != BULLET_HIT_TYPE_NONE) {
@@ -621,6 +646,19 @@ public OnPlayerUpdate(playerid) {
621646 if (g_driftingEnabled)
622647 ProcessDriftUpdateForPlayer (playerid);
623648
649+ // Determines if the player is entering a vehicle through animation, and if so, marks the time
650+ // until which their damage should be disabled based on the prevention setting.
651+ if (g_abuseFakeCarEntryPreventionSec > 0 ) {
652+ new const animationIndex = GetPlayerAnimationIndex (playerid);
653+ switch (animationIndex) {
654+ case 1043 /* CAR_OPEN_LHS */ , 1044 /* CAR_OPEN_RHS */ ,
655+ 1026 /* CAR_GETIN_LHS */ , 1027 /* CAR_GETIN_RHS */ : {
656+ g_damageDisabledExpirationTime[playerid] =
657+ GetTickCount () + g_abuseFakeCarEntryPreventionSec * 1000 ;
658+ }
659+ }
660+ }
661+
624662 return 1 ;
625663}
626664#endif
0 commit comments