From 018f5f4e34ddd564ad2a30c00a2087d16239af2b Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sun, 16 Sep 2018 14:16:48 +0100 Subject: [PATCH 1/3] adds different cargo names and the risk level. --- .../cnr/features/minijobs/pilot.pwn | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn index fa7f6d1..9dd9631 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn @@ -26,6 +26,11 @@ enum E_AIRPORT_DATA Float: E_X, Float: E_Y, Float: E_Z, }; +enum E_CARGO_DATA +{ + E_NAME[ 24 ], E_RISK +}; + new g_DropOffLocations[ ] [ E_PILOT_DATA ] = { @@ -64,7 +69,27 @@ new { "Abandoned Airstrip", 175.2288, 2504.6611, 16.4844 }, { "Abandoned Airstrip", 266.3593, 2535.8496, 16.8125 } }, - g_CargoName[ ][ 8 ] = { "Wheat", "Weed", "Meth", "Coke", "Weapons", "Clothes", "Drinks" }, + + g_CargoData[ ][ E_CARGO_DATA ] = + { + // HARDER CARGO + { "Weapons", RISK_FACTOR_HARD }, + { "Weed", RISK_FACTOR_HARD }, + { "Cocaine", RISK_FACTOR_HARD }, + { "Methamphetamine", RISK_FACTOR_HARD }, + { "Gold", RISK_FACTOR_HARD }, + { "Diamonds", RISK_FACTOR_HARD }, + + // EASY CARGO + { "Wheat", RISK_FACTOR_EASY }, + { "Clothes", RISK_FACTOR_EASY }, + { "Drinks", RISK_FACTOR_EASY }, + { "Soybeans", RISK_FACTOR_EASY }, + { "Coffee", RISK_FACTOR_EASY }, + { "Medical Supplies", RISK_FACTOR_EASY } + }, + + //g_CargoName[ ][ 8 ] = { "Wheat", "Weed", "Meth", "Coke", "Weapons", "Clothes", "Drinks" }, bool: p_hasPilotJob [ MAX_PLAYERS char ], p_PilotMapIcon [ MAX_PLAYERS ] = { 0xFFFF, ... }, @@ -169,7 +194,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) GivePlayerScore( playerid, 1 + floatround( p_PilotDistance[ playerid ] / 1000.0 ) ); GivePlayerCash( playerid, iCashEarned ); - ShowPlayerHelpDialog( playerid, 5000, "You have earned ~y~%s ~w~for exporting %s!", cash_format( iCashEarned ), g_CargoName[ p_PilotCargo[ playerid ] ] ); + ShowPlayerHelpDialog( playerid, 5000, "You have earned ~y~%s ~w~for exporting %s!", cash_format( iCashEarned ), g_CargoData[ p_PilotCargo[ playerid ] ][ E_NAME ] ); StopPlayerPilotWork( playerid ); return 1; } @@ -191,6 +216,24 @@ stock getClosestPilotRoute( playerid, &Float: distance = FLOAT_INFINITY ) return iCurrent; } +stock getRandomCargo( iRisk ) +{ + new + aRandom[ sizeof( g_CargoData ) ], + iRandom = -1 + ; + + for ( new i = 0; i < sizeof ( g_CargoData ); i ++ ) + { + if ( g_CargoData[ i ][ E_RISK ] == iRisk ) + { + aRandom[ ++iRandom ] = i; + } + } + + return aRandom[ random( iRandom + 1 ) ]; +} + stock StopPlayerPilotWork( playerid ) { DestroyDynamicRaceCP ( p_PilotCheckPoint[ playerid ] ); @@ -273,7 +316,7 @@ function OnPilotLoadCargo( playerid ) TogglePlayerControllable(playerid, true); - ShowPlayerHelpDialog( playerid, 7500, "Great! The cargo full of %s has been loaded, deliver it to the drop off location on your radar!", g_CargoName[ p_PilotCargo[ playerid ] ]); + ShowPlayerHelpDialog( playerid, 7500, "Great! The cargo full of %s has been loaded, deliver it to the drop off location on your radar!", g_CargoData[ p_PilotCargo[ playerid ] ][ E_NAME ]); return KillTimer( p_PilotLoadTimer[ playerid ] ), p_PilotLoadTimer[ playerid ] = 0xFFFF, 1; } @@ -311,7 +354,7 @@ CMD:pilot( playerid, params[ ] ) p_PilotVehicle [ playerid ] = GetPlayerVehicleID( playerid ); p_PilotDifficulty [ playerid ] = ( strmatch( szDifficulty, "harder" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY ); - p_PilotCargo [ playerid ] = random( sizeof( g_CargoName ) ); + p_PilotCargo [ playerid ] = getRandomCargo( strmatch( szDifficulty, "harder" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY ); p_PilotRoute [ playerid ] { 0 } = random ( sizeof ( g_AirportLocations ) ); p_PilotRoute [ playerid ] { 1 } = random ( sizeof( g_DropOffLocations ) ); @@ -323,7 +366,7 @@ CMD:pilot( playerid, params[ ] ) p_PilotPositionTimer[ playerid ] = SetTimerEx( "OnPilotPositionUpdate", 750, false, "dd", playerid, p_PilotRoute[ playerid ] { 0 } ); PlayerTextDrawShow( playerid, p_TruckingTD[ playerid ] ); - ShowPlayerHelpDialog( playerid, 7500, "A ~g~~h~truck blip~w~~h~ has been shown on your radar. Go to where the truck blip is to pickup your cargo full of %s.", g_CargoName[ p_PilotCargo[ playerid ] ] ); + ShowPlayerHelpDialog( playerid, 7500, "A ~g~~h~truck blip~w~~h~ has been shown on your radar. Go to where the truck blip is to pickup your cargo full of %s.", g_CargoData[ p_PilotCargo[ playerid ] ][ E_NAME ] ); } else SendError( playerid, "You already have a pilot job started! Cancel it with "COL_GREY"/pilot stop"COL_WHITE"." ); } From 2b0f96e0d1ec4ca43cd4dcb7bcf64e330f292476 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sun, 16 Sep 2018 14:16:59 +0100 Subject: [PATCH 2/3] Revert "adds different cargo names and the risk level." This reverts commit 018f5f4e34ddd564ad2a30c00a2087d16239af2b. --- .../cnr/features/minijobs/pilot.pwn | 53 ++----------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn index 9dd9631..fa7f6d1 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn @@ -26,11 +26,6 @@ enum E_AIRPORT_DATA Float: E_X, Float: E_Y, Float: E_Z, }; -enum E_CARGO_DATA -{ - E_NAME[ 24 ], E_RISK -}; - new g_DropOffLocations[ ] [ E_PILOT_DATA ] = { @@ -69,27 +64,7 @@ new { "Abandoned Airstrip", 175.2288, 2504.6611, 16.4844 }, { "Abandoned Airstrip", 266.3593, 2535.8496, 16.8125 } }, - - g_CargoData[ ][ E_CARGO_DATA ] = - { - // HARDER CARGO - { "Weapons", RISK_FACTOR_HARD }, - { "Weed", RISK_FACTOR_HARD }, - { "Cocaine", RISK_FACTOR_HARD }, - { "Methamphetamine", RISK_FACTOR_HARD }, - { "Gold", RISK_FACTOR_HARD }, - { "Diamonds", RISK_FACTOR_HARD }, - - // EASY CARGO - { "Wheat", RISK_FACTOR_EASY }, - { "Clothes", RISK_FACTOR_EASY }, - { "Drinks", RISK_FACTOR_EASY }, - { "Soybeans", RISK_FACTOR_EASY }, - { "Coffee", RISK_FACTOR_EASY }, - { "Medical Supplies", RISK_FACTOR_EASY } - }, - - //g_CargoName[ ][ 8 ] = { "Wheat", "Weed", "Meth", "Coke", "Weapons", "Clothes", "Drinks" }, + g_CargoName[ ][ 8 ] = { "Wheat", "Weed", "Meth", "Coke", "Weapons", "Clothes", "Drinks" }, bool: p_hasPilotJob [ MAX_PLAYERS char ], p_PilotMapIcon [ MAX_PLAYERS ] = { 0xFFFF, ... }, @@ -194,7 +169,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) GivePlayerScore( playerid, 1 + floatround( p_PilotDistance[ playerid ] / 1000.0 ) ); GivePlayerCash( playerid, iCashEarned ); - ShowPlayerHelpDialog( playerid, 5000, "You have earned ~y~%s ~w~for exporting %s!", cash_format( iCashEarned ), g_CargoData[ p_PilotCargo[ playerid ] ][ E_NAME ] ); + ShowPlayerHelpDialog( playerid, 5000, "You have earned ~y~%s ~w~for exporting %s!", cash_format( iCashEarned ), g_CargoName[ p_PilotCargo[ playerid ] ] ); StopPlayerPilotWork( playerid ); return 1; } @@ -216,24 +191,6 @@ stock getClosestPilotRoute( playerid, &Float: distance = FLOAT_INFINITY ) return iCurrent; } -stock getRandomCargo( iRisk ) -{ - new - aRandom[ sizeof( g_CargoData ) ], - iRandom = -1 - ; - - for ( new i = 0; i < sizeof ( g_CargoData ); i ++ ) - { - if ( g_CargoData[ i ][ E_RISK ] == iRisk ) - { - aRandom[ ++iRandom ] = i; - } - } - - return aRandom[ random( iRandom + 1 ) ]; -} - stock StopPlayerPilotWork( playerid ) { DestroyDynamicRaceCP ( p_PilotCheckPoint[ playerid ] ); @@ -316,7 +273,7 @@ function OnPilotLoadCargo( playerid ) TogglePlayerControllable(playerid, true); - ShowPlayerHelpDialog( playerid, 7500, "Great! The cargo full of %s has been loaded, deliver it to the drop off location on your radar!", g_CargoData[ p_PilotCargo[ playerid ] ][ E_NAME ]); + ShowPlayerHelpDialog( playerid, 7500, "Great! The cargo full of %s has been loaded, deliver it to the drop off location on your radar!", g_CargoName[ p_PilotCargo[ playerid ] ]); return KillTimer( p_PilotLoadTimer[ playerid ] ), p_PilotLoadTimer[ playerid ] = 0xFFFF, 1; } @@ -354,7 +311,7 @@ CMD:pilot( playerid, params[ ] ) p_PilotVehicle [ playerid ] = GetPlayerVehicleID( playerid ); p_PilotDifficulty [ playerid ] = ( strmatch( szDifficulty, "harder" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY ); - p_PilotCargo [ playerid ] = getRandomCargo( strmatch( szDifficulty, "harder" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY ); + p_PilotCargo [ playerid ] = random( sizeof( g_CargoName ) ); p_PilotRoute [ playerid ] { 0 } = random ( sizeof ( g_AirportLocations ) ); p_PilotRoute [ playerid ] { 1 } = random ( sizeof( g_DropOffLocations ) ); @@ -366,7 +323,7 @@ CMD:pilot( playerid, params[ ] ) p_PilotPositionTimer[ playerid ] = SetTimerEx( "OnPilotPositionUpdate", 750, false, "dd", playerid, p_PilotRoute[ playerid ] { 0 } ); PlayerTextDrawShow( playerid, p_TruckingTD[ playerid ] ); - ShowPlayerHelpDialog( playerid, 7500, "A ~g~~h~truck blip~w~~h~ has been shown on your radar. Go to where the truck blip is to pickup your cargo full of %s.", g_CargoData[ p_PilotCargo[ playerid ] ][ E_NAME ] ); + ShowPlayerHelpDialog( playerid, 7500, "A ~g~~h~truck blip~w~~h~ has been shown on your radar. Go to where the truck blip is to pickup your cargo full of %s.", g_CargoName[ p_PilotCargo[ playerid ] ] ); } else SendError( playerid, "You already have a pilot job started! Cancel it with "COL_GREY"/pilot stop"COL_WHITE"." ); } From 22532b95f1621a8bdad893649104af24de05fb2b Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sun, 16 Sep 2018 15:47:22 +0100 Subject: [PATCH 3/3] fixes "/pb leave" --- .../irresistible/cnr/features/paintball.pwn | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/paintball.pwn b/gamemodes/irresistible/cnr/features/paintball.pwn index 22466fa..be23e93 100644 --- a/gamemodes/irresistible/cnr/features/paintball.pwn +++ b/gamemodes/irresistible/cnr/features/paintball.pwn @@ -557,6 +557,17 @@ CMD:paintball( playerid, params[ ] ) if ( !IsPlayerInPaintBall( playerid ) ) return SendError( playerid, "You're not in any paintball lobby." ); + if ( strmatch( params, "leave" ) ) + { + if ( !IsPlayerInPaintBall( playerid ) ) + return SendError( playerid, "You're not inside the paintball." ); + + LeavePlayerPaintball( playerid ); + SetPlayerHealth( playerid, -1 ); + SendServerMessage( playerid, "You have left the paintball arena." ); + return 1; + } + if ( !hasPaintBallArena( playerid ) ) return SendError( playerid, "This command requires you to be the host of a lobby." ); @@ -611,16 +622,6 @@ CMD:paintball( playerid, params[ ] ) g_paintballData[ id ] [ E_CD_TIMER ] = SetTimerEx( "paintballCountDown", 960, false, "dd", id, iSeconds - 1 ); } } - else if ( strmatch( params, "leave" ) ) - { - if ( !IsPlayerInPaintBall( playerid ) ) - return SendError( playerid, "You're not inside the paintball." ); - - LeavePlayerPaintball( playerid ); - SetPlayerHealth( playerid, -1 ); - SendServerMessage( playerid, "You have left the paintball arena." ); - return 1; - } else { SendUsage( playerid, "/paintball [LEAVE/EDIT/KICK/COUNTDOWN/LEADER]" );