From 7eae2186a5d44b2e5a5d753ced8be22a80501cb5 Mon Sep 17 00:00:00 2001 From: Damen Date: Sun, 13 Jan 2019 01:07:16 -0500 Subject: [PATCH] reworks bc, fixes firework purchase, adjusts jail-multiplier --- .../irresistible/cnr/features/cop/arrest.pwn | 33 +++----- .../irresistible/cnr/features/cop/jail.pwn | 2 +- .../cnr/features/player_items/shop.pwn | 2 + gamemodes/irresistible/cnr/player.pwn | 2 + gamemodes/sf-cnr.pwn | 82 ++++++++++--------- 5 files changed, 59 insertions(+), 62 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/cop/arrest.pwn b/gamemodes/irresistible/cnr/features/cop/arrest.pwn index 634d91a..1662f3a 100644 --- a/gamemodes/irresistible/cnr/features/cop/arrest.pwn +++ b/gamemodes/irresistible/cnr/features/cop/arrest.pwn @@ -312,40 +312,29 @@ stock CuffPlayer( victimid, playerid ) 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." ); - new - break_attempts = 0; - - if ( ! BreakPlayerCuffs( victimid, break_attempts ) ) + if ( !BreakPlayerCuffs( victimid ) ) { GameTextForPlayer( victimid, "~n~~r~CUFFED!", 2000, 4 ); - //GameTextForPlayer( playerid, sprintf( "~n~~y~~h~/arrest %d", victimid ), 2000, 4 ); GameTextForPlayer( playerid, "~n~~y~~h~/arrest", 2000, 4 ); + 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 ); - KillTimer( p_CuffAbuseTimer[ victimid ] ); - p_CuffAbuseTimer[ victimid ] = SetTimerEx( "Uncuff", ( 60 * 1000 ), false, "d", victimid ); - //ApplyAnimation( victimid, "ped", "cower", 5.0, 1, 1, 1, 0, 0 ); - //TogglePlayerControllable( victimid, 0 ); + 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 ); - ShowPlayerHelpDialog( victimid, 4000, "You can buy bobby pins at Supa Save or a 24/7 store to break cuffs." ); + + KillTimer( p_CuffAbuseTimer[ victimid ] ); + p_CuffAbuseTimer[ victimid ] = SetTimerEx( "Uncuff", ( 60 * 1000 ), false, "d", victimid ); + + p_AwaitingBCAttempt[ victimid ] = true; + KillTimer( p_AwaitingBCAttemptTimer[ victimid ] ); + p_AwaitingBCAttemptTimer[ victimid ] = SetTimerEx( "BreakPlayerCuffsAttempt", 3000, false, "d", victimid ); } else { - if ( break_attempts ) - { - new - money_dropped = RandomEx( 200, 400 ) * break_attempts; - - SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} %s(%d) just broke their cuffs off, and dropped %s!", ReturnPlayerName( victimid ), victimid, cash_format( money_dropped ) ); - GivePlayerCash( playerid, money_dropped ); - } - else - { - SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} %s(%d) just broke their cuffs off!", ReturnPlayerName( victimid ), victimid ); - } + SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} %s(%d) just broke their cuffs off!", ReturnPlayerName( victimid ) ); } return 1; } diff --git a/gamemodes/irresistible/cnr/features/cop/jail.pwn b/gamemodes/irresistible/cnr/features/cop/jail.pwn index 1e052e5..7351cfe 100644 --- a/gamemodes/irresistible/cnr/features/cop/jail.pwn +++ b/gamemodes/irresistible/cnr/features/cop/jail.pwn @@ -9,7 +9,7 @@ #include < YSI\y_hooks > /* ** Definitions ** */ -#define JAIL_SECONDS_MULTIPLIER ( 3 ) +#define JAIL_SECONDS_MULTIPLIER ( 2 ) #define ALCATRAZ_REQUIRED_TIME ( 150 ) #define ALCATRAZ_TIME_PAUSE ( 5 ) diff --git a/gamemodes/irresistible/cnr/features/player_items/shop.pwn b/gamemodes/irresistible/cnr/features/player_items/shop.pwn index b56fcef..131cfe4 100644 --- a/gamemodes/irresistible/cnr/features/player_items/shop.pwn +++ b/gamemodes/irresistible/cnr/features/player_items/shop.pwn @@ -190,6 +190,7 @@ stock GetShopItemAmount( playerid, id ) case SHOP_ITEM_DRILL: return p_drillStrength[ playerid ]; case SHOP_ITEM_METAL_MELTER: return p_MetalMelter[ playerid ]; case SHOP_ITEM_WEED_SEED: return g_playerShopItems[ playerid ] [ SHOP_ITEM_WEED_SEED ]; + case SHOP_ITEM_FIREWORKS: return p_Fireworks[ playerid ]; } return 0; } @@ -211,6 +212,7 @@ stock SetPlayerShopItemAmount( playerid, id, value ) case SHOP_ITEM_DRILL: p_drillStrength[ playerid ] = value; case SHOP_ITEM_METAL_MELTER: p_MetalMelter[ playerid ] = value; case SHOP_ITEM_WEED_SEED: g_playerShopItems[ playerid ] [ SHOP_ITEM_WEED_SEED ] = value; + case SHOP_ITEM_FIREWORKS: p_Fireworks[ playerid ] = value; } return 1; } diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index 9020f91..d5cdf15 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -29,6 +29,8 @@ new bool: p_Tazed [ MAX_PLAYERS char ], p_LastVehicle [ MAX_PLAYERS ] = { INVALID_VEHICLE_ID, ... }, bool: p_Cuffed [ MAX_PLAYERS char ], + bool: p_AwaitingBCAttempt [ MAX_PLAYERS ], + p_AwaitingBCAttemptTimer [ MAX_PLAYERS ], p_CuffAbuseTimer [ MAX_PLAYERS ], p_AntiRobSpam [ MAX_PLAYERS ], p_AntiRapeSpam [ MAX_PLAYERS ], diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 53d9872..a68a691 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -515,6 +515,7 @@ public OnPlayerDisconnect( playerid, reason ) p_AntiEMP [ playerid ] = 0; p_LastVehicle [ playerid ] = INVALID_VEHICLE_ID; p_Cuffed { playerid } = false; + p_AwaitingBCAttempt[ playerid ] = false; justConnected { playerid } = true; p_Muted { playerid } = false; p_MetalMelter [ playerid ] = 0; @@ -593,6 +594,7 @@ public OnPlayerDisconnect( playerid, reason ) DestroyAllPlayerC4s( playerid, true ); KillTimer( p_JailTimer[ playerid ] ); KillTimer( p_CuffAbuseTimer[ playerid ] ); + KillTimer( p_AwaitingBCAttemptTimer[ playerid ] ); ResetPlayerCash( playerid ); if ( !GetPVarInt( playerid, "banned_connection" ) ) SendDeathMessage( INVALID_PLAYER_ID, playerid, 201 ); @@ -7102,55 +7104,57 @@ stock ShowPlayerSpawnMenu( playerid ) { return ShowPlayerDialog( playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST, "{FFFFFF}Spawn Location", ""COL_GREY"Reset Back To Default\nHouse\nBusiness\nGang Facility\nVisage Casino", "Select", "Cancel" ); } -stock BreakPlayerCuffs( playerid, &attempts = 0 ) +stock BreakPlayerCuffs( playerid ) { if ( p_BobbyPins[ playerid ] < 1 ) - return 0; - - new Float: police_percentage; - new bool: success = false; - - // get current police percentage - GetServerPoliceRatio( police_percentage ); - - // probability based off some factors - new probability = 15 + floatround( police_percentage, floatround_floor ); - - // attempt to uncuff - for ( attempts = 1; attempts < p_BobbyPins[ playerid ]; attempts ++ ) { - if ( random( 101 ) <= probability ) { // 35% success rate RIP! - success = true; - break; - } + 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 ]--; - if ( ( p_BobbyPins[ playerid ] -= attempts ) > 0 ) { - ShowPlayerHelpDialog( playerid, 5000, "You only have %d bobby pins left!", p_BobbyPins[ playerid ] ); - } + if ( p_AwaitingBCAttempt[ playerid ] ) p_AwaitingBCAttempt[ playerid ] = false; - if ( success ) { - /*TogglePlayerControllable( playerid, 1 ); - RemovePlayerAttachedObject( playerid, 2 ); - SetPlayerSpecialAction( playerid, SPECIAL_ACTION_NONE ); - if ( !IsPlayerInAnyVehicle( playerid ) ) { - ClearAnimations( playerid ); + new probability = 60; + + if ( random( 100 ) <= probability ) + { + if ( !IsPlayerCuffed( playerid ) ) + { + Untaze( playerid, 10 ); + GivePlayerWantedLevel( playerid, 6 ); } - p_Cuffed{ playerid } = false; - p_Tazed{ playerid } = false; - //p_Detained{ playerid } = false; - //Delete3DTextLabel( p_DetainedLabel[ playerid ] ); - //p_DetainedLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID; - //p_DetainedBy[ playerid ] = INVALID_PLAYER_ID;*/ - Untaze( playerid, 10 ); - SendServerMessage( playerid, "You have used %d bobby pins to successfully break your cuffs.", attempts ); - GivePlayerWantedLevel( playerid, 6 ); - } else { - SendError( playerid, "You snapped %d bobby pin(s) and failed to break out of your cuffs.", attempts ); + else + { + if ( !IsPlayerConnected( playerid ) || !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; + } + SendServerMessage( playerid, "You have successfully broken out of your cuffs!" ); + return true; + } + else + { + SendServerMessage( playerid, "You have snapped your bobby pin and failed to break out of your cuffs. Re-attempting in 3 seconds." ); + p_AwaitingBCAttempt[ playerid ] = true; + KillTimer( p_AwaitingBCAttemptTimer[ playerid ] ); + p_AwaitingBCAttemptTimer[ playerid ] = SetTimerEx( "BreakPlayerCuffsAttempt", 3000, false, "d", playerid ); + return false; } - return 1; } +function BreakPlayerCuffsAttempt( playerid ) return BreakPlayerCuffs( playerid ); + stock IsPlayerAFK( playerid ) return ( ( GetTickCount( ) - p_AFKTime[ playerid ] ) >= 2595 ); stock GetPlayerVIPDuration( playerid ) return p_VIPExpiretime[ playerid ] - g_iTime;