From 7278d113f5de1b1f670a50e4e17fb2fe14cce8d0 Mon Sep 17 00:00:00 2001 From: Damen Date: Fri, 25 Jan 2019 19:41:05 -0500 Subject: [PATCH] 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