passive disables deathmatch

This commit is contained in:
Lorenc Pekaj 2018-10-14 00:08:22 +11:00
parent 763689448f
commit 9c49fa35b4
4 changed files with 39 additions and 15 deletions

View File

@ -210,6 +210,7 @@
#define DIALOG_COMPONENTS_SELL 1200 #define DIALOG_COMPONENTS_SELL 1200
#define DIALOG_HOUSE_SELL 1201 #define DIALOG_HOUSE_SELL 1201
#define DIALOG_BUSINESS_SELL_CONFIRM 1202 #define DIALOG_BUSINESS_SELL_CONFIRM 1202
#define DIALOG_PASSIVE_MODE 1203
/* ** Hooks ** */ /* ** Hooks ** */
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )

View File

@ -232,7 +232,7 @@ new
p_PlayerAltBindTick [ MAX_PLAYERS ], p_PlayerAltBindTick [ MAX_PLAYERS ],
p_AimedAtPolice [ MAX_PLAYERS ], p_AimedAtPolice [ MAX_PLAYERS ],
bool: p_PassiveModeDisabled [ MAX_PLAYERS char ], bool: p_PassiveModeDisabled [ MAX_PLAYERS char ],
p_PassiveModeExpireTimer [ MAX_PLAYERS ] = { -1, ... }, //p_PassiveModeExpireTimer [ MAX_PLAYERS ] = { -1, ... },
Text3D: p_PassiveModeLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID } Text3D: p_PassiveModeLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID }
; ;

View File

@ -68,9 +68,9 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
ShowPlayerTogglableTextdraws( playerid, .force = false ); ShowPlayerTogglableTextdraws( playerid, .force = false );
} }
else if ( settingid == SETTING_PASSIVE_MODE ) { /*else if ( settingid == SETTING_PASSIVE_MODE ) {
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing
} }*/
format( szNormalString, 68, "INSERT INTO `SETTINGS`(`USER_ID`, `SETTING_ID`) VALUES (%d, %d)", p_AccountID[ playerid ], settingid ); format( szNormalString, 68, "INSERT INTO `SETTINGS`(`USER_ID`, `SETTING_ID`) VALUES (%d, %d)", p_AccountID[ playerid ], settingid );
} }
@ -80,15 +80,15 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
HidePlayerTogglableTextdraws( playerid, .force = false ); HidePlayerTogglableTextdraws( playerid, .force = false );
ShowPlayerTogglableTextdraws( playerid, .force = false ); ShowPlayerTogglableTextdraws( playerid, .force = false );
} }
else if ( settingid == SETTING_PASSIVE_MODE ) { /*else if ( settingid == SETTING_PASSIVE_MODE ) {
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing
} }*/
format( szNormalString, 64, "DELETE FROM `SETTINGS` WHERE USER_ID=%d AND SETTING_ID=%d", p_AccountID[ playerid ], settingid ); format( szNormalString, 64, "DELETE FROM `SETTINGS` WHERE USER_ID=%d AND SETTING_ID=%d", p_AccountID[ playerid ], settingid );
} }
mysql_single_query( szNormalString ); mysql_single_query( szNormalString );
SendServerMessage( playerid, "You have %s "COL_GREY"%s"COL_WHITE". Changes may take effect after spawning/relogging.", p_PlayerSettings[ playerid ] { settingid } ? ( "enabled" ) : ( "disabled" ), g_PlayerSettings[ settingid ] ); SendServerMessage( playerid, ""COL_ORANGE"%s"COL_WHITE" is now %s. Changes may take effect after spawning/relogging.", g_PlayerSettings[ settingid ], p_PlayerSettings[ playerid ] { settingid } ? ( "enabled" ) : ( "disabled" ) );
if ( ! strmatch( inputtext, "ignore" )) { if ( ! strmatch( inputtext, "ignore" )) {
cmd_cp( playerid, "" ); // Redirect to control panel again... cmd_cp( playerid, "" ); // Redirect to control panel again...

View File

@ -2829,10 +2829,10 @@ public OnPlayerTakePlayerDamage( playerid, issuerid, &Float: amount, weaponid, b
// Passive mode enabled for player? // Passive mode enabled for player?
if ( IsPlayerPassive( issuerid ) ) { if ( IsPlayerPassive( issuerid ) ) {
if ( p_PassiveModeExpireTimer[ issuerid ] == -1 ) { /*if ( p_PassiveModeExpireTimer[ issuerid ] == -1 ) {
p_PassiveModeExpireTimer[ issuerid ] = PassiveMode_Reset( issuerid, 4 ); // it will just set it to anything but -1 for now p_PassiveModeExpireTimer[ issuerid ] = PassiveMode_Reset( issuerid, 4 ); // it will just set it to anything but -1 for now
} }*/
return 0; return ShowPlayerHelpDialog( issuerid, 2000, "~r~You cannot deathmatch with /passive enabled." ), 0;
} }
// Passive mode enabled for damaged id? // Passive mode enabled for damaged id?
@ -7668,6 +7668,7 @@ CMD:c4( playerid, params[ ] )
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You cannot use this command since you're tied." ); if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You cannot use this command since you're tied." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You cannot use this command since you're kidnapped." ); if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You cannot use this command since you're kidnapped." );
if ( IsPlayerInCasino( playerid ) ) return SendError( playerid, "You cannot use this command since you're in a casino." ); if ( IsPlayerInCasino( playerid ) ) return SendError( playerid, "You cannot use this command since you're in a casino." );
if ( IsPlayerPassive( playerid ) ) return SendError( playerid, "You cannot use this command as an innocent player in passive mode." );
if ( IsPlayerInPaintBall( playerid ) || IsPlayerDueling( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an arena." ); if ( IsPlayerInPaintBall( playerid ) || IsPlayerDueling( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an arena." );
if ( p_C4Amount[ playerid ] < 1 ) return SendError( playerid, "You don't have any C4's" ); if ( p_C4Amount[ playerid ] < 1 ) return SendError( playerid, "You don't have any C4's" );
@ -10508,6 +10509,11 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
} }
TogglePlayerControllable( playerid, 1 ); TogglePlayerControllable( playerid, 1 );
if ( ! p_JobSet{ playerid } ) {
ShowPlayerDialog( playerid, DIALOG_PASSIVE_MODE, DIALOG_STYLE_LIST, "{FFFFFF}What is your type of style?", "{555555}Choose Below Below:\nI Like Roleplaying\nI Like Deathmatching", "Select", "" );
}
p_JobSet{ playerid } = true; p_JobSet{ playerid } = true;
//if ( !p_CitySet{ playerid } ) //if ( !p_CitySet{ playerid } )
@ -10520,6 +10526,19 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
TogglePlayerControllable( playerid, 0 ); TogglePlayerControllable( playerid, 0 );
ShowPlayerDialog( playerid, DIALOG_JOB, DIALOG_STYLE_LIST, "{FFFFFF}Job Selection", "Rapist\nKidnapper\nTerrorist\nHitman\nProstitute\nWeapon Dealer\nDrug Dealer\nDirty Mechanic\nBurglar", "Select", "" ); ShowPlayerDialog( playerid, DIALOG_JOB, DIALOG_STYLE_LIST, "{FFFFFF}Job Selection", "Rapist\nKidnapper\nTerrorist\nHitman\nProstitute\nWeapon Dealer\nDrug Dealer\nDirty Mechanic\nBurglar", "Select", "" );
} }
}
if ( dialogid == DIALOG_PASSIVE_MODE )
{
if ( ! response || ! listitem ) {
ShowPlayerDialog( playerid, DIALOG_PASSIVE_MODE, DIALOG_STYLE_LIST, "{FFFFFF}What is your type of style?", "{555555}Choose Below Below:\nI Like Roleplaying\nI Like Deathmatching", "Select", "" );
}
if ( listitem == 1 ) {
SendServerMessage( playerid, "Since you like roleplay, passive mode has been automatically enabled for you!" );
} else if ( listitem == 2 ) {
CallLocalFunction( "OnDialogResponse", "dddds", playerid, DIALOG_CP_MENU, 1, SETTING_PASSIVE_MODE + 1, "ignore" ); // cunning way
SendServerMessage( playerid, "Since you like deathmatch, passive mode has been automatically enabled for you!" );
}
} }
if ( dialogid == DIALOG_BOMB_SHOP ) if ( dialogid == DIALOG_BOMB_SHOP )
{ {
@ -17914,8 +17933,12 @@ stock DisablePlayerSpawnProtection( playerid )
stock SetPlayerPassiveMode( playerid ) stock SetPlayerPassiveMode( playerid )
{ {
// disable passive mode if it is enabled
if ( IsPlayerSettingToggled( playerid, SETTING_PASSIVE_MODE ) ) if ( IsPlayerSettingToggled( playerid, SETTING_PASSIVE_MODE ) )
{
ResetPlayerPassiveMode( playerid, .passive_disabled = true );
return 0; return 0;
}
// reset any labels etc // reset any labels etc
ResetPlayerPassiveMode( playerid ); ResetPlayerPassiveMode( playerid );
@ -17930,21 +17953,21 @@ stock SetPlayerPassiveMode( playerid )
stock IsPlayerPassive( playerid ) stock IsPlayerPassive( playerid )
{ {
return ! IsPlayerSettingToggled( playerid, SETTING_PASSIVE_MODE ) && ! p_WantedLevel[ playerid ] && p_Class[ playerid ] != CLASS_POLICE && ! p_PassiveModeDisabled{ playerid }; return ! p_WantedLevel[ playerid ] && p_Class[ playerid ] != CLASS_POLICE && ! p_PassiveModeDisabled{ playerid };
} }
stock ResetPlayerPassiveMode( playerid, bool: passive_disabled = false ) stock ResetPlayerPassiveMode( playerid, bool: passive_disabled = false )
{ {
DestroyDynamic3DTextLabel( p_PassiveModeLabel[ playerid ] ); DestroyDynamic3DTextLabel( p_PassiveModeLabel[ playerid ] );
KillTimer( p_PassiveModeExpireTimer[ playerid ] ); //KillTimer( p_PassiveModeExpireTimer[ playerid ] );
p_PassiveModeLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID; p_PassiveModeLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
p_PassiveModeExpireTimer[ playerid ] = -1; //p_PassiveModeExpireTimer[ playerid ] = -1;
p_PassiveModeDisabled{ playerid } = passive_disabled; p_PassiveModeDisabled{ playerid } = passive_disabled;
TextDrawHideForPlayer( playerid, g_PassiveModeTD ); TextDrawHideForPlayer( playerid, g_PassiveModeTD );
return 1; return 1;
} }
function PassiveMode_Reset( playerid, time_left ) /*function PassiveMode_Reset( playerid, time_left )
{ {
// if you happen to die then have a shot synced ... just reset normally // if you happen to die then have a shot synced ... just reset normally
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) { if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) {
@ -17963,7 +17986,7 @@ function PassiveMode_Reset( playerid, time_left )
ShowPlayerHelpDialog( playerid, 1500, "Passive mode disabled in ~r~%d seconds.", time_left ); ShowPlayerHelpDialog( playerid, 1500, "Passive mode disabled in ~r~%d seconds.", time_left );
} }
return 1; return 1;
} }*/
stock SendClientMessageToCops( colour, format[ ], va_args<> ) // Conversion to foreach 14 stuffed the define, not sure how... stock SendClientMessageToCops( colour, format[ ], va_args<> ) // Conversion to foreach 14 stuffed the define, not sure how...
{ {