Skip to content
Permalink
Browse files
Make the maximum number of connections per IP address configurable in…
… /lvp settings
  • Loading branch information
RussellLVP committed Jul 22, 2020
1 parent 4e891f7 commit fcdbd8a128551a8db7a049773277a0c32d49a7f7
Showing 4 changed files with 10 additions and 6 deletions.
@@ -6,7 +6,7 @@ import { Setting } from 'entities/setting.js';

// List of PawnConfig settings with their unique values and settings. Must be synced with Pawn. The
// settings can be in any category, of any type, as long as the identifier is a valid one.
// Next ID: 18
// Next ID: 19
const kSynchronizedSettings = new Map([
[ 'abuse/disable_out_of_range_damage', { id: 14 } ],
[ 'abuse/fake_car_entry_prevention_enter_ms', { id: 11 } ],
@@ -18,6 +18,7 @@ const kSynchronizedSettings = new Map([
[ 'abuse/kick_reason_public', { id: 6 } ],
[ 'abuse/kill_attribution_time_sec', { id: 7 } ],
[ 'abuse/manual_sawnoff_damage', { id: 13 } ],
[ 'abuse/maximum_connections_per_ip', { id: 18 } ],
[ 'vehicles/drifting_enabled', { id: 1 } ],
[ 'vehicles/drifting_max_angle', { id: 2 } ],
[ 'vehicles/drifting_max_distance', { id: 8 } ],

Some generated files are not rendered by default. Learn more.

@@ -16,6 +16,7 @@ new bool: g_abuseIgnoreSolePassengerDamage = true;
new bool: g_abuseKickReasonsPublic = true;
new g_abuseKillAttributionTimeSec = 10;
new bool: g_abuseManualSawnoffDamage = false;
new g_maximumConnectionsPerIP = 3;

// Section: drifting
new bool: g_driftingEnabled = false;
@@ -30,7 +31,7 @@ new bool: g_vehicleKeysBlockedInLasVenturas = true;

// These are the unique Ids for each of the properties that can be updated. They must be identical
// between the Pawn and the JavaScript code.
// Next ID: 18
// Next ID: 19
enum PawnConfigProperty {
kAbuseDisableOutOfRangeDamage = 14,
kAbuseFakeCarEntryPreventionEnterMs = 11,
@@ -42,6 +43,7 @@ enum PawnConfigProperty {
kAbuseKickReasonPublic = 6,
kAbuseKillAttributionTimeSec = 7,
kAbuseManualSawnoffDamage = 13,
kAbuseMaximumConnectionsPerIP = 18,
kVehiclesDriftingEnabled = 1,
kVehiclesDriftingMaxAngle = 2,
kVehiclesDriftingMaxDistance = 8,
@@ -116,3 +118,6 @@ public OnPawnConfigDataChange(PawnConfigProperty: property, Float: numberValue)

// Functions to allow legacy parts of the gamemode to access the values. Only when needed.
AreKickReasonsPublic() { return g_abuseKickReasonsPublic ? 1 : 0; }

// Returns the maximum number of allowable connections per IP address.
GetMaximumConnectionsPerIP() { return g_maximumConnectionsPerIP; }
@@ -10,9 +10,6 @@
* @author Russell Krupke <russell@sa-mp.nl>
*/
class PlayerEvents <playerId (MAX_PLAYERS)> {
// Maximum number of connections allowed from a single IP address.
const MaxConnectionsPerIp = 3;

// Time in milliseconds between two timestamps of connections originating from the same IP address.
const DefaultDelayConnection = 500;

@@ -52,7 +49,7 @@ class PlayerEvents <playerId (MAX_PLAYERS)> {
}

// Check if the maximum number of players ingame from the same IP has been reached.
if (matchedPlayers >= MaxConnectionsPerIp) {
if (matchedPlayers >= GetMaximumConnectionsPerIP()) {
printf("Player [%d] shares IP with %d ingame players.", playerId, matchedPlayers);
Kick(playerId); // deny player entry
}

0 comments on commit fcdbd8a

Please sign in to comment.