From b182e49b2bbbe15b332ef33aee94a33c7da32d92 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 12 Oct 2018 21:39:20 +1100 Subject: [PATCH 1/4] drop money on death --- .../irresistible/cnr/features/weapon_drop.pwn | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/weapon_drop.pwn b/gamemodes/irresistible/cnr/features/weapon_drop.pwn index 0c735cd..b4c1ea3 100644 --- a/gamemodes/irresistible/cnr/features/weapon_drop.pwn +++ b/gamemodes/irresistible/cnr/features/weapon_drop.pwn @@ -20,6 +20,7 @@ #define WEAPON_HEALTH ( 100 ) #define WEAPON_ARMOUR ( 101 ) +#define WEAPON_MONEY ( 102 ) /* ** Variables ** */ enum E_WEAPONDROP_DATA { @@ -86,6 +87,22 @@ hook OnPlayerDeath( playerid, killerid, reason ) if ( killer_dm_level >= 10 ) { CreateWeaponPickup( WEAPON_HEALTH, killer_dm_level, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time ); } + + // money + new + player_money = GetPlayerCash( playerid ); + + if ( player_money ) + { + // half the amount lost through secure wallet + if ( p_SecureWallet{ playerid } ) { + player_money = floatround( float( player_money ) * 0.5 ); + } + + // reduce player money + GivePlayerCash( playerid, -player_money ); + CreateWeaponPickup( WEAPON_MONEY, player_money, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time ); + } } return 1; } @@ -122,6 +139,29 @@ hook OnPlayerPickUpDynPickup( playerid, pickupid ) SetPlayerHealth( playerid, health ); } } + else if ( g_weaponDropData[ dropid ] [ E_WEAPON_ID ] == WEAPON_HEALTH ) + { + new + Float: armour; + + if ( GetPlayerArmour( playerid, armour ) ) + { + // no weed like effects + if ( ( armour += float( g_weaponDropData[ dropid ] [ E_AMMO ] ) ) > 100.0 ) { + armour = 100.0; + } + + SetPlayerArmour( playerid, armour ); + } + } + else if ( g_weaponDropData[ dropid ] [ E_WEAPON_ID ] == WEAPON_MONEY ) + { + new + dropped_money = g_weaponDropData[ dropid ] [ E_AMMO ]; + + GivePlayerCash( playerid, dropped_money ); + SendServerMessage( playerid, "You have found "COL_GOLD"%s"COL_WHITE" on the ground.", cash_format( dropped_money ) ); + } else { new @@ -169,7 +209,23 @@ stock CreateWeaponPickup( weaponid, ammo, slotid, Float: X, Float: Y, Float: Z, if ( handle != ITER_NONE ) { - g_weaponDropData[ handle ] [ E_PICKUP ] = CreateDynamicPickup( weaponid == WEAPON_HEALTH ? 1240 : GetWeaponModel( weaponid ), 1, X, Y, Z ); + new + modelid; + + switch ( weaponid ) { + case WEAPON_HEALTH: modelid = 1240; + case WEAPON_MONEY: { + if ( ammo > 10000 ) { + modelid = 1550; + } else { + modelid = 1212; + } + } + case WEAPON_ARMOUR: modelid = 1242; + default: modelid = GetWeaponModel( weaponid ); + } + + g_weaponDropData[ handle ] [ E_PICKUP ] = CreateDynamicPickup( modelid, 1, X, Y, Z ); g_weaponDropData[ handle ] [ E_EXPIRE_TIMESTAMP ] = expire_time; g_weaponDropData[ handle ] [ E_WEAPON_ID ] = weaponid; g_weaponDropData[ handle ] [ E_AMMO ] = ammo; From 1cfe7cffe6cc93f7dcfae6efa452e8e496584dcd Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 16:10:06 +1100 Subject: [PATCH 2/4] weed dealers, 10g limit ... dealers can use it --- gamemodes/sf-cnr.pwn | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 242c9e2..7b1ed79 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -152,7 +152,7 @@ new ; /* ** Weed System ** */ -#define MAX_WEED_STORAGE 6 +#define MAX_WEED_STORAGE ( 10 ) #define MAX_WEED ( 42 ) enum E_WEED_DATA { @@ -5802,7 +5802,7 @@ CMD:weed( playerid, params[ ] ) else if ( strmatch( params, "collect" ) ) { if ( !IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You are not a drug dealer." ); - if ( p_WeedGrams[ playerid ] >= MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry " #MAX_WEED_STORAGE " grams of weed." ); + if ( p_WeedGrams[ playerid ] >= MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry %d grams of weed.", MAX_WEED_STORAGE ); if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You mustn't be inside a vehicle while collecting weed." ); new count = 0; @@ -5835,7 +5835,7 @@ CMD:weed( playerid, params[ ] ) else if ( pID == playerid ) return SendError( playerid, "You cannot sell yourself weed." ); else if ( p_Class[ pID ] != CLASS_CIVILIAN ) return SendError( playerid, "This person is not a civilian." ); else if ( iAmount > p_WeedGrams[ playerid ] ) return SendError( playerid, "You only have %d grams of weed on you.", p_WeedGrams[ playerid ] ); - else if ( iAmount < 1 || iAmount > MAX_WEED_STORAGE ) return SendError( playerid, "You can only sell between 1 to " #MAX_WEED_STORAGE " grams of weed to a player." ); + else if ( iAmount < 1 || iAmount > MAX_WEED_STORAGE ) return SendError( playerid, "You can only sell between 1 to %d grams of weed to a player.", MAX_WEED_STORAGE ); else if ( GetDistanceBetweenPlayers( playerid, pID ) < 5.0 ) { new @@ -5872,7 +5872,7 @@ CMD:weed( playerid, params[ ] ) else if ( p_Class[ dealerid ] != CLASS_CIVILIAN ) return p_WeedDealer[ playerid ] = INVALID_PLAYER_ID, SendError( playerid, "This deal has ended, the dealer is not a civilian." ); else if ( !IsPlayerJob( dealerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "Your dealer no longer does drugs." ); else if ( !p_WeedGrams[ dealerid ] ) return p_WeedDealer[ playerid ] = INVALID_PLAYER_ID, SendError( playerid, "Your dealer doesn't have any more weed." ); - else if ( ( p_WeedGrams[ playerid ] + iGrams ) > MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry " #MAX_WEED_STORAGE " grams of weed." ); + else if ( ( p_WeedGrams[ playerid ] + iGrams ) > MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry %d grams of weed.", MAX_WEED_STORAGE ); else { p_WeedGrams[ playerid ] += iGrams; @@ -5899,7 +5899,7 @@ CMD:weed( playerid, params[ ] ) if ( p_Jailed{ playerid } == true ) return SendError( playerid, "You cannot use this in jail." ); if ( IsPlayerLoadingObjects( playerid ) ) return SendError( playerid, "You're in a object-loading state, please wait." ); if ( IsPlayerAttachedObjectSlotUsed( playerid, 0 ) ) return SendError( playerid, "You cannot use this command since you're robbing." ); - if ( IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You cannot use your own products, they are for resale only!" ); + // if ( IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You cannot use your own products, they are for resale only!" ); if ( IsPlayerInEvent( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an event." ); //if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot use this command in a vehicle." ); //if ( GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_DRIVER || GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_PASSENGER ) return SendError( playerid, "You cannot use this command if you're entering a vehicle." ); From 749f52ca73ead1e7858968afc019d5cf85d3bf39 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 16:10:57 +1100 Subject: [PATCH 3/4] /dropmoney, /dropweapon ... 1% chance drop of armour when you die if ur dm lvl over 50 --- .../cnr/features/random_messages.pwn | 3 +- .../irresistible/cnr/features/weapon_drop.pwn | 137 +++++++++++++++--- 2 files changed, 117 insertions(+), 23 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/random_messages.pwn b/gamemodes/irresistible/cnr/features/random_messages.pwn index c9a858d..4e50ad8 100644 --- a/gamemodes/irresistible/cnr/features/random_messages.pwn +++ b/gamemodes/irresistible/cnr/features/random_messages.pwn @@ -70,7 +70,8 @@ static stock { "{8ADE47}Stephanie:"COL_WHITE" Contribute to our feature "COL_GREY"/crowdfunds"COL_WHITE"! Early supporters get benefits!" }, { "{8ADE47}Stephanie:"COL_WHITE" Don't want to be interrupted as an innocent player? Enter passive mode with "COL_GREY"/passive"COL_WHITE"!" }, { "{8ADE47}Stephanie:"COL_WHITE" You can buy premium player homes using "COL_GREY"/estate"COL_WHITE"!" }, - { "{8ADE47}Stephanie:"COL_WHITE" You can buy Irresistible Coins from players using "COL_GREY"/ic buy"COL_WHITE"!" } + { "{8ADE47}Stephanie:"COL_WHITE" You can buy Irresistible Coins from players using "COL_GREY"/ic buy"COL_WHITE"!" }, + { "{8ADE47}Stephanie:"COL_WHITE" Buy a secure wallet to reduce the amount of money you drop when you die!" } }, g_randomMessageTick = 0 ; diff --git a/gamemodes/irresistible/cnr/features/weapon_drop.pwn b/gamemodes/irresistible/cnr/features/weapon_drop.pwn index b4c1ea3..0367ecb 100644 --- a/gamemodes/irresistible/cnr/features/weapon_drop.pwn +++ b/gamemodes/irresistible/cnr/features/weapon_drop.pwn @@ -16,7 +16,7 @@ #define WEAPON_DROP_ENABLED /* ** Definitions ** */ -#define MAX_WEAPON_DROPS ( 50 ) +#define MAX_WEAPON_DROPS ( 100 ) #define WEAPON_HEALTH ( 100 ) #define WEAPON_ARMOUR ( 101 ) @@ -30,6 +30,7 @@ enum E_WEAPONDROP_DATA { static g_weaponDropData [ MAX_WEAPON_DROPS ] [ E_WEAPONDROP_DATA ]; static Iterator: weapondrop < MAX_WEAPON_DROPS >; +static p_PlayerPickupDelay [ MAX_PLAYERS ]; static g_HealthPickup; @@ -46,18 +47,16 @@ hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart ) hook OnPlayerDeath( playerid, killerid, reason ) #endif { - static - Float: X, Float: Y, Float: Z; + new Float: X, Float: Y, Float: Z; + new expire_time = GetServerTime( ) + 180; + + GetPlayerPos( playerid, X, Y, Z ); if ( IsPlayerConnected( killerid ) && ! IsPlayerNPC( killerid ) ) { if ( IsPlayerJailed( playerid ) || IsPlayerInPaintBall( playerid ) || IsPlayerInEvent( playerid ) || IsPlayerDueling( playerid ) ) return 1; - GetPlayerPos( playerid, X, Y, Z ); - - new - expire_time = GetServerTime( ) + 180; for ( new slotid = 0; slotid < 13; slotid++ ) { @@ -88,22 +87,30 @@ hook OnPlayerDeath( playerid, killerid, reason ) CreateWeaponPickup( WEAPON_HEALTH, killer_dm_level, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time ); } - // money - new - player_money = GetPlayerCash( playerid ); - - if ( player_money ) - { - // half the amount lost through secure wallet - if ( p_SecureWallet{ playerid } ) { - player_money = floatround( float( player_money ) * 0.5 ); - } - - // reduce player money - GivePlayerCash( playerid, -player_money ); - CreateWeaponPickup( WEAPON_MONEY, player_money, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time ); + // random armour drop (1% chance) + if ( killer_dm_level >= 50 && random( 101 ) == 66 ) { + CreateWeaponPickup( WEAPON_ARMOUR, killer_dm_level, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time ); } } + + // drop player money + new + player_money = floatround( float( GetPlayerCash( playerid ) ) * 0.25 ); + + if ( player_money > 0 ) + { + // half the amount lost through secure wallet + if ( p_SecureWallet{ playerid } ) { + player_money = floatround( float( player_money ) * 0.5 ); + } + + // message the player + ShowPlayerHelpDialog( playerid, 5000, "~w~You have dropped ~r~%s", cash_format( player_money ) ); + + // reduce player money + GivePlayerCash( playerid, -player_money ); + CreateWeaponPickup( WEAPON_MONEY, player_money, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time ); + } return 1; } @@ -119,6 +126,10 @@ hook OnPlayerPickUpDynPickup( playerid, pickupid ) return 1; } + // ignore if theres a delay + if ( p_PlayerPickupDelay[ playerid ] > GetServerTime( ) ) + return 1; + // Player Drops foreach ( new dropid : weapondrop ) { @@ -202,6 +213,88 @@ hook OnPlayerPickUpDynPickup( playerid, pickupid ) return 1; } +/* ** Commands ** */ +CMD:moneybag( playerid, params[ ] ) return cmd_dropmoney( playerid, params ); +CMD:dm( playerid, params[ ] ) return cmd_dropmoney( playerid, params ); +CMD:dropmoney( playerid, params[ ] ) +{ + new + money; + + if ( sscanf( params, "d", money ) ) return SendUsage( playerid, "/dropmoney [AMOUNT]" ); + else if ( money < 10000 ) return SendError( playerid, "The minimum amount you can drop is $10,000." ); + else if ( money > GetPlayerCash( playerid ) ) return SendError( playerid, "You do not have this much money on you." ); + else if ( GetPlayerVIPLevel( playerid ) < VIP_REGULAR ) return SendError( playerid, "You need to be V.I.P to use this, to become one visit "COL_GREY"donate.sfcnr.com" ); + else if ( GetPVarInt( playerid, "dropmoney_cooldown" ) > GetServerTime( ) ) return SendError( playerid, "You must wait %d seconds before using this command again.", GetPVarInt( playerid, "dropmoney_cooldown" ) - GetServerTime( ) ); + else + { + new + Float: X, Float: Y, Float: Z; + + GetPlayerPos( playerid, X, Y, Z ); + + if ( CreateWeaponPickup( WEAPON_MONEY, money, 0, X, Y, Z, GetServerTime( ) + 300 ) != ITER_NONE ) { + p_PlayerPickupDelay[ playerid ] = GetServerTime( ) + 4; + SendServerMessage( playerid, "You have dropped a %s money bag. It will expire in five minutes.", cash_format( money ) ); + GivePlayerCash( playerid, -money ); + Streamer_Update( playerid ); + SetPVarInt( playerid, "dropmoney_cooldown", GetServerTime( ) + 10 ); + } else { + SendError( playerid, "Failed to create a money bag. Try again in a little bit." ); + } + } + return 1; +} + +CMD:disposeweapon( playerid, params[ ] ) return cmd_dropweapon( playerid, params ); +CMD:dw( playerid, params[ ] ) return cmd_dropweapon( playerid, params ); +CMD:dropweapon( playerid, params[ ] ) { + + if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." ); + + new + iCurrentWeapon = GetPlayerWeapon( playerid ), + iWeaponID[ 13 ], + iWeaponAmmo[ 13 ] + ; + + if ( iCurrentWeapon != 0 ) + { + for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) + { + new + iWeapon, + iAmmo; + + GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo ); + + if ( iWeapon != iCurrentWeapon ) { + GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] ); + } + else + { + new + Float: X, Float: Y, Float: Z; + + if ( GetPlayerPos( playerid, X, Y, Z ) && CreateWeaponPickup( iWeapon, iAmmo, iSlot, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, GetServerTime( ) + 120 ) != ITER_NONE ) { + p_PlayerPickupDelay[ playerid ] = GetServerTime( ) + 3; + } + } + } + + ResetPlayerWeapons( playerid ); + + for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) { + GivePlayerWeapon( playerid, iWeaponID[ iSlot ], 0 <= iWeaponAmmo[ iSlot ] < 16384 ? iWeaponAmmo[ iSlot ] : 16384 ); + } + + SetPlayerArmedWeapon( playerid, 0 ); // prevent driveby + return SendServerMessage( playerid, "You have dropped your weapon." ); + } else { + return SendError( playerid, "You are not holding any weapon." ); + } +} + /* ** Functions ** */ stock CreateWeaponPickup( weaponid, ammo, slotid, Float: X, Float: Y, Float: Z, expire_time ) { @@ -215,7 +308,7 @@ stock CreateWeaponPickup( weaponid, ammo, slotid, Float: X, Float: Y, Float: Z, switch ( weaponid ) { case WEAPON_HEALTH: modelid = 1240; case WEAPON_MONEY: { - if ( ammo > 10000 ) { + if ( ammo >= 1000 ) { modelid = 1550; } else { modelid = 1212; From 0c467299d449346d3cc2423ede818291c9821c32 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 16:12:00 +1100 Subject: [PATCH 4/4] move dispose weapon to weapon_drop --- gamemodes/sf-cnr.pwn | 58 +++++++++----------------------------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 7b1ed79..ad878d2 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -3121,12 +3121,11 @@ public OnPlayerDeath( playerid, killerid, reason ) TextDrawHideForPlayer( playerid, g_currentXPTD ); HidePlayerTogglableTextdraws( playerid ); - /* ** Tax And Medical Fees ** */ + /* ** Tax And Medical Fees ** if ( GetPlayerTotalCash( playerid ) > 0 && ! ( IsPlayerInPaintBall( playerid ) || IsPlayerDueling( playerid ) || IsPlayerInEvent( playerid ) ) ) { ShowPlayerHelpDialog( playerid, 5000, sprintf( "~w~You have paid ~r~$100~w~ in medical fees" ) ); GivePlayerCash( playerid, -100 ); - } - /* ** End Of Tax And Medical Fees ** */ + } */ new playerGangId = p_GangID[ playerid ]; @@ -4352,45 +4351,6 @@ CMD:race( playerid, params[ ] ) return SendUsage( playerid, "/race [CREATE/INVITE/JOIN/LEAVE/KICK/CONFIG/START/CONTRIBUTE/STOP]" ); } -CMD:dw( playerid, params[ ] ) return cmd_disposeweapon( playerid, params ); -CMD:disposeweapon(playerid, params[]) { - - if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." ); - - new - iCurrentWeapon = GetPlayerWeapon( playerid ), - iWeaponID[ 13 ], - iWeaponAmmo[ 13 ] - ; - - if ( iCurrentWeapon != 0 ) - { - for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) - { - new - iWeapon, - iAmmo; - - GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo ); - - if ( iWeapon != iCurrentWeapon ) { - GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] ); - } - } - - ResetPlayerWeapons( playerid ); - - for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) { - GivePlayerWeapon( playerid, iWeaponID[ iSlot ], 0 <= iWeaponAmmo[ iSlot ] < 16384 ? iWeaponAmmo[ iSlot ] : 16384 ); - } - - SetPlayerArmedWeapon( playerid, 0 ); // prevent driveby - return SendServerMessage( playerid, "You have dropped your weapon." ); - } else { - return SendError( playerid, "You are not holding any weapon." ); - } -} - CMD:suggest( playerid, params[ ] ) return cmd_feedback( playerid, params ); CMD:feedback( playerid, params[ ] ) { @@ -15464,7 +15424,7 @@ stock getCurrentTime( ) } new - p_HideHelpDialogTimer[ MAX_PLAYERS ] = { 0xFFFF, ... }; + p_HideHelpDialogTimer[ MAX_PLAYERS ] = { -1, ... }; stock ShowPlayerHelpDialog( playerid, timeout, format[ ], va_args<> ) { @@ -15481,17 +15441,21 @@ stock ShowPlayerHelpDialog( playerid, timeout, format[ ], va_args<> ) PlayerTextDrawShow( playerid, p_HelpBoxTD[ playerid ] ); KillTimer( p_HideHelpDialogTimer[ playerid ] ); + p_HideHelpDialogTimer[ playerid ] = -1; - if ( timeout != 0 ) + if ( timeout != 0 ) { p_HideHelpDialogTimer[ playerid ] = SetTimerEx( "HidePlayerHelpDialog", timeout, false, "d", playerid ); - + } return 1; } function HidePlayerHelpDialog( playerid ) { - p_HideHelpDialogTimer[ playerid ] = 0xFFFF; - PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] ); + if ( p_HideHelpDialogTimer[ playerid ] != -1 ) + { + p_HideHelpDialogTimer[ playerid ] = -1; + PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] ); + } } stock fix_NightThermalVisionHack( playerid ) // Created by wups