2018-12-22 12:22:29 +00:00
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc
* Module: cnr\features\cop\arrest.pwn
* Purpose: taze, cuff and arresting system for police
*/
/* ** Includes ** */
#include < YSI\y_hooks >
2019-01-14 09:39:32 +00:00
/* ** Variables ** */
2019-05-31 10:12:13 +00:00
static const COP_ARREST_PAY_PER_WANTED = 330;
static const COP_DETAIN_PAY_PER_WANTED = 385;
2019-01-14 09:39:32 +00:00
2018-12-22 12:22:29 +00:00
/* ** Forwards ** */
forward OnPlayerArrested( playerid, victimid, totalarrests, totalpeople );
/* ** Hooks ** */
2019-01-14 09:39:32 +00:00
hook OnPlayerDisconnect( playerid, reason )
{
2019-01-25 07:47:01 +00:00
// Quit to Avoid - Award Handling
2019-02-25 11:52:29 +00:00
AwardNearestLEO( playerid, 0 );
2019-01-14 09:39:32 +00:00
return 1;
}
2019-04-12 00:59:05 +00:00
hook OnPlayerEnterDynamicCP( playerid, checkpointid )
2018-12-22 12:22:29 +00:00
{
// Detain Mechanism
2019-04-12 00:59:05 +00:00
if ( checkpointid == g_Checkpoints[ CP_DROP_OFF_COP ] ||
checkpointid == g_Checkpoints[ CP_DROP_OFF_FC ] || checkpointid == g_Checkpoints[ CP_DROP_OFF_DILLIMORE ] ||
checkpointid == g_Checkpoints[ CP_DROP_OFF_DIABLO ] || checkpointid == g_Checkpoints[ CP_DROP_OFF_QUBRADOS ] ||
checkpointid == g_Checkpoints[ CP_DROP_OFF_COP_LS ] || checkpointid == g_Checkpoints[ CP_DROP_OFF_FBI_LS ] ||
checkpointid == g_Checkpoints[ CP_DROP_OFF_FBI_LV ] || checkpointid == g_Checkpoints[ CP_DROP_OFF_COP_LV ] ||
2019-05-29 13:40:57 +00:00
checkpointid == g_Checkpoints[ CP_DROP_OFF_FBI ] || checkpointid == g_Checkpoints[ CP_DROP_OFF_HELI ] )
2018-12-22 12:22:29 +00:00
{
if ( p_Class[ playerid ] != CLASS_POLICE )
return 1;
new
iState = GetPlayerState( playerid ),
iVehicle = GetPlayerVehicleID( playerid )
;
if ( iState == PLAYER_STATE_DRIVER && iVehicle != 0 )
{
new
iDetained = 0, iCashEarned = 0;
foreach(new victimid : Player)
{
if ( victimid != playerid && p_WantedLevel[ victimid ] && p_Class[ victimid ] != CLASS_POLICE )
{
if ( IsPlayerInVehicle( victimid, iVehicle ) && IsPlayerDetained( victimid ) )
{
new
totalSeconds = p_WantedLevel[ victimid ] * ( JAIL_SECONDS_MULTIPLIER );
iDetained++;
2019-05-31 10:12:13 +00:00
iCashEarned += ( p_WantedLevel[ victimid ] < MAX_WANTED_LVL ? p_WantedLevel[ victimid ] : MAX_WANTED_LVL ) * ( COP_DETAIN_PAY_PER_WANTED );
2018-12-22 12:22:29 +00:00
KillTimer( p_CuffAbuseTimer[ victimid ] );
SetPlayerSpecialAction( victimid, SPECIAL_ACTION_NONE );
RemovePlayerAttachedObject( victimid, 2 );
TogglePlayerControllable( victimid, 1 );
p_Cuffed{ victimid } = false;
GameTextForPlayer( victimid, "~r~Busted!", 4000, 0 );
ClearAnimations( victimid );
JailPlayer( victimid, totalSeconds );
GivePlayerSeasonalXP( victimid, -2 );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has sent %s(%d) to jail for %d seconds!", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( victimid ), victimid, totalSeconds );
}
}
}
if ( iDetained )
{
if ( iCashEarned > 30000 )
printf("[police dropoff] %s -> %d people - %s", ReturnPlayerName( playerid ), iDetained, cash_format( iCashEarned ) ); // 8hska7082bmahu
GivePlayerCash( playerid, iCashEarned );
GivePlayerScore( playerid, iDetained * 2 );
CallLocalFunction( "OnPlayerArrested", "dddd", playerid, INVALID_PLAYER_ID, p_Arrests[ playerid ], iDetained );
return SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[ACHIEVE]{FFFFFF} You have earned "COL_GOLD"%s{FFFFFF} and %d score for dropping off %d criminal(s) to prison.", cash_format( iCashEarned ), iDetained * 2, iDetained );
}
else return SendError( playerid, "There are no detained criminals in your vehicle that can be jailed." );
}
else return SendError( playerid, "You need a driver of a vehicle with detained criminals to use this." );
}
return 1;
2019-04-12 00:59:05 +00:00
}
2018-12-22 12:22:29 +00:00
/* ** Commands ** */
CMD:taze( playerid, params[ ] )
{
2019-04-12 00:59:05 +00:00
new victimid;
2018-12-22 12:22:29 +00:00
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
2019-04-12 00:59:05 +00:00
else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/taze [PLAYER_ID]" );
else if ( victimid == playerid ) return SendError( playerid, "You cannot taze yourself." );
2018-12-22 12:22:29 +00:00
else if ( !IsPlayerConnected( victimid ) ) return SendError( playerid, "There are no players around to taze." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
2019-02-17 21:13:32 +00:00
else if ( IsPlayerInBattleRoyale( playerid ) ) return SendError( playerid, "You cannot use this command while in Battle Royale." );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 5.0 && IsPlayerConnected( victimid ) )
2018-12-22 12:22:29 +00:00
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "This player is in a vehicle " );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot do this while you're inside a vehicle." );
if ( IsPlayerTazed( victimid ) ) return SendError( playerid, "This player is already tazed." );
2019-04-06 02:05:20 +00:00
if ( IsPlayerDead( victimid ) ) return SendError( playerid, "This player is dead." );
2019-04-12 00:59:05 +00:00
if ( IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is already cuffed." );
if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is already detained." );
2018-12-22 12:22:29 +00:00
if ( IsPlayerGettingBlowed( playerid ) ) return SendError( playerid, "You cannot use this command since you're getting blowed." );
if ( IsPlayerBlowingCock( playerid ) ) return SendError( playerid, "You cannot use this command since you're giving oral sex." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You are kidnapped, you cannot do this." );
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You are tied, you cannot do this." );
if ( IsPlayerAdminOnDuty( victimid ) ) return SendError( playerid, "You cannot use this command on admins that are on duty." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command while in jail." );
if ( IsPlayerTied( victimid ) ) return SendError( playerid, "Tazing a tied player is pretty useless, though you can use /untie for a harder job!" );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
if ( p_TazingImmunity[ victimid ] > g_iTime ) return SendError( playerid, "You must wait %d seconds before tazing this player.", p_TazingImmunity[ victimid ] - g_iTime );
2019-05-29 13:40:57 +00:00
// event check
#if defined __cloudy_event_system
if ( IsPlayerInEvent( playerid ) && ! EventSettingAllow( EVENT_SETTING_KIDNAP ) )
#else
if ( IsPlayerInEvent( playerid ) )
#endif
{
return SendError( playerid, "You cannot use this command since you're in an event." );
}
2018-12-22 12:22:29 +00:00
if ( random( 101 ) < 90 )
{
GameTextForPlayer( victimid, "~n~~r~TAZED!", 2000, 4 );
GameTextForPlayer( playerid, "~n~~y~~h~/cuff", 2000, 4 );
2019-04-12 00:59:05 +00:00
SendClientMessageFormatted( victimid, -1, ""COL_RED"[TAZED]{FFFFFF} You have been tazed by %s(%d) for 5 seconds!", ReturnPlayerName( playerid ), playerid );
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[TAZED]{FFFFFF} You have tazed %s(%d) for 5 seconds!", ReturnPlayerName( victimid ), victimid );
SetTimerEx( "Untaze", 5000, false, "dd", victimid, 6 );
2018-12-22 12:22:29 +00:00
TogglePlayerControllable( victimid, 0 );
ApplyAnimation( victimid, "CRACK", "crckdeth2", 5.0, 1, 1, 1, 0, 0 );
p_Tazed{ victimid } = true;
}
else
{
SendClientMessageFormatted( playerid, -1, ""COL_RED"[TAZE FAIL]{FFFFFF} You have failed to taze %s(%d)!", ReturnPlayerName( victimid ), victimid );
SendClientMessageFormatted( victimid, -1, ""COL_GREEN"[TAZE FAIL]{FFFFFF} %s(%d) has failed to taze you!", ReturnPlayerName( playerid ), playerid );
}
p_TazingImmunity[ victimid ] = g_iTime + 6;
return 1;
} else {
return SendError( playerid, "There are no players around to taze." );
}
}
2019-04-12 00:59:05 +00:00
CMD:ar( playerid, params[ ] ) return cmd_arrest(playerid, params);
CMD:arrest( playerid, params[ ] )
2018-12-22 12:22:29 +00:00
{
2019-04-12 00:59:05 +00:00
new victimid;
2018-12-22 12:22:29 +00:00
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
else if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command since you're jailed." );
2019-04-12 00:59:05 +00:00
else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/ar(rest) [PLAYER_ID]" );
else if ( victimid == playerid ) return SendError( playerid, "You cannot arrest yourself." );
2018-12-22 12:22:29 +00:00
else if ( !IsPlayerConnected( victimid ) ) return SendError( playerid, "This player is not connected." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
2019-02-17 21:13:32 +00:00
else if ( IsPlayerInBattleRoyale( playerid ) ) return SendError( playerid, "You cannot use this command while in Battle Royale." );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
2018-12-22 12:22:29 +00:00
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( !IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is not cuffed." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You are kidnapped, you cannot do this." );
2019-04-06 02:05:20 +00:00
if ( IsPlayerDead( victimid ) ) return SendError( playerid, "This player is dead." );
2019-04-12 00:59:05 +00:00
if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is detained, you cannot arrest them." );
2018-12-22 12:22:29 +00:00
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You are tied, you cannot do this." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot arrest this person inside a vehicle." );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "You cannot arrest a person that is inside a vehicle." );
if ( IsPlayerAdminOnDuty( victimid ) ) return SendError( playerid, "You cannot use this command on admins that are on duty." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
2019-05-31 10:12:13 +00:00
new totalCash = ( p_WantedLevel[ victimid ] < MAX_WANTED_LVL ? p_WantedLevel[ victimid ] : MAX_WANTED_LVL ) * ( COP_ARREST_PAY_PER_WANTED );
2018-12-22 12:22:29 +00:00
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 );
Untaze( victimid, 6 );
GivePlayerSeasonalXP( victimid, -20.0 );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has sent %s(%d) to jail for %d seconds!", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( victimid ), victimid, totalSeconds );
JailPlayer( victimid, totalSeconds );
return 1;
}
else return SendError( playerid, "There are no players around to arrest." );
}
2019-04-12 00:59:05 +00:00
CMD:cuff( playerid, params[ ] )
2018-12-22 12:22:29 +00:00
{
2019-04-12 00:59:05 +00:00
new victimid;
2018-12-22 12:22:29 +00:00
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
else if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command since you're jailed." );
2019-04-12 00:59:05 +00:00
else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/cuff [PLAYER_ID]" );
else if ( victimid == playerid ) return SendError( playerid, "You cannot cuff yourself." );
2018-12-22 12:22:29 +00:00
else if ( !IsPlayerConnected( victimid ) || IsPlayerNPC( victimid ) ) return SendError( playerid, "This player is not connected." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
2019-02-17 21:13:32 +00:00
else if ( IsPlayerInBattleRoyale( playerid ) ) return SendError( playerid, "You cannot use this command while in Battle Royale." );
2018-12-22 12:22:29 +00:00
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( p_WantedLevel[ victimid ] < 6 ) return SendError( playerid, "This person isn't worth cuffing, ticket them." );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "This player is in a vehicle " );
2019-04-06 02:05:20 +00:00
if ( IsPlayerDead( victimid ) ) return SendError( playerid, "This player is dead." );
2019-04-12 00:59:05 +00:00
if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is already detained." );
2018-12-22 12:22:29 +00:00
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot do this while you're inside a vehicle." );
if ( IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is already cuffed." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( !IsPlayerTazed( victimid ) ) return SendError( playerid, "You must taze this player before cuffing them." );
if ( IsPlayerGettingBlowed( playerid ) ) return SendError( playerid, "You cannot use this command since you're getting blowed." );
if ( IsPlayerBlowingCock( playerid ) ) return SendError( playerid, "You cannot use this command since you're giving oral sex." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You are kidnapped, you cannot do this." );
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You are tied, you cannot do this." );
if ( IsPlayerAdminOnDuty( victimid ) ) return SendError( playerid, "You cannot use this command on admins that are on duty." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
if ( !IsPlayerSpawned( victimid ) ) return SendError( playerid, "The player must be spawned." );
2019-04-12 00:59:05 +00:00
GameTextForPlayer( victimid, "~n~~r~CUFFED!", 2000, 4 );
GameTextForPlayer( playerid, "~n~~y~~h~/arrest", 2000, 4 );
2019-01-13 06:07:16 +00:00
2019-04-12 00:59:05 +00:00
SendClientMessageFormatted( victimid, -1, ""COL_RED"[CUFFED]{FFFFFF} You have been cuffed by %s(%d)!", ReturnPlayerName( playerid ), playerid );
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} You have cuffed %s(%d)!", ReturnPlayerName( victimid ), victimid );
2019-01-13 06:07:16 +00:00
2019-04-12 00:59:05 +00:00
p_Cuffed{ victimid } = true;
p_QuitToAvoidTimestamp[ victimid ] = g_iTime + 3;
SetPlayerAttachedObject( victimid, 2, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000 );
SetPlayerSpecialAction( victimid, SPECIAL_ACTION_CUFFED );
2019-01-13 06:07:16 +00:00
2019-04-12 00:59:05 +00:00
KillTimer( p_CuffAbuseTimer[ victimid ] );
p_CuffAbuseTimer[ victimid ] = SetTimerEx( "Uncuff", ( 60 * 1000 ), false, "d", victimid );
2018-12-22 12:22:29 +00:00
return 1;
}
else return SendError( playerid, "There are no players around to cuff." );
2018-12-22 23:19:38 +00:00
}
2019-04-12 00:59:05 +00:00
CMD:uncuff( playerid, params[ ] )
{
new victimid;
if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/uncuff [PLAYER_ID]" );
else if ( victimid == playerid ) return SendError( playerid, "You cannot uncuff yourself." );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
{
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( !IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is not cuffed." );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot do this while you're inside a vehicle." );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You cannot use this command since you're tied." );
if ( IsPlayerTazed( playerid ) ) return SendError( playerid, "You cannot use this command since you're tazed." );
if ( IsPlayerCuffed( playerid ) ) return SendError( playerid, "You cannot use this command since you're cuffed." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You cannot use this command since you're kidnapped." );
if ( IsPlayerDetained( playerid ) ) return SendError( playerid, "You cannot use this command since you're detained." );
SendClientMessageFormatted( victimid, -1, ""COL_RED"[UNCUFFED]{FFFFFF} You have been uncuffed by %s(%d)!", ReturnPlayerName( playerid ), playerid );
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[UNCUFFED]{FFFFFF} You have uncuffed %s(%d)!", ReturnPlayerName( victimid ), victimid );
ClearAnimations( victimid );
TogglePlayerControllable( victimid, 1 );
p_Cuffed{ victimid } = false;
p_Detained{ victimid } = false;
Delete3DTextLabel( p_DetainedLabel[ victimid ] );
p_DetainedLabel[ victimid ] = Text3D: INVALID_3DTEXT_ID;
p_DetainedBy[ victimid ] = INVALID_PLAYER_ID;
KillTimer( p_CuffAbuseTimer[ victimid ] );
SetPlayerSpecialAction( victimid, SPECIAL_ACTION_NONE );
RemovePlayerAttachedObject( victimid, 2 );
}
else return SendError( playerid, "There are no players around to uncuff." );
return 1;
}
CMD:detain( playerid, params[ ] )
{
2019-04-14 16:42:54 +00:00
new victimid = GetClosestPlayer( playerid );
2019-04-12 00:59:05 +00:00
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
else if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command since you're jailed." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
2019-04-14 16:42:54 +00:00
//else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/detain [PLAYER_ID]" );
//else if ( victimid == playerid ) return SendError( playerid, "You cannot detain yourself." );
2019-04-12 00:59:05 +00:00
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player you're close to is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "This player is in a vehicle " );
if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is already detained." );
if ( !IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is not cuffed." );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot do this while you're inside a vehicle." );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( !IsValidVehicle( p_LastVehicle[ playerid ] ) ) return SendError( playerid, "Your last vehicle is either destroyed or not spawned." );
if ( PutPlayerInEmptyVehicleSeat( p_LastVehicle[ playerid ], victimid ) == -1 ) return SendError( playerid, "Failed to place the player inside a full of player vehicle." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
SendClientMessageFormatted( victimid, -1, ""COL_RED"[DETAIN]{FFFFFF} You have been detained by %s(%d)!", ReturnPlayerName( playerid ), playerid );
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[DETAIN]{FFFFFF} You have detained %s(%d), he's been put in your last vehicle!", ReturnPlayerName( victimid ), victimid );
KillTimer( p_CuffAbuseTimer[ victimid ] );
p_CuffAbuseTimer[ victimid ] = SetTimerEx( "Uncuff", ( 300 * 1000 ), false, "d", victimid );
p_Detained{ victimid } = true;
p_Tazed{ victimid } = false;
p_DetainedBy[ victimid ] = playerid;
p_TiedAtTimestamp[ victimid ] = g_iTime;
Delete3DTextLabel( p_DetainedLabel[ victimid ] );
p_DetainedLabel[ victimid ] = Create3DTextLabel( "Detained Criminal", COLOR_BLUE, 0.0, 0.0, 0.0, 15.0, 0 );
Attach3DTextLabelToPlayer( p_DetainedLabel[ victimid ], victimid, 0.0, 0.0, 0.6 );
TogglePlayerControllable( victimid, 0 );
}
else return SendError( playerid, "There are no players around to detain." );
return 1;
}
2019-04-17 23:29:27 +00:00
CMD:bc( playerid, params[ ] ) return cmd_breakcuffs(playerid, params);
CMD:breakcuffs( playerid, params[ ] )
{
2019-04-20 15:55:44 +00:00
return BreakPlayerCuffs( playerid ), 1;
2019-04-17 23:29:27 +00:00
}
2019-04-12 00:59:05 +00:00
/* ** Functions ** */
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;
}
2018-12-22 23:19:38 +00:00
function Untaze( playerid, taze_immunity_seconds )
{
if ( !IsPlayerConnected( playerid ) || !p_Tazed{ playerid } ) // || p_Detained{ playerid } == true
return 0;
if ( ! IsPlayerTied( playerid ) )
TogglePlayerControllable( playerid, 1 );
if ( GetPlayerSpecialAction( playerid ) != SPECIAL_ACTION_CUFFED )
SetPlayerSpecialAction( playerid, SPECIAL_ACTION_NONE );
ClearAnimations( playerid );
p_BulletInvulnerbility[ playerid ] = g_iTime + 3;
p_TazingImmunity[ playerid ] = g_iTime + taze_immunity_seconds;
p_Tazed{ playerid } = false;
return 1;
}
function Uncuff( playerid )
{
if ( !IsPlayerConnected( playerid ) || !IsPlayerCuffed( playerid ) || !IsPlayerAttachedObjectSlotUsed( playerid, 2 ) )
return 0;
TogglePlayerControllable( playerid, 1 );
RemovePlayerAttachedObject( playerid, 2 );
SetPlayerSpecialAction( playerid, SPECIAL_ACTION_NONE );
if ( !IsPlayerInAnyVehicle( playerid ) ) {
ClearAnimations( playerid );
}
p_Cuffed{ playerid } = false;
2019-04-12 00:59:05 +00:00
p_Detained{ playerid } = false;
Delete3DTextLabel( p_DetainedLabel[ playerid ] );
p_DetainedLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
p_DetainedBy[ playerid ] = INVALID_PLAYER_ID;
2018-12-22 23:19:38 +00:00
p_BulletInvulnerbility[ playerid ] = g_iTime + 5;
SendGlobalMessage( -1, ""COL_GREY"[SERVER]{FFFFFF} %s(%d) has been uncuffed and undetained by the anti-abuse system.", ReturnPlayerName( playerid ), playerid );
return 1;
2019-01-14 09:39:32 +00:00
}
stock BreakPlayerCuffs( playerid )
{
2019-04-06 02:05:20 +00:00
if ( !IsPlayerConnected( playerid ) || IsPlayerDead( playerid ) ) return false;
2019-01-14 09:39:32 +00:00
2019-04-17 23:29:27 +00:00
if ( !IsPlayerCuffed( playerid ) ) return SendError( playerid, "You are not cuffed." );
2019-01-14 09:39:32 +00:00
if ( p_BobbyPins[ playerid ] < 1 )
{
ShowPlayerHelpDialog( playerid, 4000, "You can buy bobby pins at Supa Save or a 24/7 store to break cuffs." );
return false;
}
else p_BobbyPins[ playerid ] --;
2019-04-18 04:24:12 +00:00
new probability = 50; // success rate probability
2019-01-14 09:39:32 +00:00
if ( random( 101 ) <= probability )
{
if ( ! IsPlayerCuffed( playerid ) )
{
Untaze( playerid, 10 );
GivePlayerWantedLevel( playerid, 6 );
}
else
{
if ( ! IsPlayerAttachedObjectSlotUsed( playerid, 2 ) )
return false;
TogglePlayerControllable( playerid, 1 );
RemovePlayerAttachedObject( playerid, 2 );
SetPlayerSpecialAction( playerid, SPECIAL_ACTION_NONE );
if ( ! IsPlayerInAnyVehicle( playerid ) ) {
ClearAnimations( playerid );
}
p_Cuffed{ playerid } = false;
p_BulletInvulnerbility[ playerid ] = g_iTime + 5;
2019-04-20 15:55:44 +00:00
p_Detained{ playerid } = false;
Delete3DTextLabel( p_DetainedLabel[ playerid ] );
p_DetainedLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
p_DetainedBy[ playerid ] = INVALID_PLAYER_ID;
2019-01-14 09:39:32 +00:00
}
SendServerMessage( playerid, "You have successfully broken out of your cuffs!" );
return true;
}
else
{
2019-04-17 23:29:27 +00:00
SendServerMessage( playerid, "You have snapped your bobby pin and failed to break out of your cuffs." );
2019-01-14 09:39:32 +00:00
return false;
}
}
2019-01-25 07:47:01 +00:00
stock AwardNearestLEO( playerid, reason )
{
2019-06-02 11:50:15 +00:00
#if defined __cloudy_event_system
if ( ! IsPlayerConnected( playerid ) || playerid == INVALID_PLAYER_ID || GetPlayerWantedLevel( playerid ) < 2 || ReturnPlayerHealth( playerid ) <= 0 || IsPlayerInEvent( playerid ) )
#else
if ( ! IsPlayerConnected( playerid ) || playerid == INVALID_PLAYER_ID || GetPlayerWantedLevel( playerid ) < 2 || ReturnPlayerHealth( playerid ) <= 0 )
#endif
2019-01-26 00:41:05 +00:00
return false;
2019-02-25 11:52:29 +00:00
new Float: radius = ( IsPlayerInAnyVehicle( playerid ) ? 150.0 : 75.0 ); // If player is in a vehicle, increase radius due to ability to get farther quicker.
2019-01-25 07:47:01 +00:00
2019-02-25 11:52:29 +00:00
new closestLEO = GetClosestPlayerEx( playerid, CLASS_POLICE, radius );
2019-01-25 07:47:01 +00:00
2019-03-01 22:15:14 +00:00
if ( IsPlayerConnected( closestLEO ) && !p_Spectating{ closestLEO } )
2019-01-25 07:47:01 +00:00
{
new reasonText[ 24 ];
switch ( reason )
{
2019-02-25 11:52:29 +00:00
case 0: reasonText = "Quit To Avoid";
case 1: reasonText = "AFK'd While Wanted";
2019-01-25 07:47:01 +00:00
}
AwardArrest( playerid, closestLEO );
2019-02-25 11:52:29 +00:00
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been awarded for the arrest on %s(%d) as they "COL_LRED"%s.", ReturnPlayerName( closestLEO ), closestLEO, ReturnPlayerName( playerid ), playerid, reasonText );
2019-01-25 07:47:01 +00:00
return true;
}
return false;
}
2019-01-26 00:41:05 +00:00
hook OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid )
2019-01-25 07:47:01 +00:00
{
2019-01-26 00:41:05 +00:00
if ( GetPlayerWantedLevel( playerid ) > 2 )
2019-01-25 07:47:01 +00:00
{
2019-01-27 03:45:00 +00:00
2019-01-25 07:47:01 +00:00
new Float: x, Float: y, Float: z;
2019-01-26 00:41:05 +00:00
GetEntrancePos( entranceid, x, y, z );
2019-01-25 07:47:01 +00:00
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;
2019-04-10 02:22:50 +00:00
}
hook OnPlayerUpdateEx( playerid )
{
if ( p_Class[ playerid ] == CLASS_POLICE && GetPlayerScore( playerid ) < 50 )
{
new
Float: radius = 25.0,
closestCivilian = GetClosestPlayerEx( playerid, CLASS_CIVILIAN, radius );
2019-04-10 17:27:53 +00:00
if ( closestCivilian != INVALID_PLAYER_ID && GetPlayerWantedLevel( closestCivilian ) != 0 )
2019-04-10 02:22:50 +00:00
{
return ShowPlayerHelpDialog( playerid, 4000, "Use ~y~/taze [ID]~w~, ~b~/cuff [ID]~w~, and ~r~/ar [ID] ~w~commands to arrest." );
}
}
return 1;
2019-06-02 11:50:15 +00:00
}