Implement Y keybind for quick arrest

This commit is contained in:
ChronosX88 2024-01-11 02:01:52 +03:00
parent 38f8cc460e
commit b47ffa3edc

View File

@ -88,6 +88,46 @@ hook OnPlayerEnterDynamicCP( playerid, checkpointid )
return 1;
}
hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
if( IsPlayerNPC( playerid ) ) return 1;
if ( PRESSED(KEY_YES) && AC_IsPlayerSpawned( playerid ) )
{
if ( p_AntiSpammyTS[ playerid ] > g_iTime ) return SendError( playerid, "Don't spam arrest key!");
if ( p_Class[ playerid ] != CLASS_POLICE ) return 1;
new victimid = GetClosestPlayer( playerid );
new params[16];
format(params, sizeof(params), "%d", victimid);
if (!IsPlayerTazed( victimid ) && !IsPlayerCuffed( victimid ))
{
cmd_taze(playerid, params);
} else if (!IsPlayerCuffed(victimid)) {
cmd_cuff(playerid, params);
} else {
cmd_arrest(playerid, params);
}
p_AntiSpammyTS[ playerid ] = g_iTime + 1;
}
return 1;
}
hook OnPlayerUpdateEx( playerid )
{
if ( p_Class[ playerid ] == CLASS_POLICE && GetPlayerScore( playerid ) < 50 )
{
new
Float: radius = 25.0,
closestCivilian = GetClosestPlayerEx( playerid, CLASS_CIVILIAN, radius );
if ( closestCivilian != INVALID_PLAYER_ID && GetPlayerWantedLevel( closestCivilian ) > 0 )
{
return ShowPlayerHelpDialog( playerid, 4000, "Use ~y~Y~w~ button to arrest." );
}
}
return 1;
}
/* ** Commands ** */
CMD:taze( playerid, params[ ] )
{
@ -497,19 +537,3 @@ hook OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid )
}
return 1;
}
hook OnPlayerUpdateEx( playerid )
{
if ( p_Class[ playerid ] == CLASS_POLICE && GetPlayerScore( playerid ) < 50 )
{
new
Float: radius = 25.0,
closestCivilian = GetClosestPlayerEx( playerid, CLASS_CIVILIAN, radius );
if ( closestCivilian != INVALID_PLAYER_ID && GetPlayerWantedLevel( closestCivilian ) != 0 )
{
return ShowPlayerHelpDialog( playerid, 4000, "Use ~y~/taze [ID]~w~, ~b~/cuff [ID]~w~, and ~r~/ar [ID] ~w~commands to arrest." );
}
}
return 1;
}