From ba54a9f72d6819688974497b274a06f80d548507 Mon Sep 17 00:00:00 2001 From: Damen Date: Thu, 24 Jan 2019 23:39:34 -0500 Subject: [PATCH 01/13] adjusts the migration error to fix developing work, removes the ability to use animations while using a parachute, fixes weed error OnPlayerDisconnect, removes the ability to gain IC while doing an animation, removes the ability to send IC to spectating admins, adds a variable setter OnPlayerConnect to remove the ability to relog to skip the cooldown timer for Dirty Mechanic --- gamemodes/irresistible/cnr/features/animations.pwn | 10 ++++++++++ gamemodes/irresistible/cnr/features/car_jacker.pwn | 6 ++++++ .../irresistible/cnr/features/vip/coin_generation.pwn | 2 +- .../irresistible/cnr/features/vip/coin_market.pwn | 2 +- gamemodes/irresistible/cnr/features/weed.pwn | 1 - .../irresistible/config/migrations/_migrations.pwn | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/animations.pwn b/gamemodes/irresistible/cnr/features/animations.pwn index fa5cb13..0395be9 100644 --- a/gamemodes/irresistible/cnr/features/animations.pwn +++ b/gamemodes/irresistible/cnr/features/animations.pwn @@ -362,6 +362,7 @@ stock CreateLoopingAnimation( playerid, animlib[ ], animname[ ], Float:Speed, lo else if ( IsPlayerAttachedObjectSlotUsed( playerid, 3 ) ) return SendError( playerid, "You cannot use this command since you're holding a stolen good." ); else if ( GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_DRIVER || GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_PASSENGER ) return SendError( playerid, "You cannot use this command since you're entering a vehicle." ); else if ( GetPlayerState( playerid ) == PLAYER_STATE_EXIT_VEHICLE ) return SendError( playerid, "You cannot use this command since you're exiting a vehicle." ); + else if ( IsPlayerWearingParachute( playerid ) ) return SendError( playerid, "You cannot use this command while wearing a parachute." ); else { SetPlayerSpecialAction( playerid, 0 ); @@ -397,3 +398,12 @@ stock IsPlayingAnimation( playerid, const library[ ], const animation[ ] ) stock IsPlayerUsingAnimation( playerid ) { return p_InAnimation{ playerid }; } + + +stock IsPlayerWearingParachute( playerid ) +{ + if ( GetPlayerWeapon( playerid ) == 46 ) + return true; + else + return false; +} \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/car_jacker.pwn b/gamemodes/irresistible/cnr/features/car_jacker.pwn index 57cff05..f183fa6 100644 --- a/gamemodes/irresistible/cnr/features/car_jacker.pwn +++ b/gamemodes/irresistible/cnr/features/car_jacker.pwn @@ -42,6 +42,12 @@ hook OnScriptInit( ) return 1; } +hook OnPlayerConnect( playerid ) +{ + p_AntiExportCarSpam [ playerid ] = g_iTime + 60; + return 1; +} + hook OnPlayerDisconnect( playerid, reason ) { g_LastExportModel[ playerid ] = 0; diff --git a/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn b/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn index fc770c3..8fb37f6 100644 --- a/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn +++ b/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn @@ -55,7 +55,7 @@ hook OnPlayerTickSecond( playerid ) iKeys, iUpDownKeys, iLeftRightKeys; // Increase Irresistible Coins (1/20 = cred/min) - if ( ! IsPlayerAFK( playerid ) && GetPlayerKeys( playerid, iKeys, iUpDownKeys, iLeftRightKeys ) && ! IsPlayerOnRoulette( playerid ) && ! IsPlayerOnSlotMachine( playerid ) && GetPlayerVehicleSeat( playerid ) <= 0 ) + if ( ! IsPlayerAFK( playerid ) && GetPlayerKeys( playerid, iKeys, iUpDownKeys, iLeftRightKeys ) && ! IsPlayerOnRoulette( playerid ) && ! IsPlayerOnSlotMachine( playerid ) && GetPlayerVehicleSeat( playerid ) <= 0 && !IsPlayerUsingAnimation( playerid ) ) { if ( iKeys != 0 || iUpDownKeys != 0 || iLeftRightKeys != 0 ) { // GetPlayerScore( playerid ) > 10 && diff --git a/gamemodes/irresistible/cnr/features/vip/coin_market.pwn b/gamemodes/irresistible/cnr/features/vip/coin_market.pwn index fce31d5..b40adf2 100644 --- a/gamemodes/irresistible/cnr/features/vip/coin_market.pwn +++ b/gamemodes/irresistible/cnr/features/vip/coin_market.pwn @@ -501,7 +501,7 @@ CMD:irresistiblecoins( playerid, params[ ] ) else if ( senttoid == playerid ) return SendError( playerid, "You cannot send yourself coins." ); else { - if ( GetDistanceBetweenPlayers( playerid, senttoid ) > 8.0 ) + if ( GetDistanceBetweenPlayers( playerid, senttoid ) > 8.0 || p_Spectating{ senttoid } ) return SendError( playerid, "Please make sure you are close to the player before sending coins to them." ); format( szNormalString, sizeof( szNormalString ), "INSERT INTO `TRANSACTIONS_IC` (`TO_ID`, `FROM_ID`, `IC`) VALUES (%d, %d, %f)", p_AccountID[ senttoid ], p_AccountID[ playerid ], coins ); diff --git a/gamemodes/irresistible/cnr/features/weed.pwn b/gamemodes/irresistible/cnr/features/weed.pwn index 6d814ce..ebf07c0 100644 --- a/gamemodes/irresistible/cnr/features/weed.pwn +++ b/gamemodes/irresistible/cnr/features/weed.pwn @@ -329,7 +329,6 @@ stock Weed_GetPlantLimit( playerid ) stock Weed_ResetSellingProperties( playerid ) { - Weed_ResetSellingProperties( playerid ); p_WeedSellingGrams[ playerid ] = 0; p_WeedSellingPrice[ playerid ] = 0; return 1; diff --git a/gamemodes/irresistible/config/migrations/_migrations.pwn b/gamemodes/irresistible/config/migrations/_migrations.pwn index de1239d..e49ebad 100644 --- a/gamemodes/irresistible/config/migrations/_migrations.pwn +++ b/gamemodes/irresistible/config/migrations/_migrations.pwn @@ -55,7 +55,7 @@ public Migrations_CheckMissing( ) new num_migrations = Migrations_GetCount( ); - if ( executed_migrations != num_migrations ) + if ( executed_migrations < num_migrations ) { new dir: migrations_directory = dir_open( SERVER_MIGRATIONS_FOLDER ), From 44ccbd825d20dda1ecd9ce88ccaadce926ae85b9 Mon Sep 17 00:00:00 2001 From: Damen Date: Thu, 24 Jan 2019 23:47:47 -0500 Subject: [PATCH 02/13] removes the ability to use player-owned vehicle commands in a vehicle underwater --- .../irresistible/cnr/features/vehicles/vehicles.pwn | 13 +++++++++---- gamemodes/sf-cnr.pwn | 12 ++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn b/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn index 9404e50..0a053c2 100644 --- a/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn +++ b/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn @@ -305,6 +305,7 @@ CMD:v( playerid, params[ ] ) else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You need to be a driver to use this command." ); else if ( v == -1 ) return SendError( playerid, "This vehicle isn't a buyable vehicle." ); else if ( playerid != ownerid ) return SendError( playerid, "You cannot park this vehicle." ); + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); else { if ( IsVehicleUpsideDown( GetPlayerVehicleID( playerid ) ) ) return SendError( playerid, "Sorry, you're just going to have to ditch your car as soon as possible." ); @@ -344,8 +345,8 @@ CMD:v( playerid, params[ ] ) { if ( p_VehicleBringCooldown[ playerid ] > g_iTime ) return SendError( playerid, "You must wait %s before using this feature again.", secondstotime( p_VehicleBringCooldown[ playerid ] - g_iTime ) ); - - if ( p_OwnedVehicles[ playerid ] > 0 ) + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); + else if ( p_OwnedVehicles[ playerid ] > 0 ) { szLargeString = ""COL_WHITE"Bringing your vehicle to you will cost $10,000!\n"; for( new i; i < p_OwnedVehicles[ playerid ]; i++ ) @@ -383,6 +384,7 @@ CMD:v( playerid, params[ ] ) ; if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You must be inside a vehicle to use this command." ); else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You need to be a driver to use this command." ); + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); else if ( sscanf( params[ 6 ], "dd", color1, color2 ) ) return SendUsage( playerid, "/v color [COLOR_1] [COLOR_2]" ); else if ( g_buyableVehicle{ GetPlayerVehicleID( playerid ) } == false ) return SendError( playerid, "This isn't a buyable vehicle." ); else if ( GetPlayerCash( playerid ) < 100 ) return SendError( playerid, "You don't have enough cash for this." ); @@ -407,6 +409,7 @@ CMD:v( playerid, params[ ] ) ; if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You must be inside a vehicle to use this command." ); else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You need to be a driver to use this command." ); + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); else if ( sscanf( params[ 6 ], "s[32]", szPlate ) ) return SendUsage( playerid, "/v plate [TEXT]" ); else if ( g_buyableVehicle{ GetPlayerVehicleID( playerid ) } == false ) return SendError( playerid, "This isn't a buyable vehicle." ); else @@ -428,6 +431,7 @@ CMD:v( playerid, params[ ] ) ; if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You must be inside a vehicle to use this command." ); else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You need to be a driver to use this command." ); + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); else if ( sscanf( params[ 9 ], "d", paintjobid ) ) return SendUsage( playerid, "/v paintjob [PAINT_JOB_ID]" ); else if ( g_buyableVehicle{ GetPlayerVehicleID( playerid ) } == false ) return SendError( playerid, "This isn't a buyable vehicle." ); else if ( GetPlayerCash( playerid ) < 500 ) return SendError( playerid, "You don't have enough cash for this." ); @@ -450,6 +454,7 @@ CMD:v( playerid, params[ ] ) new v = getVehicleSlotFromID( vehicleid, ownerid ); if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You need to be in a vehicle to use this command." ); else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You need to be a driver to use this command." ); + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); else if ( v == -1 ) return SendError( playerid, "This vehicle isn't a buyable vehicle." ); else if ( playerid != ownerid ) return SendError( playerid, "This vehicle does not belong to you." ); else @@ -461,7 +466,7 @@ CMD:v( playerid, params[ ] ) if ( !strcmp( params[ 7 ], "doors", true, 5 ) ) { if ( !strlen( params[ 13 ] ) ) return SendUsage( playerid, "/v toggle doors [OPEN/CLOSE]" ); - if ( strmatch( params[ 13 ], "open" ) ) { + else if ( strmatch( params[ 13 ], "open" ) ) { SetVehicleParamsCarDoors( vehicleid, 1, 1, 1, 1 ); return SendServerMessage( playerid, "You have opened the doors of this vehicle." ); } @@ -476,7 +481,7 @@ CMD:v( playerid, params[ ] ) else if ( !strcmp( params[ 7 ], "windows", true, 7 ) ) { if ( !strlen( params[ 15 ] ) ) return SendUsage( playerid, "/v toggle windows [OPEN/CLOSE]" ); - if ( strmatch( params[ 15 ], "open" ) ) { + else if ( strmatch( params[ 15 ], "open" ) ) { SetVehicleParamsCarWindows( vehicleid, 0, 0, 0, 0 ); return SendServerMessage( playerid, "You have opened the windows of this vehicle." ); } diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 89784a5..3faf292 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -7147,3 +7147,15 @@ stock GetPlayerOutsidePos( playerid, &Float: X, &Float: Y, &Float: Z ) // gets t } return 1; } + +stock IsPlayerBelowSeaLevel( playerid ) +{ + new Float: x, Float: y, Float: z; + + GetPlayerPos( playerid, x, y, z ); + + if ( z < 0.0 ) + return true; + else + return false; +} \ No newline at end of file From 130f1c581e115a79fc304fab5156843eb8df3c12 Mon Sep 17 00:00:00 2001 From: Damen Date: Thu, 24 Jan 2019 23:48:43 -0500 Subject: [PATCH 03/13] removes the ability to use dirty mechanic commands in a vehicle underwater --- gamemodes/sf-cnr.pwn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 3faf292..a831457 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2357,8 +2357,9 @@ CMD:mech( playerid, params[ ] ) ; if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "You must be a civilian to use this command." ); - if ( !IsPlayerJob( playerid, JOB_DIRTY_MECHANIC ) ) return SendError( playerid, "You are not a dirty mechanic." ); - if ( isnull( params ) ) return SendUsage( playerid, "/(mech)anic [FIX/NOS/REMP/FLIP/FLIX/PRICE/NEARBY]" ); + else if ( !IsPlayerJob( playerid, JOB_DIRTY_MECHANIC ) ) return SendError( playerid, "You are not a dirty mechanic." ); + else if ( IsPlayerBelowSeaLevel( playerid ) ) return SendError( playerid, "You cannot use this command while below sea level." ); + else if ( isnull( params ) ) return SendUsage( playerid, "/(mech)anic [FIX/NOS/REMP/FLIP/FLIX/PRICE/NEARBY]" ); else if ( strmatch( params, "fix" ) ) { if ( p_AntiMechFixSpam[ playerid ] > g_iTime ) From b9066187e6ca89a86d7e658b95e920039ba1e650 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 00:02:36 -0500 Subject: [PATCH 04/13] removes player from player-owned Journeys when they disconnect --- .../cnr/features/minijobs/meth.pwn | 27 +++++++++++++++++++ .../cnr/features/vehicles/vehicles.pwn | 6 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn index 0a13c23..c6858f6 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn @@ -517,4 +517,31 @@ stock GetPlayerCausticSoda( playerid ) return p_CausticSoda{ playerid }; stock SetPlayerCausticSoda( playerid, amount ) { p_CausticSoda{ playerid } = amount; +} + +stock RemovePlayersFromJourney( vehicleID ) +{ + new Float: x, Float: y, Float: z; + + foreach ( new playerid : Player ) + { + if ( GetPlayerVirtualWorld( playerid ) == ( vehicleID + VW_METH ) && !p_Spectating{ playerid } ) + { + haltMethamphetamine( playerid, vehicleID ); + + GetVehiclePos( vehicleID, x, y, z ); + SetPlayerPos( playerid, x, y, z ); + SetPlayerInterior( playerid, 0 ); + SetPlayerVirtualWorld( playerid, 0 ); + + p_MuriaticAcid{ playerid } = 0; + p_CausticSoda{ playerid } = 0; + p_Methamphetamine{ playerid } = 0; + p_HydrogenChloride{ playerid } = 0; + + SendServerMessage( playerid, "You have been removed from a player-owned Journey as the player who owned it has left the server." ); + } + } + + return 1; } \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn b/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn index 0a053c2..c44197b 100644 --- a/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn +++ b/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn @@ -846,7 +846,11 @@ stock dischargeVehicles( playerid ) if ( p_OwnedVehicles[ playerid ] ) { for( new v; v < MAX_BUYABLE_VEHICLES; v++ ) - DestroyBuyableVehicle( playerid, v, .db_remove = false ); + { + if ( g_vehicleData[ playerid ][ v ][ E_MODEL ] == 508 ) RemovePlayersFromJourney( g_vehicleData[ playerid ][ v ][ E_VEHICLE_ID ] ); + DestroyBuyableVehicle( playerid, v, .db_remove = false ); + } + } return 1; } From 00beb4946685892a900ad5667fcb0e0289002f07 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 00:18:07 -0500 Subject: [PATCH 05/13] removes the ability for LEOs to purchase a chainsaw, while also reworking certain functions to make them more accessible for global use --- gamemodes/irresistible/anticheat/weapon.pwn | 30 ++++++++ gamemodes/irresistible/cnr/classes.pwn | 8 ++ .../irresistible/cnr/features/weapon_drop.pwn | 77 +++++++++++-------- gamemodes/sf-cnr.pwn | 3 + 4 files changed, 86 insertions(+), 32 deletions(-) diff --git a/gamemodes/irresistible/anticheat/weapon.pwn b/gamemodes/irresistible/anticheat/weapon.pwn index 503cfad..d1d8a48 100644 --- a/gamemodes/irresistible/anticheat/weapon.pwn +++ b/gamemodes/irresistible/anticheat/weapon.pwn @@ -49,6 +49,13 @@ hook OnPlayerDeath( playerid, killerid, reason ) return 1; } +hook OnPlayerUpdate( playerid ) +{ + if ( IsPlayerAnyLEO( playerid ) && CheckIfPlayerHasWeapon( playerid, 9 ) ) + RemoveSpecificPlayerWeapon( playerid, 9, false ); + return 1; +} + hook OnPlayerSpawn( playerid ) { if ( 0 <= playerid < MAX_PLAYERS ) @@ -300,3 +307,26 @@ stock AC_CreateDynamicPickup( modelid, type, Float: x, Float: y, Float: z, world #define _ALS_CreateDynamicPickup #endif #define CreateDynamicPickup AC_CreateDynamicPickup + +stock CheckIfPlayerHasWeapon( playerid, weaponid ) +{ + new + iCurrentWeapon = GetPlayerWeapon( playerid ), + iWeapon, + iAmmo + ; + + if ( iCurrentWeapon == weaponid ) + return true; + else + { + for ( new iSlot = 0; iSlot < 13; iSlot++ ) + { + GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo ); + + if ( iWeapon == weaponid ) + return true; + } + return false; + } +} \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/classes.pwn b/gamemodes/irresistible/cnr/classes.pwn index e073361..9fc145d 100644 --- a/gamemodes/irresistible/cnr/classes.pwn +++ b/gamemodes/irresistible/cnr/classes.pwn @@ -489,3 +489,11 @@ stock IsPlayerPolice( playerid ) } return false; } + +stock IsPlayerAnyLEO( playerid ) +{ + if ( IsPlayerPolice( playerid ) || IsPlayerArmy( playerid ) || IsPlayerCIA( playerid ) || IsPlayerFBI( playerid ) ) + return true; + else + return false; +} \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/weapon_drop.pwn b/gamemodes/irresistible/cnr/features/weapon_drop.pwn index 25ab57b..10f8cf5 100644 --- a/gamemodes/irresistible/cnr/features/weapon_drop.pwn +++ b/gamemodes/irresistible/cnr/features/weapon_drop.pwn @@ -317,42 +317,12 @@ CMD:dropweapon( playerid, params[ ] ) { if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." ); new - iCurrentWeapon = GetPlayerWeapon( playerid ), - iWeaponID[ 13 ], - iWeaponAmmo[ 13 ] + iCurrentWeapon = GetPlayerWeapon( playerid ) ; if ( iCurrentWeapon != 0 ) { - for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) - { - new - iWeapon, - iAmmo; - - GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo ); - - if ( iWeapon != iCurrentWeapon ) { - GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] ); - } - else - { - new - Float: X, Float: Y, Float: Z; - - if ( GetPlayerPos( playerid, X, Y, Z ) && CreateWeaponPickup( iWeapon, iAmmo, iSlot, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, GetServerTime( ) + 120, .nonpassive_only = false ) != ITER_NONE ) { - p_PlayerPickupDelay[ playerid ] = GetServerTime( ) + 3; - } - } - } - - ResetPlayerWeapons( playerid ); - - for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) { - GivePlayerWeapon( playerid, iWeaponID[ iSlot ], 0 <= iWeaponAmmo[ iSlot ] < 16384 ? iWeaponAmmo[ iSlot ] : 16384 ); - } - - SetPlayerArmedWeapon( playerid, 0 ); // prevent driveby + RemoveSpecificPlayerWeapon( playerid, iCurrentWeapon, true ); return SendServerMessage( playerid, "You have dropped your weapon." ); } else { return SendError( playerid, "You are not holding any weapon." ); @@ -439,3 +409,46 @@ stock ClearInactiveWeaponDrops( ) } return 1; } + +stock RemoveSpecificPlayerWeapon( playerid, weaponid, bool:createpickup ) +{ + new + iCurrentWeapon = GetPlayerWeapon( playerid ), + iWeaponID[ 13 ], + iWeaponAmmo[ 13 ] + ; + + if ( iCurrentWeapon != 0 ) + { + for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) + { + new + iWeapon, + iAmmo; + + GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo ); + + if ( iWeapon != iCurrentWeapon || iWeapon != weaponid ) { + GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] ); + } + else if ( createpickup ) + { + new + Float: X, Float: Y, Float: Z; + + if ( GetPlayerPos( playerid, X, Y, Z ) && CreateWeaponPickup( iWeapon, iAmmo, iSlot, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, GetServerTime( ) + 120, .nonpassive_only = false ) != ITER_NONE ) { + p_PlayerPickupDelay[ playerid ] = GetServerTime( ) + 3; + } + } + } + + ResetPlayerWeapons( playerid ); + + for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) { + GivePlayerWeapon( playerid, iWeaponID[ iSlot ], 0 <= iWeaponAmmo[ iSlot ] < 16384 ? iWeaponAmmo[ iSlot ] : 16384 ); + } + + SetPlayerArmedWeapon( playerid, 0 ); // prevent driveby + } + return 1; +} \ No newline at end of file diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index a831457..b0e4335 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -5039,6 +5039,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) case 17 .. 22: weaponid = listitem - 12; case 23 .. 24: weaponid = listitem - 9; } + if ( IsPlayerAnyLEO( playerid ) && weaponid == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." ); GivePlayerWeapon( playerid, weaponid, 0xFFFF ); SendServerMessage( playerid, "You have redeemed a %s.", ReturnWeaponName( weaponid ) ); p_VIPWeaponRedeem[ playerid ] = g_iTime + ( p_VIPLevel[ playerid ] == VIP_PLATINUM ? 60 : 300 ); @@ -5566,6 +5567,8 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) { if ( x == listitem ) { + // Chainsaw Removal for LEO through Ammunation + if ( IsPlayerAnyLEO( playerid ) && g_AmmunationWeapons[ i ] [ E_WEPID ] == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." ); if ( g_AmmunationWeapons[ i ] [ E_PRICE ] > GetPlayerCash( playerid ) ) { SendError( playerid, "You don't have enough money for this." ); From 3a5a562b8e224cb7515e0f6b8d88ae5463e7ad60 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 01:04:20 -0500 Subject: [PATCH 06/13] adjusts passives with association to wanted players and vehicles, including some fixes --- .../cnr/features/passive_mode.pwn | 53 +++++++++++++++++++ gamemodes/irresistible/cnr/wanted_level.pwn | 25 ++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/passive_mode.pwn b/gamemodes/irresistible/cnr/features/passive_mode.pwn index 99a8ce7..4103024 100644 --- a/gamemodes/irresistible/cnr/features/passive_mode.pwn +++ b/gamemodes/irresistible/cnr/features/passive_mode.pwn @@ -22,6 +22,14 @@ hook OnPlayerUpdateEx( playerid ) if ( p_AntiSpawnKillEnabled{ playerid } && g_iTime > p_AntiSpawnKill[ playerid ] ) { DisablePlayerSpawnProtection( playerid ); } + if ( GetPlayerWantedLevel( playerid ) > 0 ) + { + if ( IsPassivePlayerInVehicle( GetPlayerVehicleID( playerid ) ) ) + { + RemovePlayerFromVehicle( playerid ); + SendError( playerid, "You cannot enter vehicles with passive players in it as a wanted criminal." ); + } + } return 1; } @@ -69,7 +77,52 @@ hook OnPlayerUnjailed( playerid, reasonid ) return 1; } +hook OnPlayerEnterVehicle( playerid, vehicleid, ispassenger ) +{ + + if ( IsPlayerPassive( playerid ) ) + { + if ( IsWantedPlayerInVehicle( vehicleid ) ) + { + SetPlayerWantedLevel( playerid, 6 ); + ShowPlayerHelpDialog( playerid, 3000, "You are now considered wanted for associating yourself with a wanted player." ); + return 1; + } + } + return 1; + +} + /* ** Functions ** */ +stock GivePassivePassengersWanted( vehicleid ) +{ + foreach( new pID : Player ) + { + if ( !IsPlayerPassive( pID ) || !IsPlayerInAnyVehicle( pID ) ) + continue; + + if ( GetPlayerVehicleID( pID ) == vehicleid ) + { + SetPlayerWantedLevel( pID, 6 ); + ShowPlayerHelpDialog( pID, 3000, "You are now considered wanted for associating yourself with a wanted player." ); + } + } + return true; +} + +stock IsPassivePlayerInVehicle( vehicleid ) +{ + foreach ( new pID : Player ) + { + if ( !IsPlayerPassive( pID ) || !IsPlayerInAnyVehicle( pID ) ) + continue; + + if ( GetPlayerVehicleID( pID ) == vehicleid ) + return true; + } + return false; +} + stock DisablePlayerSpawnProtection( playerid ) { if ( p_AntiSpawnKillEnabled{ playerid } ) diff --git a/gamemodes/irresistible/cnr/wanted_level.pwn b/gamemodes/irresistible/cnr/wanted_level.pwn index 3eebc49..3252e2e 100644 --- a/gamemodes/irresistible/cnr/wanted_level.pwn +++ b/gamemodes/irresistible/cnr/wanted_level.pwn @@ -50,6 +50,11 @@ stock CNR_SetPlayerWantedLevel( playerid, level ) ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // remove passive mode if the player is wanted } } + else if ( IsPlayerInAnyVehicle( playerid ) ) + { + new vehicleID = GetPlayerVehicleID( playerid ); + GivePassivePassengersWanted( vehicleID ); + } else { PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); @@ -76,7 +81,12 @@ stock GivePlayerWantedLevel( playerid, level ) { if ( ! IsPlayerConnected( playerid ) || IsPlayerNPC( playerid ) || IsPlayerJailed( playerid ) || IsPlayerDueling( playerid ) || level == 0 ) return 0; - + else if ( IsPlayerInAnyVehicle( playerid ) ) + { + new vehicleID = GetPlayerVehicleID( playerid ); + GivePassivePassengersWanted( vehicleID ); + } + new current_wanted = GetPlayerWantedLevel( playerid ); @@ -91,4 +101,17 @@ stock ClearPlayerWantedLevel( playerid ) p_WantedLevel[ playerid ] = 0; SetPlayerWantedLevel( playerid, 0 ); SetPlayerColorToTeam( playerid ); +} + +stock IsWantedPlayerInVehicle( vehicleid ) +{ + foreach ( new pID : Player ) + { + if ( !IsPlayerInAnyVehicle( pID ) ) + continue; + + if ( GetPlayerVehicleID( pID ) == vehicleid && GetPlayerWantedLevel( pID ) > 1 ) + return true; + } + return false; } \ No newline at end of file From 0291b7ddecb39457c15550b27edf89be2b624239 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 01:33:31 -0500 Subject: [PATCH 07/13] removes the ability for passive players to enter business vehicles --- gamemodes/irresistible/cnr/features/business/business.pwn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gamemodes/irresistible/cnr/features/business/business.pwn b/gamemodes/irresistible/cnr/features/business/business.pwn index de0c59e..c16d9f7 100644 --- a/gamemodes/irresistible/cnr/features/business/business.pwn +++ b/gamemodes/irresistible/cnr/features/business/business.pwn @@ -506,6 +506,13 @@ hook OnPlayerDriveVehicle( playerid, vehicleid ) { if ( g_isBusinessVehicle[ vehicleid ] != -1 && Iter_Contains( business, g_isBusinessVehicle[ vehicleid ] ) ) { + if ( IsPlayerPassive( playerid ) ) + { + ShowPlayerHelpDialog( playerid, 2000, "Passive players cannot enter business vehicles." ); + RemovePlayerFromVehicle( playerid ); + return 1; + } + new businessid = g_isBusinessVehicle[ vehicleid ]; From 8e7e3ce2b8be4119f997b9c74fd54a27ac6b3bc4 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 02:47:01 -0500 Subject: [PATCH 08/13] adds awarding nearest leo whenever quit to avoid or afk wanted, adds checkpoint checks to ensure no-one goes into an interior to q to avoid --- .../irresistible/cnr/features/cop/arrest.pwn | 84 ++++++++++++++++++- gamemodes/sf-cnr.pwn | 8 +- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/cop/arrest.pwn b/gamemodes/irresistible/cnr/features/cop/arrest.pwn index bf3ff32..340a461 100644 --- a/gamemodes/irresistible/cnr/features/cop/arrest.pwn +++ b/gamemodes/irresistible/cnr/features/cop/arrest.pwn @@ -23,6 +23,9 @@ hook OnPlayerDisconnect( playerid, reason ) p_AwaitingBCAttempt{ playerid } = false; KillTimer( p_AwaitingBCAttemptTimer[ playerid ] ); p_AwaitingBCAttemptTimer[ playerid ] = -1; + + // Quit to Avoid - Award Handling + AwardNearestLEO( playerid, 0 ); return 1; } @@ -317,6 +320,24 @@ stock ArrestPlayer( victimid, playerid ) else return SendError( playerid, "There are no players around to arrest." ); } +stock AwardArrest( victimid, playerid ) +{ + p_QuitToAvoidTimestamp[ playerid ] = 0; + new totalCash = ( p_WantedLevel[ victimid ] < MAX_WANTED_LVL ? p_WantedLevel[ victimid ] : MAX_WANTED_LVL ) * ( 300 ); + new totalSeconds = p_WantedLevel[ victimid ] * ( JAIL_SECONDS_MULTIPLIER ); + GivePlayerScore( playerid, 2 ); + GivePlayerExperience( playerid, E_POLICE ); + GivePlayerCash( playerid, totalCash ); + StockMarket_UpdateEarnings( E_STOCK_GOVERNMENT, totalCash, 0.1 ); + if ( totalCash > 20000 ) printf("[police arrest] %s -> %s - %s", ReturnPlayerName( playerid ), ReturnPlayerName( victimid ), cash_format( totalCash ) ); // 8hska7082bmahu + SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[ACHIEVE]{FFFFFF} You have earned "COL_GOLD"%s{FFFFFF} dollars and 2 score for arresting %s(%d)!", cash_format( totalCash ), ReturnPlayerName( victimid ), victimid ); + GameTextForPlayer( victimid, "~r~Busted!", 4000, 0 ); + CallLocalFunction( "OnPlayerArrested", "dddd", playerid, victimid, p_Arrests[ playerid ], 1 ); + GivePlayerSeasonalXP( victimid, -20.0 ); + JailPlayer( victimid, totalSeconds ); + return 1; +} + stock CuffPlayer( victimid, playerid ) { if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." ); @@ -467,4 +488,65 @@ stock BreakPlayerCuffs( playerid ) } } -function BreakPlayerCuffsAttempt( playerid ) return BreakPlayerCuffs( playerid ), 1; \ No newline at end of file +function BreakPlayerCuffsAttempt( playerid ) return BreakPlayerCuffs( playerid ), 1; + +stock AwardNearestLEO( playerid, reason ) +{ + new + Float: x, Float: y, Float: z, + closestLEO = INVALID_PLAYER_ID, + radius = ( IsPlayerInAnyVehicle( playerid ) ? 150 : 75 ); // If player is in a vehicle, increase radius due to ability to get farther quicker. + + GetPlayerPos( playerid, x, y, z ); + + foreach( new pID : Player ) + { + if ( p_Class[ pID ] != CLASS_POLICE ) continue; + + new Float: distance = GetDistanceBetweenPlayers( playerid, pID ); + + if ( distance < radius && distance < closestLEO ) + closestLEO = pID; + } + + if ( closestLEO != INVALID_PLAYER_ID ) + { + new reasonText[ 24 ]; + + switch ( reason ) + { + case 0: reasonText = "Q'ing to Avoid"; + case 1: reasonText = "being AFK while wanted"; + } + + AwardArrest( playerid, closestLEO ); + SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been awarded for the arrest on %s(%d) due to them "COL_LRED"%s.", ReturnPlayerName( closestLEO ), closestLEO, ReturnPlayerName( playerid ), playerid, reasonText ); + return true; + } + + return false; +} + +hook OnPlayerEnterDynamicCP( playerid, checkpointid ) +{ + if ( !p_InHouse[ playerid ] && GetPlayerWantedLevel( playerid ) > 2 ) + { + new Float: x, Float: y, Float: z; + + GetEntrancePos( checkpointid, x, y, z ); + + foreach ( new pID : Player ) + { + if ( p_Class[ pID ] != CLASS_POLICE ) continue; + + new Float: distance = GetPlayerDistanceFromPoint( pID, x, y, z ); + + if ( distance < 50 ) + { + p_QuitToAvoidTimestamp[ playerid ] = g_iTime + 30; + break; + } + } + } + return 1; +} \ No newline at end of file diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index b0e4335..27aeb3f 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -265,8 +265,12 @@ public OnServerUpdateTimer( ) { // AFK Jail if ( p_WantedLevel[ playerid ] >= 6 && p_InHouse[ playerid ] == -1 && !IsPlayerAdminOnDuty( playerid ) && !IsPlayerInEntrance( playerid, g_VIPLounge[ CITY_SF ] ) && !IsPlayerInEntrance( playerid, g_VIPLounge[ CITY_LV ] ) && !IsPlayerInEntrance( playerid, g_VIPLounge[ CITY_LS ] ) && !IsPlayerTied( playerid ) && !IsPlayerKidnapped( playerid ) && !IsPlayerCuffed( playerid ) && !IsPlayerTazed( playerid ) && IsPlayerSpawned( playerid ) ) { // && !IsPlayerDetained( playerid ) - JailPlayer( playerid, 60, 1 ); - SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for 60 seconds by the server "COL_LRED"[AFK Wanted]", ReturnPlayerName( playerid ), playerid ); + + if ( !AwardNearestLEO( playerid, 1 ) ) + { + JailPlayer( playerid, 60, 1 ); + SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for 60 seconds by the server "COL_LRED"[AFK Wanted]", ReturnPlayerName( playerid ), playerid ); + } } // AFK Admins From f14e571fb89d9c4733f8c86b4dc796fee97ae26b Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 02:50:27 -0500 Subject: [PATCH 09/13] fixes info pickup text type for meth van --- gamemodes/irresistible/cnr/features/info_pickups.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/info_pickups.pwn b/gamemodes/irresistible/cnr/features/info_pickups.pwn index 33d0b6a..81901f2 100644 --- a/gamemodes/irresistible/cnr/features/info_pickups.pwn +++ b/gamemodes/irresistible/cnr/features/info_pickups.pwn @@ -26,7 +26,7 @@ static stock { -2767.3765, 1257.077, 11.7703, 0xFFFF, "{FFFFFF}You can mine ores and store your ores in dunes for exportation! Grab the spade and hit the ore!" }, // Mining { 1954.71890, 1038.251, 992.859, 0xFFFF, "{FFFFFF}Test out your luck on the slot machines, maybe you might win the mega jackpot!" }, // Slots { 1955.69070, 1005.167, 992.468, 0xFFFF, "{FFFFFF}Roulette can payout up to $3.5M! Single bets return 35x your money whereas outside bets can return 2x to 3x!" }, // Roulette - { 2085.5896, 1239.4589, 414.745, 0xFFFF, "{FFFFFF}Buy materials at a co-nvience store and cook meth! Aim and shoot each ingredient to add them as you /meth cook!" } // Meth Cook + { 2085.5896, 1239.4589, 414.745, 0xFFFF, "{FFFFFF}Buy materials at a convience store and cook meth! Aim and shoot each ingredient to add them as you /meth cook!" } // Meth Cook } ; From 21455d399f60c1b04522787eb00afa1cce9d697f Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 03:15:38 -0500 Subject: [PATCH 10/13] fixes vipjob command to not allow non-job names to be inputted, updates updates.txt with recent commits --- gamemodes/sf-cnr.pwn | 2 +- scriptfiles/updates.txt | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 27aeb3f..c632b82 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2336,7 +2336,7 @@ CMD:vipjob( playerid, params[ ] ) if ( isnull( params ) ) return SendUsage( playerid, "/vipjob [PART OF JOB NAME]" ); - if ( ( iJob = GetJobIDFromName( params ) ) == 0xFE ) + if ( ( iJob = GetJobIDFromName( params ) ) == 0xFE || iJob < 0 || iJob > 7 ) return SendError( playerid, "You have entered an invalid job." ); if ( iJob != p_Job{ playerid } ) { diff --git a/scriptfiles/updates.txt b/scriptfiles/updates.txt index 242e9eb..13bc552 100644 --- a/scriptfiles/updates.txt +++ b/scriptfiles/updates.txt @@ -1,13 +1,16 @@ -(+) A percentage is showed in the top donor bar, which is the required total funding of the server for the month. -(+) Server features are shown to newly registered players. -(/) Breaking Cuffs is now at a 75% chance success rate. -(/) Jail Multiplier is now lowered from 3 to 2. -(/) /sm is no longer capped at a 90M transaction. -(/) /ic send limit has been increased from 5,000 to 10,000. -(/) Player money is saved on an inflow/outflow basis. Before, it saved only when you disconnected. -(/) You need 50 score to send private messages in the server. -(*) Bank Money changes now trigger it to be saved. Fixing IC & Stock selling issue. -(*) Fireworks purchasing is now functional and grants you the item upon purchase. -(*) Fixed issue with cop chat behaving abnormally. -(*) You cannot use /sync in jail. -(-) Knives have been removed due to abuse. \ No newline at end of file +(/) Weed is no longer taxed when bought or sold. (Kova) +(*) Quit to Avoid and AFK Wanted will now award the nearest LEO (75m On Foot, 150m In Vehicle). (Damen) +(*) Passive Mode Players are no longer able to enter Business Vehicles. (Damen) +(*) Passive Mode Players will now become wanted through association when interacting with wanted players. (Damen) +(*) Law Enforcement Officers are no longer able to purchase or obtain chainsaws. (Damen) +(*) When inside a player-owned Journey vehicle interior and the owner disconnects, you will be removed from the interior. (Damen) +(*) Info pickup text typo fixed. (Damen) +(*) /vipjob should no longer allow you to put in an incorrect job name and still take your money. (Damen) +(*) You can no longer use player-owned vehicle or dirty mechanic commands to allow your vehicle to drive underwater. (Damen) +(*) You can no longer relog to reset the Dirty Mechanic export timer restriction. (Damen) +(*) Removes the ability to send IC to administrators who are spectating you. (Damen) +(*) Removes the ability to farm IC by using animations. (Damen) +(*) You can no longer use animations while wearing a parachute to avoid fake deaths. (Damen) +(*) /spawn should now display beyond 60 homes. (Stev) +(*) Business production label should now display the correct amount of money. (Stev) +(*) Militia Ship should no longer be robbable through the wall. (Kova) \ No newline at end of file From 7278d113f5de1b1f670a50e4e17fb2fe14cce8d0 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 19:41:05 -0500 Subject: [PATCH 11/13] adjustments made per comments and testing --- gamemodes/irresistible/anticheat/weapon.pwn | 7 ----- gamemodes/irresistible/cnr/classes.pwn | 18 ++++++------ .../irresistible/cnr/features/animations.pwn | 11 +------- .../cnr/features/business/business.pwn | 2 +- .../irresistible/cnr/features/cop/arrest.pwn | 28 ++++++++----------- .../cnr/features/minijobs/meth.pwn | 18 ++++++++---- .../cnr/features/passive_mode.pwn | 6 ++-- .../cnr/features/vehicles/vehicles.pwn | 2 ++ gamemodes/irresistible/cnr/wanted_level.pwn | 7 ++--- .../config/migrations/_migrations.pwn | 2 +- gamemodes/sf-cnr.pwn | 9 ++---- 11 files changed, 46 insertions(+), 64 deletions(-) diff --git a/gamemodes/irresistible/anticheat/weapon.pwn b/gamemodes/irresistible/anticheat/weapon.pwn index d1d8a48..9de7aa1 100644 --- a/gamemodes/irresistible/anticheat/weapon.pwn +++ b/gamemodes/irresistible/anticheat/weapon.pwn @@ -49,13 +49,6 @@ hook OnPlayerDeath( playerid, killerid, reason ) return 1; } -hook OnPlayerUpdate( playerid ) -{ - if ( IsPlayerAnyLEO( playerid ) && CheckIfPlayerHasWeapon( playerid, 9 ) ) - RemoveSpecificPlayerWeapon( playerid, 9, false ); - return 1; -} - hook OnPlayerSpawn( playerid ) { if ( 0 <= playerid < MAX_PLAYERS ) diff --git a/gamemodes/irresistible/cnr/classes.pwn b/gamemodes/irresistible/cnr/classes.pwn index 9fc145d..1ae1da6 100644 --- a/gamemodes/irresistible/cnr/classes.pwn +++ b/gamemodes/irresistible/cnr/classes.pwn @@ -362,6 +362,16 @@ hook OnPlayerRequestSpawn( playerid ) return IsPlayerClassApproved( playerid ); } +hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) +{ + if( !IsPlayerNPC( playerid ) ) + { + if ( ( newkeys && KEY_FIRE ) && GetPlayerClass( playerid ) == CLASS_POLICE && GetPlayerWeapon( playerid ) == 9 ) + RemoveSpecificPlayerWeapon( playerid, 9, false ); + } + return 1; +} + stock IsPlayerClassApproved( playerid ) { // is logged in @@ -488,12 +498,4 @@ stock IsPlayerPolice( playerid ) } } return false; -} - -stock IsPlayerAnyLEO( playerid ) -{ - if ( IsPlayerPolice( playerid ) || IsPlayerArmy( playerid ) || IsPlayerCIA( playerid ) || IsPlayerFBI( playerid ) ) - return true; - else - return false; } \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/animations.pwn b/gamemodes/irresistible/cnr/features/animations.pwn index 0395be9..e05e872 100644 --- a/gamemodes/irresistible/cnr/features/animations.pwn +++ b/gamemodes/irresistible/cnr/features/animations.pwn @@ -362,7 +362,7 @@ stock CreateLoopingAnimation( playerid, animlib[ ], animname[ ], Float:Speed, lo else if ( IsPlayerAttachedObjectSlotUsed( playerid, 3 ) ) return SendError( playerid, "You cannot use this command since you're holding a stolen good." ); else if ( GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_DRIVER || GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_PASSENGER ) return SendError( playerid, "You cannot use this command since you're entering a vehicle." ); else if ( GetPlayerState( playerid ) == PLAYER_STATE_EXIT_VEHICLE ) return SendError( playerid, "You cannot use this command since you're exiting a vehicle." ); - else if ( IsPlayerWearingParachute( playerid ) ) return SendError( playerid, "You cannot use this command while wearing a parachute." ); + else if ( GetPlayerWeapon( playerid ) == 46 ) return SendError( playerid, "You cannot use this command while wearing a parachute." ); else { SetPlayerSpecialAction( playerid, 0 ); @@ -397,13 +397,4 @@ stock IsPlayingAnimation( playerid, const library[ ], const animation[ ] ) stock IsPlayerUsingAnimation( playerid ) { return p_InAnimation{ playerid }; -} - - -stock IsPlayerWearingParachute( playerid ) -{ - if ( GetPlayerWeapon( playerid ) == 46 ) - return true; - else - return false; } \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/business/business.pwn b/gamemodes/irresistible/cnr/features/business/business.pwn index c16d9f7..df1b4d6 100644 --- a/gamemodes/irresistible/cnr/features/business/business.pwn +++ b/gamemodes/irresistible/cnr/features/business/business.pwn @@ -509,7 +509,7 @@ hook OnPlayerDriveVehicle( playerid, vehicleid ) if ( IsPlayerPassive( playerid ) ) { ShowPlayerHelpDialog( playerid, 2000, "Passive players cannot enter business vehicles." ); - RemovePlayerFromVehicle( playerid ); + SyncObject( playerid ); return 1; } diff --git a/gamemodes/irresistible/cnr/features/cop/arrest.pwn b/gamemodes/irresistible/cnr/features/cop/arrest.pwn index 340a461..a385f3a 100644 --- a/gamemodes/irresistible/cnr/features/cop/arrest.pwn +++ b/gamemodes/irresistible/cnr/features/cop/arrest.pwn @@ -20,12 +20,13 @@ forward OnPlayerArrested( playerid, victimid, totalarrests, totalpeople ); /* ** Hooks ** */ hook OnPlayerDisconnect( playerid, reason ) { + p_AwaitingBCAttempt{ playerid } = false; KillTimer( p_AwaitingBCAttemptTimer[ playerid ] ); p_AwaitingBCAttemptTimer[ playerid ] = -1; // Quit to Avoid - Award Handling - AwardNearestLEO( playerid, 0 ); + if ( playerid != INVALID_PLAYER_ID ) AwardNearestLEO( playerid, 0 ); return 1; } @@ -492,22 +493,15 @@ function BreakPlayerCuffsAttempt( playerid ) return BreakPlayerCuffs( playerid ) stock AwardNearestLEO( playerid, reason ) { + if ( ! IsPlayerConnected( playerid ) || playerid == INVALID_PLAYER_ID ) + return false; + new - Float: x, Float: y, Float: z, closestLEO = INVALID_PLAYER_ID, - radius = ( IsPlayerInAnyVehicle( playerid ) ? 150 : 75 ); // If player is in a vehicle, increase radius due to ability to get farther quicker. + Float: radius = ( IsPlayerInAnyVehicle( playerid ) ? 150.0 : 75.0 ) // If player is in a vehicle, increase radius due to ability to get farther quicker. + ; - GetPlayerPos( playerid, x, y, z ); - - foreach( new pID : Player ) - { - if ( p_Class[ pID ] != CLASS_POLICE ) continue; - - new Float: distance = GetDistanceBetweenPlayers( playerid, pID ); - - if ( distance < radius && distance < closestLEO ) - closestLEO = pID; - } + closestLEO = GetClosestPlayerEx( playerid, CLASS_POLICE, radius ); if ( closestLEO != INVALID_PLAYER_ID ) { @@ -527,13 +521,13 @@ stock AwardNearestLEO( playerid, reason ) return false; } -hook OnPlayerEnterDynamicCP( playerid, checkpointid ) +hook OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ) { - if ( !p_InHouse[ playerid ] && GetPlayerWantedLevel( playerid ) > 2 ) + if ( GetPlayerWantedLevel( playerid ) > 2 ) { new Float: x, Float: y, Float: z; - GetEntrancePos( checkpointid, x, y, z ); + GetEntrancePos( entranceid, x, y, z ); foreach ( new pID : Player ) { diff --git a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn index c6858f6..a8360f9 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn @@ -69,6 +69,7 @@ static stock /* ** Forwards ** */ forward OnMethamphetamineCooking( playerid, vehicleid, last_chemical ); +forward OnPlayerVehicleDestroyed( playerid, slot ); /* ** Hooks ** */ hook OnPlayerDisconnect( playerid, reason ) @@ -341,6 +342,12 @@ public OnMethamphetamineCooking( playerid, vehicleid, last_chemical ) return 1; } +public OnPlayerVehicleDestroyed( playerid, slot ) +{ + if ( g_vehicleData[ playerid ][ slot ][ E_MODEL ] == 508 ) RemovePlayersFromJourney( g_vehicleData[ playerid ][ slot ][ E_VEHICLE_ID ] ); + return 1; +} + /* ** Commands ** */ CMD:meth( playerid, params[ ] ) { @@ -521,7 +528,7 @@ stock SetPlayerCausticSoda( playerid, amount ) { stock RemovePlayersFromJourney( vehicleID ) { - new Float: x, Float: y, Float: z; + new Float: x, Float: y, Float: z, Float: Angle; foreach ( new playerid : Player ) { @@ -530,14 +537,13 @@ stock RemovePlayersFromJourney( vehicleID ) haltMethamphetamine( playerid, vehicleID ); GetVehiclePos( vehicleID, x, y, z ); + GetVehicleZAngle( vehicleID, Angle ); + x += ( 5.0 * floatsin( -( Angle - 45.0 ), degrees ) ); + y += ( 5.0 * floatcos( -( Angle - 45.0 ), degrees ) ); + SetPlayerPos( playerid, x, y, z ); SetPlayerInterior( playerid, 0 ); SetPlayerVirtualWorld( playerid, 0 ); - - p_MuriaticAcid{ playerid } = 0; - p_CausticSoda{ playerid } = 0; - p_Methamphetamine{ playerid } = 0; - p_HydrogenChloride{ playerid } = 0; SendServerMessage( playerid, "You have been removed from a player-owned Journey as the player who owned it has left the server." ); } diff --git a/gamemodes/irresistible/cnr/features/passive_mode.pwn b/gamemodes/irresistible/cnr/features/passive_mode.pwn index 4103024..a3f197d 100644 --- a/gamemodes/irresistible/cnr/features/passive_mode.pwn +++ b/gamemodes/irresistible/cnr/features/passive_mode.pwn @@ -26,7 +26,7 @@ hook OnPlayerUpdateEx( playerid ) { if ( IsPassivePlayerInVehicle( GetPlayerVehicleID( playerid ) ) ) { - RemovePlayerFromVehicle( playerid ); + SyncObject( playerid ); SendError( playerid, "You cannot enter vehicles with passive players in it as a wanted criminal." ); } } @@ -94,11 +94,11 @@ hook OnPlayerEnterVehicle( playerid, vehicleid, ispassenger ) } /* ** Functions ** */ -stock GivePassivePassengersWanted( vehicleid ) +stock GivePassivePassengersWanted( playerid, vehicleid ) { foreach( new pID : Player ) { - if ( !IsPlayerPassive( pID ) || !IsPlayerInAnyVehicle( pID ) ) + if ( !IsPlayerPassive( pID ) || IsPlayerNPC( pID ) || pID == playerid ) continue; if ( GetPlayerVehicleID( pID ) == vehicleid ) diff --git a/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn b/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn index c44197b..f8dc67a 100644 --- a/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn +++ b/gamemodes/irresistible/cnr/features/vehicles/vehicles.pwn @@ -723,6 +723,8 @@ stock DestroyBuyableVehicle( playerid, vID, bool: db_remove = true ) ResetBuyableVehicleMods( playerid, vID ); } + CallLocalFunction( "OnPlayerVehicleDestroyed", "dd", playerid, vID ); + // Reset vehicle component data (hook into module) DestroyVehicleCustomComponents( playerid, vID, db_remove ); diff --git a/gamemodes/irresistible/cnr/wanted_level.pwn b/gamemodes/irresistible/cnr/wanted_level.pwn index 3252e2e..0ef8f17 100644 --- a/gamemodes/irresistible/cnr/wanted_level.pwn +++ b/gamemodes/irresistible/cnr/wanted_level.pwn @@ -53,7 +53,7 @@ stock CNR_SetPlayerWantedLevel( playerid, level ) else if ( IsPlayerInAnyVehicle( playerid ) ) { new vehicleID = GetPlayerVehicleID( playerid ); - GivePassivePassengersWanted( vehicleID ); + GivePassivePassengersWanted( playerid, vehicleID ); } else { @@ -84,7 +84,7 @@ stock GivePlayerWantedLevel( playerid, level ) else if ( IsPlayerInAnyVehicle( playerid ) ) { new vehicleID = GetPlayerVehicleID( playerid ); - GivePassivePassengersWanted( vehicleID ); + GivePassivePassengersWanted( playerid, vehicleID ); } new @@ -107,9 +107,6 @@ stock IsWantedPlayerInVehicle( vehicleid ) { foreach ( new pID : Player ) { - if ( !IsPlayerInAnyVehicle( pID ) ) - continue; - if ( GetPlayerVehicleID( pID ) == vehicleid && GetPlayerWantedLevel( pID ) > 1 ) return true; } diff --git a/gamemodes/irresistible/config/migrations/_migrations.pwn b/gamemodes/irresistible/config/migrations/_migrations.pwn index e49ebad..de1239d 100644 --- a/gamemodes/irresistible/config/migrations/_migrations.pwn +++ b/gamemodes/irresistible/config/migrations/_migrations.pwn @@ -55,7 +55,7 @@ public Migrations_CheckMissing( ) new num_migrations = Migrations_GetCount( ); - if ( executed_migrations < num_migrations ) + if ( executed_migrations != num_migrations ) { new dir: migrations_directory = dir_open( SERVER_MIGRATIONS_FOLDER ), diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index c632b82..fd90e66 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -5043,7 +5043,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) case 17 .. 22: weaponid = listitem - 12; case 23 .. 24: weaponid = listitem - 9; } - if ( IsPlayerAnyLEO( playerid ) && weaponid == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." ); + if ( GetPlayerClass( playerid ) == CLASS_POLICE && weaponid == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." ); GivePlayerWeapon( playerid, weaponid, 0xFFFF ); SendServerMessage( playerid, "You have redeemed a %s.", ReturnWeaponName( weaponid ) ); p_VIPWeaponRedeem[ playerid ] = g_iTime + ( p_VIPLevel[ playerid ] == VIP_PLATINUM ? 60 : 300 ); @@ -5572,7 +5572,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) if ( x == listitem ) { // Chainsaw Removal for LEO through Ammunation - if ( IsPlayerAnyLEO( playerid ) && g_AmmunationWeapons[ i ] [ E_WEPID ] == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." ); + if ( GetPlayerClass( playerid ) == CLASS_POLICE && g_AmmunationWeapons[ i ] [ E_WEPID ] == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." ); if ( g_AmmunationWeapons[ i ] [ E_PRICE ] > GetPlayerCash( playerid ) ) { SendError( playerid, "You don't have enough money for this." ); @@ -7162,8 +7162,5 @@ stock IsPlayerBelowSeaLevel( playerid ) GetPlayerPos( playerid, x, y, z ); - if ( z < 0.0 ) - return true; - else - return false; + return z < 0.0; } \ No newline at end of file From f66b4069a1c54c3311d299fc5dd9dc5e1600f249 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 19:48:35 -0500 Subject: [PATCH 12/13] adds the anti-q-to-avoid system to emp attempts --- gamemodes/sf-cnr.pwn | 2 ++ scriptfiles/updates.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index fd90e66..29e3b6e 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2710,12 +2710,14 @@ CMD:emp( playerid, params[ ] ) { SendClientMessage( playerid, -1, ""COL_RED"[EMP]{FFFFFF} An Electromagnetic Pulse attempt has been repelled by an aluminum foil!" ); SendClientMessage( pID, -1, ""COL_GREEN"[EMP]{FFFFFF} Electromagnetic Pulse had been repelled by aluminum foil set on vehicle." ); + p_QuitToAvoidTimestamp[ pID ] = g_iTime + 15; return 1; } } SendClientMessageFormatted( pID, -1, ""COL_RED"[EMP]{FFFFFF} %s(%d) has sent an electromagnetic pulse on your vehicle causing it to crash for 30 seconds.", ReturnPlayerName( playerid ), playerid ); SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[EMP]{FFFFFF} You have activated a electromagnetic pulse on %s(%d)'s vehicle!", ReturnPlayerName( pID ), pID ); + p_QuitToAvoidTimestamp[ pID ] = g_iTime + 15; SetTimerEx( "emp_deactivate", 30000, false, "d", GetPlayerVehicleID( pID ) ); GetVehicleParamsEx( iVehicle, engine, lights, alarm, doors, bonnet, boot, objective ); SetVehicleParamsEx( iVehicle, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective ); diff --git a/scriptfiles/updates.txt b/scriptfiles/updates.txt index 13bc552..8930e30 100644 --- a/scriptfiles/updates.txt +++ b/scriptfiles/updates.txt @@ -11,6 +11,7 @@ (*) Removes the ability to send IC to administrators who are spectating you. (Damen) (*) Removes the ability to farm IC by using animations. (Damen) (*) You can no longer use animations while wearing a parachute to avoid fake deaths. (Damen) +(*) EMPs now trigger the anti-Q to avoid system to punish those who attempt to evade LEOs. (Damen) (*) /spawn should now display beyond 60 homes. (Stev) (*) Business production label should now display the correct amount of money. (Stev) (*) Militia Ship should no longer be robbable through the wall. (Kova) \ No newline at end of file From ca0c93bb37af8bbeb10dbe89b64166df19806bbe Mon Sep 17 00:00:00 2001 From: Damen Date: Sat, 26 Jan 2019 22:45:00 -0500 Subject: [PATCH 13/13] more adjustments based on comments --- gamemodes/irresistible/anticheat/weapon.pwn | 25 +------------------ .../irresistible/cnr/features/cop/arrest.pwn | 3 ++- .../irresistible/cnr/features/weapon_drop.pwn | 3 ++- gamemodes/sf-cnr.pwn | 4 +-- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/gamemodes/irresistible/anticheat/weapon.pwn b/gamemodes/irresistible/anticheat/weapon.pwn index 9de7aa1..3b34b83 100644 --- a/gamemodes/irresistible/anticheat/weapon.pwn +++ b/gamemodes/irresistible/anticheat/weapon.pwn @@ -299,27 +299,4 @@ stock AC_CreateDynamicPickup( modelid, type, Float: x, Float: y, Float: z, world #else #define _ALS_CreateDynamicPickup #endif -#define CreateDynamicPickup AC_CreateDynamicPickup - -stock CheckIfPlayerHasWeapon( playerid, weaponid ) -{ - new - iCurrentWeapon = GetPlayerWeapon( playerid ), - iWeapon, - iAmmo - ; - - if ( iCurrentWeapon == weaponid ) - return true; - else - { - for ( new iSlot = 0; iSlot < 13; iSlot++ ) - { - GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo ); - - if ( iWeapon == weaponid ) - return true; - } - return false; - } -} \ No newline at end of file +#define CreateDynamicPickup AC_CreateDynamicPickup \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/cop/arrest.pwn b/gamemodes/irresistible/cnr/features/cop/arrest.pwn index a385f3a..913aeac 100644 --- a/gamemodes/irresistible/cnr/features/cop/arrest.pwn +++ b/gamemodes/irresistible/cnr/features/cop/arrest.pwn @@ -503,7 +503,7 @@ stock AwardNearestLEO( playerid, reason ) closestLEO = GetClosestPlayerEx( playerid, CLASS_POLICE, radius ); - if ( closestLEO != INVALID_PLAYER_ID ) + if ( IsPlayerConnected( closestLEO ) ) { new reasonText[ 24 ]; @@ -525,6 +525,7 @@ hook OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ) { if ( GetPlayerWantedLevel( playerid ) > 2 ) { + new Float: x, Float: y, Float: z; GetEntrancePos( entranceid, x, y, z ); diff --git a/gamemodes/irresistible/cnr/features/weapon_drop.pwn b/gamemodes/irresistible/cnr/features/weapon_drop.pwn index 10f8cf5..6ae8f4f 100644 --- a/gamemodes/irresistible/cnr/features/weapon_drop.pwn +++ b/gamemodes/irresistible/cnr/features/weapon_drop.pwn @@ -431,7 +431,8 @@ stock RemoveSpecificPlayerWeapon( playerid, weaponid, bool:createpickup ) if ( iWeapon != iCurrentWeapon || iWeapon != weaponid ) { GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] ); } - else if ( createpickup ) + + if ( createpickup ) { new Float: X, Float: Y, Float: Z; diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 29e3b6e..4fb90d2 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -7160,9 +7160,9 @@ stock GetPlayerOutsidePos( playerid, &Float: X, &Float: Y, &Float: Z ) // gets t stock IsPlayerBelowSeaLevel( playerid ) { - new Float: x, Float: y, Float: z; + new Float: z; - GetPlayerPos( playerid, x, y, z ); + GetPlayerPos( playerid, z, z, z ); return z < 0.0; } \ No newline at end of file