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

This commit is contained in:
Damen 2019-01-25 02:47:01 -05:00
parent 0291b7ddec
commit 8e7e3ce2b8
2 changed files with 89 additions and 3 deletions

View File

@ -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." );
@ -468,3 +489,64 @@ stock BreakPlayerCuffs( playerid )
}
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;
}

View File

@ -265,9 +265,13 @@ 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 )
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
if ( IsPlayerAdminOnDuty( playerid ) )