From 070770ad2221e22ea37e4612c7794e904174eccf Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Tue, 11 Sep 2018 18:17:37 +1000 Subject: [PATCH] chuffsec module can be commented to disable now --- .../cnr/commands/admin/admin_two.pwn | 6 ++++ .../irresistible/cnr/features/chuffsec.pwn | 26 ++++++++++++++ gamemodes/sf-cnr.pwn | 36 +++++++++++-------- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/gamemodes/irresistible/cnr/commands/admin/admin_two.pwn b/gamemodes/irresistible/cnr/commands/admin/admin_two.pwn index 2b961a6..4ea98e2 100644 --- a/gamemodes/irresistible/cnr/commands/admin/admin_two.pwn +++ b/gamemodes/irresistible/cnr/commands/admin/admin_two.pwn @@ -118,7 +118,9 @@ CMD:vrespawn( playerid, params[ ] ) return SendUsage( playerid, "/vrespawn [VEHICLE_ID]" ); } else if ( !IsValidVehicle( vID ) ) return SendError( playerid, "Invalid Vehicle ID" ); +#if defined __cnr__chuffsec else if ( IsVehicleSecurityVehicle( vID ) ) return SendError( playerid, "This vehicle is prohibited." ); +#endif else { SetVehicleToRespawn( vID ); @@ -145,7 +147,9 @@ CMD:vdestroy( playerid, params[ ] ) if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You're not in any vehicle." ); vID = GetPlayerVehicleID( playerid ); if ( IsBuyableVehicle( vID ) ) return SendError( playerid, "You cannot use this command to destroy buyable vehicles." ); + #if defined __cnr__chuffsec if ( IsVehicleSecurityVehicle( vID ) ) return SendError( playerid, "This vehicle is prohibited." ); + #endif if ( g_TrolleyVehicles[ 0 ] == vID || g_TrolleyVehicles[ 1 ] == vID || g_TrolleyVehicles[ 2 ] == vID || g_TrolleyVehicles[ 3 ] == vID || g_TrolleyVehicles[ 4 ] == vID ) return SendError( playerid, "This vehicle is prohibited." ); DestroyVehicle( vID ); if ( g_adminSpawnedCar{ vID } ) g_adminSpawnedCar{ vID } = false; @@ -154,7 +158,9 @@ CMD:vdestroy( playerid, params[ ] ) } else if ( !IsValidVehicle( vID ) ) return SendError( playerid, "Invalid Vehicle ID" ); else if ( IsBuyableVehicle( vID ) ) return SendError( playerid, "You cannot use this command to destroy buyable vehicles." ); +#if defined __cnr__chuffsec else if ( IsVehicleSecurityVehicle( vID ) ) return SendError( playerid, "This vehicle is prohibited." ); +#endif else if ( g_TrolleyVehicles[ 0 ] == vID || g_TrolleyVehicles[ 1 ] == vID || g_TrolleyVehicles[ 2 ] == vID || g_TrolleyVehicles[ 3 ] == vID || g_TrolleyVehicles[ 4 ] == vID ) return SendError( playerid, "This vehicle is prohibited." ); else { diff --git a/gamemodes/irresistible/cnr/features/chuffsec.pwn b/gamemodes/irresistible/cnr/features/chuffsec.pwn index 1182e07..cfa02b3 100644 --- a/gamemodes/irresistible/cnr/features/chuffsec.pwn +++ b/gamemodes/irresistible/cnr/features/chuffsec.pwn @@ -186,6 +186,32 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) return 1; } +hook OnPlayerRequestSpawn( playerid ) +{ + if ( IsPlayerSecurityDriver( playerid ) ) + { + SetPlayerSkin( playerid, 71 ); + return Y_HOOKS_BREAK_RETURN_1; + } + return 1; +} + +hook OnPlayerUpdate( playerid ) +{ + if ( IsPlayerSecurityDriver( playerid ) ) { // prevent unneccessary updating + return Y_HOOKS_BREAK_RETURN_1; + } + return Y_HOOKS_CONTINUE_RETURN_1; +} + +hook OnPlayerSpawn( playerid ) +{ + if ( IsPlayerSecurityDriver( playerid ) ) { + return Y_HOOKS_BREAK_RETURN_1; + } + return Y_HOOKS_CONTINUE_RETURN_1; +} + /* ** Commands ** */ CMD:chuffloc( playerid, params[ ] ) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 9808baf..eec04a6 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -4939,9 +4939,6 @@ public OnPlayerSpawn( playerid ) new iTick = GetTickCount( ); - if ( IsPlayerSecurityDriver( playerid ) ) - return 1; - UpdatePlayerTime( playerid ); DeletePVar( playerid, "attached_mugshot" ); @@ -7903,9 +7900,12 @@ CMD:cnr( playerid, params[ ] ) new Float: iClass[ 2 ]; - for( new i = 0; i < MAX_PLAYERS; i++ ) - if ( IsPlayerConnected( i ) && i != g_secureTruckDriver ) - iClass[ ( p_Class[ i ] == CLASS_POLICE ? CLASS_POLICE : CLASS_CIVILIAN ) ] ++; + for( new i = 0; i < MAX_PLAYERS; i++ ) if ( IsPlayerConnected( i ) ) { + #if defined __cnr__chuffsec + if ( i == g_secureTruckDriver ) continue; + #endif + iClass[ ( p_Class[ i ] == CLASS_POLICE ? CLASS_POLICE : CLASS_CIVILIAN ) ] ++; + } new Float: iCivilians = ( iClass[ CLASS_CIVILIAN ] / ( iClass[ CLASS_CIVILIAN ] + iClass[ CLASS_POLICE ] ) ) * 100.0, @@ -11969,10 +11969,17 @@ CMD:c4( playerid, params[ ] ) g_C4Data[ playerid ] [ ID ] [ E_INTERIOR ] = GetPlayerInterior( playerid ); g_C4Data[ playerid ] [ ID ] [ E_SET ] = true; - if ( !iVehicle ) + if ( ! iVehicle ) { iVehicle = GetPlayerSurfingVehicleID( playerid ); + } - if ( IsValidVehicle( iVehicle ) && iVehicle != g_secureTruckVehicle ) + #if defined __cnr__chuffsec + if ( iVehicle == g_secureTruckVehicle ) { + iVehicle = INVALID_VEHICLE_ID; + } + #endif + + if ( IsValidVehicle( iVehicle ) ) { GetVehiclePos( iVehicle, X, Y, Z ); @@ -13999,9 +14006,6 @@ public OnRconCommand(cmd[]) public OnPlayerRequestSpawn( playerid ) { - if ( IsPlayerSecurityDriver( playerid ) ) - return SetPlayerSkin( playerid, 71 ); - // army limit /*if ( IsPlayerArmy( playerid ) ) { @@ -15118,9 +15122,6 @@ function unpause_Player( playerid ) public OnPlayerUpdate( playerid ) { - if ( IsPlayerSecurityDriver( playerid ) ) - return 1; - if ( !p_PlayerLogged{ playerid } ) return 0; @@ -20651,8 +20652,10 @@ stock GivePlayerWantedLevel( playerid, wantedlevel, bool:loadingstats = false ) if ( !IsPlayerConnected( playerid ) ) return 0; +#if defined __cnr__chuffsec if ( IsPlayerSecurityDriver( playerid ) ) return SetPlayerColor( playerid, COLOR_SECURITY ); +#endif if ( IsPlayerJailed( playerid ) ) { @@ -20896,7 +20899,10 @@ stock GetPlayerIDFromAccountID( iAccountID ) stock SetPlayerColorToTeam( playerid ) { +#if defined __cnr__chuffsec if ( IsPlayerSecurityDriver( playerid ) ) return SetPlayerColor( playerid, COLOR_SECURITY ); +#endif + if ( p_AdminOnDuty{ playerid } ) return SetPlayerColor( playerid, COLOR_PINK ); switch( p_Class[ playerid ] ) @@ -22326,8 +22332,10 @@ stock isValidPlayerName( szName[ ] ) //strreplacechar( szName, '.', '-' ); strreplacechar( szName, '/', '-' ); +#if defined __cnr__chuffsec if ( strmatch( szName, SECURE_TRUCK_DRIVER_NAME ) ) return false; +#endif if( !( 2 < strlen( szName ) < MAX_PLAYER_NAME ) ) return false;