adjustments made per comments and testing

This commit is contained in:
Damen 2019-01-25 19:41:05 -05:00
parent 21455d399f
commit 7278d113f5
11 changed files with 46 additions and 64 deletions

View File

@ -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 )

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 )
{

View File

@ -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." );
}

View File

@ -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 )

View File

@ -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 );

View File

@ -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;
}

View File

@ -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 ),

View File

@ -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;
}