adjusts passives with association to wanted players and vehicles, including some fixes

This commit is contained in:
Damen 2019-01-25 01:04:20 -05:00
parent 00beb49466
commit 3a5a562b8e
2 changed files with 77 additions and 1 deletions

View File

@ -22,6 +22,14 @@ hook OnPlayerUpdateEx( playerid )
if ( p_AntiSpawnKillEnabled{ playerid } && g_iTime > p_AntiSpawnKill[ playerid ] ) { if ( p_AntiSpawnKillEnabled{ playerid } && g_iTime > p_AntiSpawnKill[ playerid ] ) {
DisablePlayerSpawnProtection( 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; return 1;
} }
@ -69,7 +77,52 @@ hook OnPlayerUnjailed( playerid, reasonid )
return 1; 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 ** */ /* ** 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 ) stock DisablePlayerSpawnProtection( playerid )
{ {
if ( p_AntiSpawnKillEnabled{ playerid } ) if ( p_AntiSpawnKillEnabled{ playerid } )

View File

@ -50,6 +50,11 @@ stock CNR_SetPlayerWantedLevel( playerid, level )
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // remove passive mode if the player is wanted ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // remove passive mode if the player is wanted
} }
} }
else if ( IsPlayerInAnyVehicle( playerid ) )
{
new vehicleID = GetPlayerVehicleID( playerid );
GivePassivePassengersWanted( vehicleID );
}
else else
{ {
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
@ -76,7 +81,12 @@ stock GivePlayerWantedLevel( playerid, level )
{ {
if ( ! IsPlayerConnected( playerid ) || IsPlayerNPC( playerid ) || IsPlayerJailed( playerid ) || IsPlayerDueling( playerid ) || level == 0 ) if ( ! IsPlayerConnected( playerid ) || IsPlayerNPC( playerid ) || IsPlayerJailed( playerid ) || IsPlayerDueling( playerid ) || level == 0 )
return 0; return 0;
else if ( IsPlayerInAnyVehicle( playerid ) )
{
new vehicleID = GetPlayerVehicleID( playerid );
GivePassivePassengersWanted( vehicleID );
}
new new
current_wanted = GetPlayerWantedLevel( playerid ); current_wanted = GetPlayerWantedLevel( playerid );
@ -91,4 +101,17 @@ stock ClearPlayerWantedLevel( playerid )
p_WantedLevel[ playerid ] = 0; p_WantedLevel[ playerid ] = 0;
SetPlayerWantedLevel( playerid, 0 ); SetPlayerWantedLevel( playerid, 0 );
SetPlayerColorToTeam( playerid ); SetPlayerColorToTeam( playerid );
}
stock IsWantedPlayerInVehicle( vehicleid )
{
foreach ( new pID : Player )
{
if ( !IsPlayerInAnyVehicle( pID ) )
continue;
if ( GetPlayerVehicleID( pID ) == vehicleid && GetPlayerWantedLevel( pID ) > 1 )
return true;
}
return false;
} }