From 598b0c6fda78f7ab8bd29a823d3c3b5095fee9b3 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 14:21:51 +0100 Subject: [PATCH] adding hitmarker textdraw into damage_feed file. cleanup variables --- .../irresistible/cnr/features/damage_feed.pwn | 61 +++++++++++++++++-- gamemodes/irresistible/cnr/player.pwn | 1 - gamemodes/irresistible/cnr/textdraws.pwn | 9 --- gamemodes/sf-cnr.pwn | 36 +---------- 4 files changed, 57 insertions(+), 50 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 469684e..3735e49 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -23,7 +23,7 @@ /* ** Forwards ** */ forward OnPlayerFeedUpdate ( playerid ); -forward OnPlayerTakenDamageFeed ( playerid, issuerid, Float: amount, weaponid, bodypart ); +forward OnPlayerTakenDamage ( playerid, issuerid, Float: amount, weaponid, bodypart ); /* ** Variables ** */ enum E_DAMAGE_FEED @@ -32,14 +32,16 @@ enum E_DAMAGE_FEED E_WEAPON, E_TICK, }; -new +static stock g_damageGiven [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], g_damageTaken [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], PlayerText: g_damageFeedTakenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: g_damageFeedGivenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, + PlayerText: p_DamageTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, - p_damageFeedTimer [ MAX_PLAYERS ], + p_damageFeedTimer [ MAX_PLAYERS ] = { -1, ... }, + p_DamageTDTimer [ MAX_PLAYERS ] = { -1, ... }, bool: p_FeedActive [ MAX_PLAYERS char ], p_lastFeedUpdate [ MAX_PLAYERS ] ; @@ -53,13 +55,62 @@ hook OnPlayerConnect( playerid ) } p_lastFeedUpdate[ playerid ] = GetTickCount( ); + + /* ** Textdraws ** */ + p_DamageTD[ playerid ] = CreatePlayerTextDraw(playerid, 357.000000, 208.000000, "~r~~h~300.24 DAMAGE"); + PlayerTextDrawBackgroundColor(playerid, p_DamageTD[ playerid ], 255); + PlayerTextDrawFont(playerid, p_DamageTD[ playerid ], 3); + PlayerTextDrawLetterSize(playerid, p_DamageTD[ playerid ], 0.400000, 1.000000); + PlayerTextDrawColor(playerid, p_DamageTD[ playerid ], -1); + PlayerTextDrawSetOutline(playerid, p_DamageTD[ playerid ], 1); + PlayerTextDrawSetProportional(playerid, p_DamageTD[ playerid ], 1); + return 1; } /* ** Functions ** */ -public OnPlayerTakenDamageFeed( playerid, issuerid, Float: amount, weaponid, bodypart ) +function OnHitmarkerHide( playerid ) + return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); + +public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart ) { - AddDamageFeedHit( issuerid, playerid, amount, weaponid, TYPE_GIVEN ); + /* ** Hitmarker ** */ + if ( IsPlayerSettingToggled( issuerid, SETTING_HITMARKER ) ) + { + new + soundid = p_VIPLevel[ issuerid ] ? p_HitmarkerSound{ issuerid } : 0; + + PlayerPlaySound( issuerid, g_HitmarkerSounds[ soundid ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); + + PlayerTextDrawSetString( issuerid, p_DamageTD[ issuerid ], sprintf( "~r~~h~%0.2f DAMAGE", amount ) ); + PlayerTextDrawShow( issuerid, p_DamageTD[ issuerid ] ); + + KillTimer( p_DamageTDTimer[ issuerid ] ); + p_DamageTDTimer[ issuerid ] = SetTimerEx( "OnHitmarkerHide", 3000, false, "d", issuerid ); + } + + /* ** Hitmarker (while spectating) ** */ + foreach ( new i : Player ) + { + if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid ) + { + new + soundid = p_VIPLevel[ issuerid ] ? p_HitmarkerSound{ issuerid } : 0; + + PlayerPlaySound( i, g_HitmarkerSounds[ soundid ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); + + PlayerTextDrawSetString( i, p_DamageTD[ i ], sprintf( "~r~~h~%0.2f DAMAGE", amount ) ); + PlayerTextDrawShow( i, p_DamageTD[ i ] ); + + KillTimer( p_DamageTDTimer[ i ] ); + p_DamageTDTimer[ i ] = SetTimerEx( "OnHitmarkerHide", 3000, false, "d", i ); + } + } + + /* ** Damage Feed ** */ + if ( issuerid != INVALID_PLAYER_ID ) { + AddDamageFeedHit( issuerid, playerid, amount, weaponid, TYPE_GIVEN ); + } AddDamageFeedHit( playerid, issuerid, amount, weaponid, TYPE_TAKEN ); return 1; } diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index eb7ecaf..9eff290 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -72,7 +72,6 @@ new p_PmResponder [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, bool: justConnected [ MAX_PLAYERS char ], p_BailOfferer [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, - p_DamageTDTimer [ MAX_PLAYERS ] = { -1, ... }, Text3D: p_InfoLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID, ... }, p_InfoLabelString [ MAX_PLAYERS ] [ 32 ], bool: p_inMovieMode [ MAX_PLAYERS char ], diff --git a/gamemodes/irresistible/cnr/textdraws.pwn b/gamemodes/irresistible/cnr/textdraws.pwn index 8f855e0..db6bb09 100644 --- a/gamemodes/irresistible/cnr/textdraws.pwn +++ b/gamemodes/irresistible/cnr/textdraws.pwn @@ -40,7 +40,6 @@ new PlayerText: p_PlayerRankTextTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_RobberyAmountTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_RobberyRiskTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, - PlayerText: p_DamageTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_JailTimeTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: g_ZoneOwnerTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_HelpBoxTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, @@ -441,14 +440,6 @@ hook OnPlayerConnect( playerid ) PlayerTextDrawSetOutline(playerid, p_JailTimeTD[ playerid ], 1); PlayerTextDrawSetProportional(playerid, p_JailTimeTD[ playerid ], 1); - p_DamageTD[ playerid ] = CreatePlayerTextDraw(playerid, 357.000000, 208.000000, "~r~~h~300.24 DAMAGE"); - PlayerTextDrawBackgroundColor(playerid, p_DamageTD[ playerid ], 255); - PlayerTextDrawFont(playerid, p_DamageTD[ playerid ], 3); - PlayerTextDrawLetterSize(playerid, p_DamageTD[ playerid ], 0.400000, 1.000000); - PlayerTextDrawColor(playerid, p_DamageTD[ playerid ], -1); - PlayerTextDrawSetOutline(playerid, p_DamageTD[ playerid ], 1); - PlayerTextDrawSetProportional(playerid, p_DamageTD[ playerid ], 1); - p_LocationTD[ playerid ] = CreatePlayerTextDraw( playerid, 86.000000, 322.000000, "Loading..." ); PlayerTextDrawAlignment( playerid, p_LocationTD[ playerid ], 2 ); PlayerTextDrawBackgroundColor( playerid, p_LocationTD[ playerid ], 255 ); diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 629f876..118c379 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2955,45 +2955,11 @@ public OnPlayerTakePlayerDamage( playerid, issuerid, &Float: amount, weaponid, b amount *= 1.5; } - // Hitmarker - if ( IsPlayerSettingToggled( issuerid, SETTING_HITMARKER ) ) - { - new - soundid = p_VIPLevel[ issuerid ] ? p_HitmarkerSound{ issuerid } : 0; - - PlayerPlaySound( issuerid, g_HitmarkerSounds[ soundid ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); - - PlayerTextDrawSetString( issuerid, p_DamageTD[ issuerid ], sprintf( "~r~~h~%0.2f DAMAGE", amount ) ); - PlayerTextDrawShow( issuerid, p_DamageTD[ issuerid ] ); - - KillTimer( p_DamageTDTimer[ issuerid ] ); - p_DamageTDTimer[ issuerid ] = SetTimerEx( "hidedamagetd_Timer", 3000, false, "d", issuerid ); - } - - foreach ( new i : Player ) - { - if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid ) - { - new - soundid = p_VIPLevel[ issuerid ] ? p_HitmarkerSound{ issuerid } : 0; - - PlayerPlaySound( i, g_HitmarkerSounds[ soundid ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); - - PlayerTextDrawSetString( i, p_DamageTD[ i ], sprintf( "~r~~h~%0.2f DAMAGE", amount ) ); - PlayerTextDrawShow( i, p_DamageTD[ i ] ); - - KillTimer( p_DamageTDTimer[ i ] ); - p_DamageTDTimer[ i ] = SetTimerEx( "hidedamagetd_Timer", 3000, false, "d", i ); - } - } - + CallLocalFunction( "OnPlayerTakenDamage", "ddfdd", playerid, issuerid, amount, weapon, bodypart ); return 1; } #endif -function hidedamagetd_Timer( playerid ) - return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); - stock BeginEconomyTax( starting = 1 ) { mysql_function_query( dbHandle, "SELECT USER_CASH, BIZ_CASH, GANG_CASH FROM (SELECT (SUM(BANKMONEY)+SUM(CASH)) USER_CASH FROM USERS) A CROSS JOIN (SELECT SUM(BANK) BIZ_CASH FROM BUSINESSES) B CROSS JOIN (SELECT SUM(BANK) GANG_CASH FROM GANGS) C", true, "OnTaxEconomy", "i", starting ); }