From 5548bd4544c82c9c17666fdd78c3c6b1ed67da31 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 15 Sep 2018 21:15:24 +0100 Subject: [PATCH 1/3] added risk element into pilot job added parameters into "/pilot [NORMAL/HARDER/STOP]" fixed all related bugs according to bangs --- .../cnr/features/minijobs/pilot.pwn | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn index d2d8ece..e9d02e0 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn @@ -73,6 +73,7 @@ new p_PilotCancelTimer [ MAX_PLAYERS ] = { 0xFFFF, ... }, p_PilotLoadTimer [ MAX_PLAYERS ] = { 0xFFFF, ... }, p_PilotCargo [ MAX_PLAYERS ], + p_PilotDifficulty [ MAX_PLAYERS ], p_PilotVehicle [ MAX_PLAYERS ], p_PilotTimeElapsed [ MAX_PLAYERS ], Float: p_PilotDistance [ MAX_PLAYERS ], @@ -86,11 +87,20 @@ hook OnPlayerDisconnect( playerid, reason ) return 1; } +#if defined AC_INCLUDED +hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart ) +#else +hook OnPlayerDeath( playerid, killerid, reason ) +#endif +{ + StopPlayerPilotWork( playerid ); + return 1; +} + hook OnPlayerUpdateEx( playerid ) { new player_vehicle = GetPlayerVehicleID( playerid ); - // check if the player has detached their trailer if ( GetPlayerState( playerid ) == PLAYER_STATE_DRIVER && player_vehicle && p_hasPilotJob{ playerid } && p_PilotVehicle[ playerid ] != player_vehicle && p_PilotCancelTimer[ playerid ] == 0xFFFF ) { cancelPlayerPilotWork( playerid, player_vehicle, .ticks = 60 ); } @@ -101,16 +111,17 @@ hook OnPlayerUpdateEx( playerid ) hook OnPlayerStateChange( playerid, newstate, oldstate ) { if ( newstate != PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_DRIVER && p_hasPilotJob{ playerid } ) { - cancelPlayerPilotWork( playerid, GetPlayerVehicleID( playerid ), .ticks = 60 ); + cancelPlayerPilotWork( playerid, GetPlayerVehicleID( playerid ), .ticks = 0 ); } - else if ( newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER && p_hasPilotJob{ playerid } ) { + else if ( newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER && p_hasPilotJob{ playerid } ) { KillTimer( p_PilotCancelTimer[ playerid ] ); p_PilotCancelTimer[ playerid ] = 0xFFFF; } else if ( newstate == PLAYER_STATE_DRIVER && IsPlayerInAnyVehicle(playerid) && !p_hasPilotJob{ playerid }) { - if ( IsVehiclePlane( GetPlayerVehicleID( playerid ) ) ) { + if ( IsVehiclePlane( GetPlayerVehicleID( playerid ) ) ) + { ShowPlayerHelpDialog( playerid, 3000, "You can begin a pilot job by typing ~g~~h~/pilot" ); } } @@ -126,8 +137,6 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) DestroyDynamicRaceCP ( p_PilotCheckPoint[ playerid ] ); KillTimer ( p_PilotPositionTimer[ playerid ] ); - GivePlayerWantedLevel( playerid, 6 ); - if ( p_PilotRoute[ playerid ] { 0 } != INVALID_PILOT_ROUTE ) { static aPlayer[ 1 ]; aPlayer[ 0 ] = playerid; @@ -141,6 +150,9 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) TogglePlayerControllable(playerid, false); + if ( p_PilotDifficulty[ playerid ] == RISK_FACTOR_HARD) + GivePlayerWantedLevel( playerid, 6 ); + ShowPlayerHelpDialog( playerid, 5000, "Please wait while your cargo is getting loaded into your vehicle!" ); p_PilotMapIcon [ playerid ] = CreateDynamicMapIconEx( g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_X ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Y ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Z ], 51, 0, MAPICON_GLOBAL, 6000.0, { -1 }, { -1 }, aPlayer ); @@ -152,6 +164,11 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) else if ( p_PilotRoute[ playerid ] { 1 } != INVALID_PILOT_ROUTE ) { new + iCashEarned; + + if ( p_PilotDifficulty[ playerid ] == RISK_FACTOR_EASY) + iCashEarned = floatround( p_PilotDistance[ playerid ] * 1.0 + PILOT_BONUS ); + else iCashEarned = floatround( p_PilotDistance[ playerid ] * 2.0 + PILOT_BONUS ); TextDrawHideForPlayer( playerid, p_TruckingTD[ playerid ] ); @@ -161,6 +178,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) ShowPlayerHelpDialog( playerid, 5000, "You have earned ~y~%s ~w~for exporting %s!", cash_format( iCashEarned ), g_CargoName[ p_PilotCargo[ playerid ] ] ); + p_PilotDifficulty [ playerid ] = -1; p_PilotDistance [ playerid ] = 0.0; p_hasPilotJob [ playerid ] = false; p_PilotCheckPoint [ playerid ] = 0xFFFF; @@ -193,15 +211,13 @@ stock getClosestPilotRoute( playerid, &Float: distance = FLOAT_INFINITY ) stock StopPlayerPilotWork( playerid ) { - if ( !p_hasPilotJob { playerid } ) - return SendError( playerid, "You cannot cancel a pilot job that hasn't started."); - DestroyDynamicRaceCP ( p_PilotCheckPoint[ playerid ] ); DestroyDynamicMapIcon ( p_PilotMapIcon[ playerid ] ); KillTimer ( p_PilotCancelTimer[ playerid ] ); KillTimer ( p_PilotPositionTimer[ playerid ] ); + p_PilotDifficulty [ playerid ] = -1; p_PilotDistance [ playerid ] = 0.0; p_hasPilotJob { playerid } = false; p_PilotCheckPoint [ playerid ] = 0xFFFF; @@ -213,8 +229,7 @@ stock StopPlayerPilotWork( playerid ) p_PilotCargo [ playerid ] = -1; p_PilotVehicle [ playerid ] = INVALID_VEHICLE_ID; - TextDrawHideForPlayer( playerid, p_TruckingTD[ playerid ] ); - return SendServerMessage( playerid, "Your pilot mission has been stopped." ); + TextDrawHideForPlayer( playerid, p_TruckingTD[ playerid ] ), 1; } stock IsVehiclePlane ( vehicleid ) @@ -254,6 +269,7 @@ function cancelPlayerPilotWork( playerid, vehicleid, ticks ) if ( ticks < 1 || !IsPlayerConnected( playerid ) || !IsPlayerSpawned( playerid ) ) { StopPlayerPilotWork( playerid ); + return SendServerMessage( playerid, "Your pilot mission has been stopped." ); } else { @@ -282,17 +298,19 @@ function OnPilotLoadCargo( playerid ) CMD:pilot( playerid, params[ ] ) { new + szDifficulty[ 7 ], iVehicle = GetPlayerVehicleID( playerid ); if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "You must be an ordinary civilian to use this command." ); - else if ( strmatch( params, "STOP" )) - { - return StopPlayerPilotWork( playerid ), 1; - } - else if ( !strmatch( params, "WORK" )) return SendUsage( playerid, "/pilot [WORK/STOP]" ); else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You must be a driver of a vehicle to work." ); else if ( !iVehicle ) return SendError( playerid, "You are not in any vehicle." ); - else + else if ( sscanf( params, "S(normal)[7]", szDifficulty ) ) return SendUsage( playerid, "/pilot [NORMAL/HARDER/STOP]" ); + else if ( strmatch( szDifficulty, "stop" )) + { + StopPlayerPilotWork( playerid ); + return SendServerMessage( playerid, "Your pilot mission has been stopped." ); + } + else if ( strmatch( szDifficulty, "normal" ) || strmatch( szDifficulty, "harder" )) { if ( IsVehiclePlane( iVehicle )) { @@ -307,6 +325,7 @@ CMD:pilot( playerid, params[ ] ) p_hasPilotJob { playerid } = true; p_WorkCooldown [ playerid ] = g_iTime + 60; 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_PilotRoute [ playerid ] { 0 } = random ( sizeof ( g_AirportLocations ) ); From f74b61ff5230798e6dd17081996f48d87d141fcf Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 15 Sep 2018 21:31:37 +0100 Subject: [PATCH 2/3] increased the drop off checkpoint by 0.5 units --- gamemodes/irresistible/cnr/features/minijobs/pilot.pwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn index e9d02e0..8b45b17 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/pilot.pwn @@ -156,7 +156,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) ShowPlayerHelpDialog( playerid, 5000, "Please wait while your cargo is getting loaded into your vehicle!" ); p_PilotMapIcon [ playerid ] = CreateDynamicMapIconEx( g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_X ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Y ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Z ], 51, 0, MAPICON_GLOBAL, 6000.0, { -1 }, { -1 }, aPlayer ); - p_PilotCheckPoint [ playerid ] = CreateDynamicRaceCP( 4, g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_X ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Y ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Z ] + 50.0, 10.0, 0.0, 0.0, 10.0, -1, -1, playerid ); + p_PilotCheckPoint [ playerid ] = CreateDynamicRaceCP( 4, g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_X ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Y ], g_DropOffLocations[ p_PilotRoute[ playerid ] { 1 } ] [ E_Z ] + 50.0, 15.0, 0.0, 0.0, 10.0, -1, -1, playerid ); return ( p_PilotRoute[ playerid ] { 0 } = INVALID_PILOT_ROUTE ), 1; } @@ -229,7 +229,7 @@ stock StopPlayerPilotWork( playerid ) p_PilotCargo [ playerid ] = -1; p_PilotVehicle [ playerid ] = INVALID_VEHICLE_ID; - TextDrawHideForPlayer( playerid, p_TruckingTD[ playerid ] ), 1; + TextDrawHideForPlayer( playerid, p_TruckingTD[ playerid ] ); } stock IsVehiclePlane ( vehicleid ) From af30a8991432357f4d5ed5c01b21f70ed5c87f0f Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 15 Sep 2018 21:35:02 +0100 Subject: [PATCH 3/3] including pilot into script --- gamemodes/irresistible/cnr/features/minijobs/_minijobs.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/minijobs/_minijobs.pwn b/gamemodes/irresistible/cnr/features/minijobs/_minijobs.pwn index 59ae064..0ce2e2b 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/_minijobs.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/_minijobs.pwn @@ -8,4 +8,4 @@ /* ** Includes ** */ #include "irresistible\cnr\features\minijobs\meth.pwn" #include "irresistible\cnr\features\minijobs\trucking.pwn" -// #include "irresistible\cnr\features\minijobs\pilot.pwn" +#include "irresistible\cnr\features\minijobs\pilot.pwn"