From 8f6058b86a94450e07dcdd576fc7a77ac6a293cc Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 00:40:49 +0100 Subject: [PATCH 01/25] starting on damage feed, ideal for dmers --- .../irresistible/anticheat/damage_feed.pwn | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 gamemodes/irresistible/anticheat/damage_feed.pwn diff --git a/gamemodes/irresistible/anticheat/damage_feed.pwn b/gamemodes/irresistible/anticheat/damage_feed.pwn new file mode 100644 index 0000000..813c7dc --- /dev/null +++ b/gamemodes/irresistible/anticheat/damage_feed.pwn @@ -0,0 +1,176 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Steven Howard + * Module: anticheat/damage_feed.pwn + * Purpose: damage feed for dmers + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Definitions ** */ +#define MAX_FEED_HEIGHT ( 5 ) +#define HIDE_FEED_DELAY ( 3000 ) +#define MAX_UPDATE_RATE ( 250 ) + +/* ** Variables ** */ +enum E_DAMAGE_FEED +{ + E_ISSUER, E_NAME[ MAX_PLAYER_NAME ], Float: E_AMOUNT, + E_WEAPON, E_TICK, +}; + +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, ... }, + + p_damageFeedTimer [ MAX_PLAYERS ], + p_lastFeedUpdate [ MAX_PLAYERS ] +; + +/* ** Hooks ** */ +hook OnPlayerConnect( playerid ) +{ + for( new i = 0; i < sizeof( g_damageGiven[ ] ); i ++) { + g_damageGiven[ playerid ][ i ][ E_TICK ] = 0; + g_damageTaken[ playerid ][ i ][ E_TICK ] = 0; + } + + p_lastFeedUpdate[ playerid ] = GetTickCount( ); + return 1; +} + +/* ** Functions ** */ +function OnPlayerFeedUpdate( playerid ) +{ + return 1; +} + +stock UpdateDamageFeed( playerid, bool: modified = false ) +{ +/* ** Textdraws ** */ + if ( g_damageFeedGivenTD[ playerid] == PlayerText: INVALID_TEXT_DRAW ) + { + new PlayerText: handle = CreatePlayerTextDraw( playerid, 200.000000, 340.000000, "_"); + + if ( handle == PlayerText: INVALID_TEXT_DRAW ) + return print("[DAMAGE FEED ERROR]: Unable to create TD (given damage)" ), 0; + + PlayerTextDrawAlignment( playerid, handle, 2 ); + PlayerTextDrawBackgroundColor( playerid, handle, 255 ); + PlayerTextDrawFont( playerid, handle, 1 ); + PlayerTextDrawLetterSize( playerid, handle, 0.200000, 0.899999 ); + PlayerTextDrawColor( playerid, handle, -16776961 ); + PlayerTextDrawSetOutline( playerid, handle, 1 ); + PlayerTextDrawSetProportional( playerid, handle, 1 ); + PlayerTextDrawSetSelectable( playerid, handle, 0 ); + + g_damageFeedGivenTD[ playerid ] = handle; + } + + + if ( g_damageFeedTakenTD[ playerid] == PlayerText: INVALID_TEXT_DRAW ) + { + new PlayerText: handle = CreatePlayerTextDraw( playerid, 440.000000, 340.000000,, "_"); + + if ( handle == PlayerText: INVALID_TEXT_DRAW ) + return print("[DAMAGE FEED ERROR]: Unable to create TD (taken damage)" ), 0; + + PlayerTextDrawBackgroundColor( playerid, handle, 255 ); + PlayerTextDrawFont( playerid, handle, 1 ); + PlayerTextDrawLetterSize( playerid, handle, 0.200000, 0.899999 ); + PlayerTextDrawColor( playerid, handle, 16711935 ); + PlayerTextDrawSetOutline( playerid, handle, 1 ); + PlayerTextDrawSetProportional( playerid, handle, 1 ); + PlayerTextDrawSetSelectable( playerid, handle, 0 ); + + g_damageFeedTakenTD[ playerid ] = handle; + } + +/* ** Core ** */ + + new szTick = GetTickCount( ); + if ( szTick == 0) szTick = 1; + new low_tick = ( szTick + 1 ); + + for( new i = 0; i < sizeof( g_damageGiven[ ] ) - 1; i ++) + { + if ( !g_damageGiven[ playerid ][ i ][ E_TICK ] ) { + break; + } + + if ( szTick - g_damageGiven[ playerid ][ i ][ E_TICK ] >= HIDE_FEED_DELAY ) + { + modified = true; + + for (new j = i; j < sizeof( g_damageGiven[ ] ) - 1; j++) { + g_damageGiven[ playerid ][ j ][ E_TICK ] = 0; + } + + break; + } + + if (g_damageGiven[ playerid ][ i ][ E_TICK ] < low_tick) { + low_tick = g_damageGiven[ playerid ][ i ][ E_TICK ]; + } + } + + for( new i = 0; i < sizeof( g_damageTaken[ ] ) - 1; i ++) + { + if ( !g_damageTaken[ playerid ][ i ][ E_TICK ] ) { + break; + } + + if ( szTick - g_damageTaken[ playerid ][ i ][ E_TICK ] >= HIDE_FEED_DELAY ) + { + modified = true; + + for (new j = i; j < sizeof( g_damageTaken[ ] ) - 1; j++) { + g_damageTaken[ playerid ][ j ][ E_TICK ] = 0; + } + + break; + } + + if (g_damageTaken[ playerid ][ i ][ E_TICK ] < low_tick) { + low_tick = g_damageTaken[ playerid ][ i ][ E_TICK ]; + } + } + + if ( p_damageFeedTimer[ playerid ] != -1 ) { + KillTimer( p_damageFeedTimer[ playerid ] ); + } + + if ( szTick - p_lastFeedUpdate[ playerid ] < MAX_UPDATE_RATE && modified ) + { + p_damageFeedTimer[ playerid ] = SetTimerEx( "OnPlayerFeedUpdate", MAX_UPDATE_RATE - ( szTick - low_tick ) + 10, false, "d", playerid ); + } + else + { + if ( lowest_tick == tick + 1 ) { + p_damageFeedTimer[playerid] = -1; + modified = true; + } else { + p_damageFeedTimer[playerid] = SetTimerEx( "OnPlayerFeedUpdate", HIDE_FEED_DELAY - ( szTick - lowest_tick ) + 10, false, "i", playerid ); + } + + if (modified) + { + UpdateDamageFeedLabel( playerid ); + + p_lastFeedUpdate[ playerid ] = szTick; + } + } +} + +stock UpdateDamageFeedLabel( playerid ) +{ + new + szLabel[ 64 * MAX_FEED_HEIGHT ] + ; + + FOR +} \ No newline at end of file From 0d442f4e781020f1e2797a9e3aa153e8126c6525 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 10:37:47 +0100 Subject: [PATCH 02/25] damage feed changes --- .../irresistible/anticheat/damage_feed.pwn | 271 +++++++++++++++--- 1 file changed, 237 insertions(+), 34 deletions(-) diff --git a/gamemodes/irresistible/anticheat/damage_feed.pwn b/gamemodes/irresistible/anticheat/damage_feed.pwn index 813c7dc..276c1f9 100644 --- a/gamemodes/irresistible/anticheat/damage_feed.pwn +++ b/gamemodes/irresistible/anticheat/damage_feed.pwn @@ -8,11 +8,21 @@ /* ** Includes ** */ #include < YSI\y_hooks > +/* ** Macros ** */ +#define IsDamageFeedActive(%0) (p_FeedActive{%0}) + /* ** Definitions ** */ #define MAX_FEED_HEIGHT ( 5 ) #define HIDE_FEED_DELAY ( 3000 ) #define MAX_UPDATE_RATE ( 250 ) +#define TYPE_NONE ( 0 ) +#define TYPE_GIVEN ( 1 ) +#define TYPE_TAKEN ( 2 ) + +/* ** Forwards ** */ +forward OnPlayerFeedUpdate( playerid ); + /* ** Variables ** */ enum E_DAMAGE_FEED { @@ -20,44 +30,67 @@ enum E_DAMAGE_FEED E_WEAPON, E_TICK, }; -static stock +new 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: g_damageFeedGivenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, p_damageFeedTimer [ MAX_PLAYERS ], + bool: p_FeedActive [ MAX_PLAYERS char ], p_lastFeedUpdate [ MAX_PLAYERS ] ; /* ** Hooks ** */ hook OnPlayerConnect( playerid ) { - for( new i = 0; i < sizeof( g_damageGiven[ ] ); i ++) { - g_damageGiven[ playerid ][ i ][ E_TICK ] = 0; - g_damageTaken[ playerid ][ i ][ E_TICK ] = 0; + for( new x = 0; x < sizeof( g_damageGiven[ ] ); x ++) { + g_damageGiven[ playerid ][ x ][ E_TICK ] = 0; + g_damageTaken[ playerid ][ x ][ E_TICK ] = 0; } p_lastFeedUpdate[ playerid ] = GetTickCount( ); return 1; } + /* ** Functions ** */ -function OnPlayerFeedUpdate( playerid ) +public OnPlayerFeedUpdate( playerid ) { + p_damageFeedTimer[ playerid ] = -1; + + if ( IsPlayerConnected( playerid ) && IsDamageFeedActive( playerid ) ) { + UpdateDamageFeed( playerid, true ); + } + return 1; } stock UpdateDamageFeed( playerid, bool: modified = false ) { -/* ** Textdraws ** */ + if ( !IsDamageFeedActive( playerid ) ) + { + if ( g_damageFeedGivenTD[ playerid ] != PlayerText: INVALID_TEXT_DRAW ) { + PlayerTextDrawDestroy( playerid, g_damageFeedGivenTD[ playerid ] ); + g_damageFeedGivenTD[ playerid ] = PlayerText: INVALID_TEXT_DRAW; + } + + if ( g_damageFeedTakenTD[ playerid ] != PlayerText: INVALID_TEXT_DRAW ) { + PlayerTextDrawDestroy( playerid, g_damageFeedTakenTD[ playerid ] ); + g_damageFeedTakenTD[ playerid ] = PlayerText: INVALID_TEXT_DRAW; + } + + return 1; + } + + /* ** Textdraws ** */ if ( g_damageFeedGivenTD[ playerid] == PlayerText: INVALID_TEXT_DRAW ) { new PlayerText: handle = CreatePlayerTextDraw( playerid, 200.000000, 340.000000, "_"); if ( handle == PlayerText: INVALID_TEXT_DRAW ) - return print("[DAMAGE FEED ERROR]: Unable to create TD (given damage)" ), 0; + return print("[DAMAGE FEED ERROR]: Unable to create TD (given damage)" ); PlayerTextDrawAlignment( playerid, handle, 2 ); PlayerTextDrawBackgroundColor( playerid, handle, 255 ); @@ -71,13 +104,12 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) g_damageFeedGivenTD[ playerid ] = handle; } - if ( g_damageFeedTakenTD[ playerid] == PlayerText: INVALID_TEXT_DRAW ) { - new PlayerText: handle = CreatePlayerTextDraw( playerid, 440.000000, 340.000000,, "_"); + new PlayerText: handle = CreatePlayerTextDraw( playerid, 440.000000, 340.000000, "_"); if ( handle == PlayerText: INVALID_TEXT_DRAW ) - return print("[DAMAGE FEED ERROR]: Unable to create TD (taken damage)" ), 0; + return print("[DAMAGE FEED ERROR]: Unable to create TD (taken damage)" ); PlayerTextDrawBackgroundColor( playerid, handle, 255 ); PlayerTextDrawFont( playerid, handle, 1 ); @@ -90,53 +122,52 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) g_damageFeedTakenTD[ playerid ] = handle; } -/* ** Core ** */ - + /* ** Core ** */ new szTick = GetTickCount( ); - if ( szTick == 0) szTick = 1; - new low_tick = ( szTick + 1 ); + if ( szTick == 0 ) szTick = 1; + new lowest_tick = szTick + 1; - for( new i = 0; i < sizeof( g_damageGiven[ ] ) - 1; i ++) + for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++) { - if ( !g_damageGiven[ playerid ][ i ][ E_TICK ] ) { + if ( !g_damageGiven[ playerid ][ givenid ][ E_TICK ] ) { break; } - if ( szTick - g_damageGiven[ playerid ][ i ][ E_TICK ] >= HIDE_FEED_DELAY ) + if ( szTick - g_damageGiven[ playerid ][ givenid ][ E_TICK ] >= HIDE_FEED_DELAY ) { modified = true; - for (new j = i; j < sizeof( g_damageGiven[ ] ) - 1; j++) { + for( new j = givenid; j < sizeof( g_damageGiven[ ] ) - 1; j++ ) { g_damageGiven[ playerid ][ j ][ E_TICK ] = 0; } break; } - if (g_damageGiven[ playerid ][ i ][ E_TICK ] < low_tick) { - low_tick = g_damageGiven[ playerid ][ i ][ E_TICK ]; + if ( g_damageGiven[ playerid ][ givenid ][ E_TICK ] < lowest_tick ) { + lowest_tick = g_damageGiven[ playerid ][ givenid ][ E_TICK ]; } } - for( new i = 0; i < sizeof( g_damageTaken[ ] ) - 1; i ++) + for( new takenid = 0; takenid < sizeof( g_damageTaken[ ] ) - 1; takenid ++) { - if ( !g_damageTaken[ playerid ][ i ][ E_TICK ] ) { + if ( !g_damageTaken[ playerid ][ takenid ][ E_TICK ] ) { break; } - if ( szTick - g_damageTaken[ playerid ][ i ][ E_TICK ] >= HIDE_FEED_DELAY ) + if ( szTick - g_damageTaken[ playerid ][ takenid ][ E_TICK ] >= HIDE_FEED_DELAY ) { modified = true; - for (new j = i; j < sizeof( g_damageTaken[ ] ) - 1; j++) { + for( new j = takenid; j < sizeof( g_damageTaken[ ] ) - 1; j++ ) { g_damageTaken[ playerid ][ j ][ E_TICK ] = 0; } break; } - if (g_damageTaken[ playerid ][ i ][ E_TICK ] < low_tick) { - low_tick = g_damageTaken[ playerid ][ i ][ E_TICK ]; + if ( g_damageTaken[ playerid ][ takenid ][ E_TICK ] < lowest_tick ) { + lowest_tick = g_damageTaken[ playerid ][ takenid ][ E_TICK ]; } } @@ -144,16 +175,19 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) KillTimer( p_damageFeedTimer[ playerid ] ); } - if ( szTick - p_lastFeedUpdate[ playerid ] < MAX_UPDATE_RATE && modified ) + if ( ( szTick - p_lastFeedUpdate[ playerid ] ) < MAX_UPDATE_RATE && modified ) { - p_damageFeedTimer[ playerid ] = SetTimerEx( "OnPlayerFeedUpdate", MAX_UPDATE_RATE - ( szTick - low_tick ) + 10, false, "d", playerid ); + p_damageFeedTimer[ playerid ] = SetTimerEx( "OnPlayerFeedUpdate", MAX_UPDATE_RATE - ( szTick - lowest_tick ) + 10, false, "d", playerid ); } else { - if ( lowest_tick == tick + 1 ) { + if ( lowest_tick == ( szTick + 1 ) ) + { p_damageFeedTimer[playerid] = -1; modified = true; - } else { + } + else + { p_damageFeedTimer[playerid] = SetTimerEx( "OnPlayerFeedUpdate", HIDE_FEED_DELAY - ( szTick - lowest_tick ) + 10, false, "i", playerid ); } @@ -164,13 +198,182 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) p_lastFeedUpdate[ playerid ] = szTick; } } + + return 1; } stock UpdateDamageFeedLabel( playerid ) { new - szLabel[ 64 * MAX_FEED_HEIGHT ] - ; + szLabel[ 64 * MAX_FEED_HEIGHT ] = ""; - FOR + for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++) + { + if ( !g_damageGiven[ playerid ][ givenid ][ E_TICK ] ) + break; + + new szWeapon[ 32 ]; + + if ( g_damageGiven[ playerid ][ givenid ][ E_WEAPON ] == -1 ) { + szWeapon = "Multiple"; + } + else { + GetWeaponName( g_damageGiven[ playerid ][ givenid ][ E_WEAPON ], szWeapon, sizeof( szWeapon ) ); + } + + if ( g_damageGiven[ playerid ][ givenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) + { + format( szLabel, sizeof( szLabel ), "%s%s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); + } + else + { + format( szLabel, sizeof( szLabel ), "%s%s - %s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); + } + } + + if ( g_damageFeedGivenTD[ playerid ] == PlayerText: INVALID_TEXT_DRAW ) { + print( "[DAMAGE FEED ERROR] Doesn't have feed textdraw when needed ( g_damageFeedGivenTD )" ); + } + else + { + if ( szLabel[ 0 ] ) + { + PlayerTextDrawSetString( playerid, g_damageFeedGivenTD[ playerid ], szLabel ); + PlayerTextDrawShow( playerid, g_damageFeedGivenTD[ playerid ] ); + } + else + { + PlayerTextDrawHide( playerid, g_damageFeedGivenTD[ playerid ] ); + } + } + + szLabel = ""; + + for( new takenid = 0; takenid < sizeof( g_damageTaken[ ] ) - 1; takenid ++) + { + if ( !g_damageTaken[ playerid ][ takenid ][ E_TICK ] ) + break; + + new szWeapon[ 32 ]; + + if ( g_damageTaken[ playerid ][ takenid ][ E_WEAPON ] == -1 ) { + szWeapon = "Multiple"; + } + else { + GetWeaponName( g_damageTaken[ playerid ][ takenid ][ E_WEAPON ], szWeapon, sizeof( szWeapon ) ); + } + + if ( g_damageTaken[ playerid ][ takenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) + { + format( szLabel, sizeof( szLabel ), "%s%s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); + } + else + { + format( szLabel, sizeof( szLabel ), "%s%s - %s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); + } + } + + if ( g_damageFeedTakenTD[ playerid ] == PlayerText: INVALID_TEXT_DRAW ) { + print( "[DAMAGE FEED ERROR] Doesn't have feed textdraw when needed ( g_damageFeedTakenTD )" ); + } + else + { + if ( szLabel[ 0 ] ) + { + PlayerTextDrawSetString( playerid, g_damageFeedTakenTD[ playerid ], szLabel ); + PlayerTextDrawShow( playerid, g_damageFeedTakenTD[ playerid ] ); + } + else + { + PlayerTextDrawHide( playerid, g_damageFeedTakenTD[ playerid ] ); + } + } +} + +stock RemoveDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], index ) +{ + for( new i = 0; i < MAX_FEED_HEIGHT; i ++ ) + { + if ( i >= index ) { + array[ i ][ E_TICK ] = 0; + } + } +} + +stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issuerid, Float: amount, weapon ) +{ + if ( ! IsDamageFeedActive( playerid ) ) { + return; + } + + new szTick = GetTickCount( ); + if ( szTick == 0 ) szTick = 1; + new wID = -1; + + for( new i = 0; i < sizeof( array ); i ++ ) + { + if ( ! array[ i ][ E_TICK ] ) { + break; + } + + if ( szTick - array[ i ][ E_TICK ] >= HIDE_FEED_DELAY ) { + RemoveDamageHit( array, i ); + break; + } + + if ( array[ i ][ E_ISSUER ] == issuerid ) + { + amount += array[ i ][ E_AMOUNT ]; + wID = i; + break; + } + } + + if ( wID == -1 ) + { + wID = 0; + + for( new i = sizeof( array ) - 1; i >= 1; i -- ) + { + array[ i ] = array[ i - 1 ]; + } + } + + array[ wID ][ E_TICK ] = szTick; + array[ wID ][ E_AMOUNT ] = amount; + array[ wID ][ E_ISSUER ] = issuerid; + array[ wID ][ E_WEAPON ] = weapon; + + GetPlayerName( playerid, array[ wID ][ E_NAME ] , MAX_PLAYER_NAME ); + + UpdateDamageFeed( playerid, true ); +} + +stock AddDamageFeedHit( playerid, issuerid, Float: amount, weaponid, type ) +{ + if ( type == TYPE_GIVEN ) + { + foreach( new i : Player ) if ( i != playerid) { + AddDamageHit( g_damageGiven[ i ], i, issuerid, amount, weaponid ); + } + + AddDamageHit( g_damageGiven[ playerid ], playerid, issuerid, amount, weaponid ); + } + else if ( type == TYPE_TAKEN ) + { + foreach( new i : Player ) if ( i != playerid) { + AddDamageHit( g_damageTaken[ i ], i, issuerid, amount, weaponid ); + } + + AddDamageHit( g_damageTaken[ playerid ], playerid, issuerid, amount, weaponid ); + } +} + +/* ** Commands ** */ +CMD:feed( playerid, params[ ] ) +{ + p_FeedActive{ playerid } = !p_FeedActive{ playerid }; + + SendClientMessageFormatted( playerid, -1, ""COL_GREY"[SERVER]"COL_WHITE" You have %s the damage feed.", p_FeedActive{ playerid } ? ( "toggled" ) : ( "un-toggled" ) ); + return 1; } \ No newline at end of file From 9fd02514c426714b13516d7cdd567f6a652a41ed Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 10:41:35 +0100 Subject: [PATCH 03/25] fixing the wrong player index selected for damage. --- gamemodes/irresistible/anticheat/damage_feed.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/anticheat/damage_feed.pwn b/gamemodes/irresistible/anticheat/damage_feed.pwn index 276c1f9..5b5a06e 100644 --- a/gamemodes/irresistible/anticheat/damage_feed.pwn +++ b/gamemodes/irresistible/anticheat/damage_feed.pwn @@ -344,7 +344,7 @@ stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issueri array[ wID ][ E_ISSUER ] = issuerid; array[ wID ][ E_WEAPON ] = weapon; - GetPlayerName( playerid, array[ wID ][ E_NAME ] , MAX_PLAYER_NAME ); + GetPlayerName( issuerid, array[ wID ][ E_NAME ] , MAX_PLAYER_NAME ); UpdateDamageFeed( playerid, true ); } From 9d3fc9838eae6a3f4920e28ba2b27c5ffb2142a8 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 11:10:16 +0100 Subject: [PATCH 04/25] moved into features changed the colors of textdraws --- .../{anticheat => cnr/features}/damage_feed.pwn | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) rename gamemodes/irresistible/{anticheat => cnr/features}/damage_feed.pwn (92%) diff --git a/gamemodes/irresistible/anticheat/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn similarity index 92% rename from gamemodes/irresistible/anticheat/damage_feed.pwn rename to gamemodes/irresistible/cnr/features/damage_feed.pwn index 5b5a06e..4a90397 100644 --- a/gamemodes/irresistible/anticheat/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -1,7 +1,7 @@ /* * Irresistible Gaming (c) 2018 * Developed by Steven Howard - * Module: anticheat/damage_feed.pwn + * Module: cnr/features/damage_feed.pwn * Purpose: damage feed for dmers */ @@ -16,10 +16,12 @@ #define HIDE_FEED_DELAY ( 3000 ) #define MAX_UPDATE_RATE ( 250 ) -#define TYPE_NONE ( 0 ) #define TYPE_GIVEN ( 1 ) #define TYPE_TAKEN ( 2 ) +#define DAMAGE_GIVEN_COLOR "~~" +#define DAMAGE_TAKEN_COLOR "~~" + /* ** Forwards ** */ forward OnPlayerFeedUpdate( playerid ); @@ -54,7 +56,6 @@ hook OnPlayerConnect( playerid ) return 1; } - /* ** Functions ** */ public OnPlayerFeedUpdate( playerid ) { @@ -223,11 +224,11 @@ stock UpdateDamageFeedLabel( playerid ) if ( g_damageGiven[ playerid ][ givenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s%s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s~g~~h~%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); } else { - format( szLabel, sizeof( szLabel ), "%s%s - %s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s~g~~h~%s - %s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); } } @@ -265,11 +266,11 @@ stock UpdateDamageFeedLabel( playerid ) if ( g_damageTaken[ playerid ][ takenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s%s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s~b~~h~%s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); } else { - format( szLabel, sizeof( szLabel ), "%s%s - %s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s~b~~h~%s - %s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); } } From 0405aa45a49571bcb09c22d6063c259ed4f9474e Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 11:13:17 +0100 Subject: [PATCH 05/25] remove invalid defines --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 3 --- 1 file changed, 3 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 4a90397..c8b7366 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -19,9 +19,6 @@ #define TYPE_GIVEN ( 1 ) #define TYPE_TAKEN ( 2 ) -#define DAMAGE_GIVEN_COLOR "~~" -#define DAMAGE_TAKEN_COLOR "~~" - /* ** Forwards ** */ forward OnPlayerFeedUpdate( playerid ); From 71dc423e884332841a0d1ca17ac957d8293b9010 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 11:26:08 +0100 Subject: [PATCH 06/25] added callback to return the damage given/taken --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index c8b7366..6683a83 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -21,6 +21,7 @@ /* ** Forwards ** */ forward OnPlayerFeedUpdate( playerid ); +forward OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart ); /* ** Variables ** */ enum E_DAMAGE_FEED @@ -54,6 +55,17 @@ hook OnPlayerConnect( playerid ) } /* ** Functions ** */ +public OnPlayerTakenDamageFeed( playerid, issuerid, Float: amount, weaponid, bodypart ) +{ + if ( issuerid != INVALID_PLAYER_ID ) + { + AddDamageFeedHit( issuerid, playerid, amount, weaponid, TYPE_GIVEN ); + } + + AddDamageFeedHit( playerid, issuerid, amount, weaponid, TYPE_TAKEN ); + return 1; +} + public OnPlayerFeedUpdate( playerid ) { p_damageFeedTimer[ playerid ] = -1; From 5c635493e70b95a83e8aa14df4efe7d8479870c3 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 11:26:41 +0100 Subject: [PATCH 07/25] cleanup --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 6683a83..8941418 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -21,7 +21,7 @@ /* ** Forwards ** */ forward OnPlayerFeedUpdate( playerid ); -forward OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart ); +forward OnPlayerTakenDamageFeed( playerid, issuerid, Float: amount, weaponid, bodypart ); /* ** Variables ** */ enum E_DAMAGE_FEED From a57114f4c126f05de64dfe3bd494823229734c59 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 14:06:18 +0100 Subject: [PATCH 08/25] textdraw placements --- .../irresistible/cnr/features/_features.pwn | 2 +- .../irresistible/cnr/features/damage_feed.pwn | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 64dbe09..3652200 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -38,7 +38,7 @@ #include "irresistible\cnr\features\crime_reports.pwn" #include "irresistible\cnr\features\fires.pwn" #include "irresistible\cnr\features\car_jacker.pwn" - +#include "irresistible\cnr\features\damage_feed.pwn" // disabled // #include "irresistible\cnr\features\eastereggs.pwn" diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 8941418..469684e 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -19,9 +19,11 @@ #define TYPE_GIVEN ( 1 ) #define TYPE_TAKEN ( 2 ) +#define TEXTDRAW_ADDON ( 120.0 ) + /* ** Forwards ** */ -forward OnPlayerFeedUpdate( playerid ); -forward OnPlayerTakenDamageFeed( playerid, issuerid, Float: amount, weaponid, bodypart ); +forward OnPlayerFeedUpdate ( playerid ); +forward OnPlayerTakenDamageFeed ( playerid, issuerid, Float: amount, weaponid, bodypart ); /* ** Variables ** */ enum E_DAMAGE_FEED @@ -57,11 +59,7 @@ hook OnPlayerConnect( playerid ) /* ** Functions ** */ public OnPlayerTakenDamageFeed( playerid, issuerid, Float: amount, weaponid, bodypart ) { - if ( issuerid != INVALID_PLAYER_ID ) - { - AddDamageFeedHit( issuerid, playerid, amount, weaponid, TYPE_GIVEN ); - } - + AddDamageFeedHit( issuerid, playerid, amount, weaponid, TYPE_GIVEN ); AddDamageFeedHit( playerid, issuerid, amount, weaponid, TYPE_TAKEN ); return 1; } @@ -97,7 +95,7 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) /* ** Textdraws ** */ if ( g_damageFeedGivenTD[ playerid] == PlayerText: INVALID_TEXT_DRAW ) { - new PlayerText: handle = CreatePlayerTextDraw( playerid, 200.000000, 340.000000, "_"); + new PlayerText: handle = CreatePlayerTextDraw( playerid, ( 320.0 - TEXTDRAW_ADDON ), 340.0, "_"); if ( handle == PlayerText: INVALID_TEXT_DRAW ) return print("[DAMAGE FEED ERROR]: Unable to create TD (given damage)" ); @@ -116,7 +114,7 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) if ( g_damageFeedTakenTD[ playerid] == PlayerText: INVALID_TEXT_DRAW ) { - new PlayerText: handle = CreatePlayerTextDraw( playerid, 440.000000, 340.000000, "_"); + new PlayerText: handle = CreatePlayerTextDraw( playerid, ( TEXTDRAW_ADDON + 320.0 ), 340.0, "_"); if ( handle == PlayerText: INVALID_TEXT_DRAW ) return print("[DAMAGE FEED ERROR]: Unable to create TD (taken damage)" ); @@ -384,6 +382,6 @@ CMD:feed( playerid, params[ ] ) { p_FeedActive{ playerid } = !p_FeedActive{ playerid }; - SendClientMessageFormatted( playerid, -1, ""COL_GREY"[SERVER]"COL_WHITE" You have %s the damage feed.", p_FeedActive{ playerid } ? ( "toggled" ) : ( "un-toggled" ) ); + SendServerMessage( playerid, "You have %s the damage feed.", p_FeedActive{ playerid } ? ( "toggled" ) : ( "un-toggled" ) ); return 1; } \ No newline at end of file From 598b0c6fda78f7ab8bd29a823d3c3b5095fee9b3 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 14:21:51 +0100 Subject: [PATCH 09/25] 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 ); } From 45dcae630da457ee3951d6c4482530ddb8e7e297 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 14:35:21 +0100 Subject: [PATCH 10/25] puching all hitsound configuration into one --- .../irresistible/cnr/features/damage_feed.pwn | 54 ++++++++++++++++++- gamemodes/irresistible/cnr/player.pwn | 3 +- gamemodes/sf-cnr.pwn | 46 +--------------- 3 files changed, 56 insertions(+), 47 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 3735e49..28900ad 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -32,6 +32,11 @@ enum E_DAMAGE_FEED E_WEAPON, E_TICK, }; +enum E_HITMARKER_SOUND +{ + E_NAME[ 10 ], E_SOUND_ID, +}; + static stock g_damageGiven [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], g_damageTaken [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], @@ -40,6 +45,12 @@ static stock PlayerText: g_damageFeedGivenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_DamageTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, + g_HitmarkerSounds [ ][ E_HITMARKER_SOUND ] = + { + { "Bell Ding", 17802 }, { "Soft Beep", 5205 }, { "Low Blip", 1138 }, { "Med Blip", 1137 }, + { "High Blip", 1139 }, { "Bling", 5201 } + }, + p_damageFeedTimer [ MAX_PLAYERS ] = { -1, ... }, p_DamageTDTimer [ MAX_PLAYERS ] = { -1, ... }, bool: p_FeedActive [ MAX_PLAYERS char ], @@ -68,6 +79,24 @@ hook OnPlayerConnect( playerid ) return 1; } +hook OnPlayerDisconnect( playerid, reason ) +{ + p_HitmarkerSound{ playerid } = 0; + + return 1; +} + +hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) +{ + if ( dialogid == DIALOG_MODIFY_HITSOUND && response ) + { + p_HitmarkerSound{ playerid } = listitem; + SendClientMessageFormatted( playerid, -1, ""COL_GREY"[SERVER]"COL_WHITE" You have changed your hitmarker sound to "COL_GREY"%s"COL_WHITE".", g_HitmarkerSounds[ listitem ] [ E_NAME ] ); + ShowSoundsMenu( playerid ); + } + + return 1; +} /* ** Functions ** */ function OnHitmarkerHide( playerid ) return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); @@ -428,6 +457,20 @@ stock AddDamageFeedHit( playerid, issuerid, Float: amount, weaponid, type ) } } +stock ShowSoundsMenu( playerid ) +{ + static + szSounds[ 11 * sizeof( g_HitmarkerSounds ) ]; + + if ( szSounds[ 0 ] == '\0' ) + { + for( new i = 0; i < sizeof( g_HitmarkerSounds ); i++ ) + format( szSounds, sizeof( szSounds ), "%s%s\n", szSounds, g_HitmarkerSounds[ i ] [ E_NAME ] ); + } + ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" ); +} + + /* ** Commands ** */ CMD:feed( playerid, params[ ] ) { @@ -435,4 +478,13 @@ CMD:feed( playerid, params[ ] ) SendServerMessage( playerid, "You have %s the damage feed.", p_FeedActive{ playerid } ? ( "toggled" ) : ( "un-toggled" ) ); return 1; -} \ No newline at end of file +} + +CMD:hitmarker( playerid, params[ ] ) +{ + if ( p_VIPLevel[ playerid ] < 1 ) + return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); + + ShowSoundsMenu( playerid ); + return 1; +} diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index 9eff290..16f75f6 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -234,7 +234,8 @@ new p_AimedAtPolice [ MAX_PLAYERS ], bool: p_PassiveModeDisabled [ MAX_PLAYERS char ], p_PassiveModeExpireTimer [ MAX_PLAYERS ] = { -1, ... }, - Text3D: p_PassiveModeLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID } + Text3D: p_PassiveModeLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID }, + p_HitmarkerSound [ MAX_PLAYERS char ] ; /* ** Getters And Setters** */ diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 118c379..9765282 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -365,21 +365,6 @@ stock const } ; -/* ** Hitmarker ** */ -enum E_HITMARKER_SOUND -{ - E_NAME[ 10 ], E_SOUND_ID -}; - -new - g_HitmarkerSounds[ ] [ E_HITMARKER_SOUND ] = - { - { "Bell Ding", 17802 }, { "Soft Beep", 5205 }, { "Low Blip", 1138 }, { "Med Blip", 1137 }, - { "High Blip", 1139 }, { "Bling", 5201 } - }, - p_HitmarkerSound [ MAX_PLAYERS char ] -; - /* ** Race System ** */ #define MAX_RACES ( 32 ) @@ -2259,7 +2244,6 @@ public OnPlayerDisconnect( playerid, reason ) p_AddedEmail { playerid } = false; p_TicketTimestamp[ playerid ] = 0; p_ExtraAssetSlots{ playerid } = 0; - p_HitmarkerSound{ playerid } = 0; p_CasinoRewardsPoints[ playerid ] = 0.0; p_OwnedBusinesses[ playerid ] = 0; p_ExplosiveBullets[ playerid ] = 0; @@ -2955,7 +2939,7 @@ public OnPlayerTakePlayerDamage( playerid, issuerid, &Float: amount, weaponid, b amount *= 1.5; } - CallLocalFunction( "OnPlayerTakenDamage", "ddfdd", playerid, issuerid, amount, weapon, bodypart ); + CallLocalFunction( "OnPlayerTakenDamage", "ddfdd", playerid, issuerid, amount, weaponid, bodypart ); return 1; } #endif @@ -4421,15 +4405,6 @@ thread readplayervipnotes( playerid ) return SendError( playerid, "You do not have any V.I.P notes." ); } -CMD:hitmarker( playerid, params[ ] ) -{ - if ( p_VIPLevel[ playerid ] < 1 ) - return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); - - ShowSoundsMenu( playerid ); - return 1; -} - CMD:t( playerid, params[ ] ) { new @@ -12430,12 +12405,6 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) } } } - if ( dialogid == DIALOG_MODIFY_HITSOUND && response ) - { - p_HitmarkerSound{ playerid } = listitem; - SendClientMessageFormatted( playerid, -1, ""COL_GREY"[SERVER]"COL_WHITE" You have changed your hitmarker sound to "COL_GREY"%s"COL_WHITE".", g_HitmarkerSounds[ listitem ] [ E_NAME ] ); - ShowSoundsMenu( playerid ); - } if ( dialogid == DIALOG_VIP_NOTE && response ) { SendClientMessageToAdmins( -1, ""COL_PINK"[DONOR NEEDS HELP]"COL_GREY" %s(%d) is requesting help with their VIP asset(s). (/viewnotes)", ReturnPlayerName( playerid ), playerid ); @@ -16884,19 +16853,6 @@ thread OnListGangMembers( playerid, gangid, page ) return 1; } -stock ShowSoundsMenu( playerid ) -{ - static - szSounds[ 11 * sizeof( g_HitmarkerSounds ) ]; - - if ( szSounds[ 0 ] == '\0' ) - { - for( new i = 0; i < sizeof( g_HitmarkerSounds ); i++ ) - format( szSounds, sizeof( szSounds ), "%s%s\n", szSounds, g_HitmarkerSounds[ i ] [ E_NAME ] ); - } - ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" ); -} - stock GivePlayerLeoWeapons( playerid ) { GivePlayerWeapon( playerid, 3, 1 ); GivePlayerWeapon( playerid, 22, 250 ); From 110458523d88608ed42746cbd3518e1f26412108 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 16:36:56 +0100 Subject: [PATCH 11/25] changing functions for given/taken feed --- .../irresistible/cnr/features/damage_feed.pwn | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 28900ad..781a457 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -138,9 +138,10 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar /* ** Damage Feed ** */ if ( issuerid != INVALID_PLAYER_ID ) { - AddDamageFeedHit( issuerid, playerid, amount, weaponid, TYPE_GIVEN ); + DamageFeedAddHitGiven( issuerid, playerid, amount, weaponid ); } - AddDamageFeedHit( playerid, issuerid, amount, weaponid, TYPE_TAKEN ); + + DamageFeedAddHitTaken( playerid, issuerid, amount, weaponid ); return 1; } @@ -155,6 +156,24 @@ public OnPlayerFeedUpdate( playerid ) return 1; } +stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid ) +{ + foreach( new i : Player ) if ( i != playerid ) { + AddDamageHit( g_damageGiven[ i ], i, issuerid, amount, weaponid ); + } + + AddDamageHit( g_damageGiven[ playerid ], playerid, issuerid, amount, weaponid ); +} + +stock DamageFeedAddHitTaken( playerid, issuerid, Float: amount, weaponid ) +{ + foreach( new i : Player ) if ( i != playerid ) { + AddDamageHit( g_damageTaken[ i ], i, issuerid, amount, weaponid ); + } + + AddDamageHit( g_damageTaken[ playerid ], playerid, issuerid, amount, weaponid ); +} + stock UpdateDamageFeed( playerid, bool: modified = false ) { if ( !IsDamageFeedActive( playerid ) ) @@ -311,11 +330,11 @@ stock UpdateDamageFeedLabel( playerid ) if ( g_damageGiven[ playerid ][ givenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s~g~~h~%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s~g~~h~%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); } else { - format( szLabel, sizeof( szLabel ), "%s~g~~h~%s - %s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s~g~~h~%s - %s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); } } @@ -437,26 +456,6 @@ stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issueri UpdateDamageFeed( playerid, true ); } -stock AddDamageFeedHit( playerid, issuerid, Float: amount, weaponid, type ) -{ - if ( type == TYPE_GIVEN ) - { - foreach( new i : Player ) if ( i != playerid) { - AddDamageHit( g_damageGiven[ i ], i, issuerid, amount, weaponid ); - } - - AddDamageHit( g_damageGiven[ playerid ], playerid, issuerid, amount, weaponid ); - } - else if ( type == TYPE_TAKEN ) - { - foreach( new i : Player ) if ( i != playerid) { - AddDamageHit( g_damageTaken[ i ], i, issuerid, amount, weaponid ); - } - - AddDamageHit( g_damageTaken[ playerid ], playerid, issuerid, amount, weaponid ); - } -} - stock ShowSoundsMenu( playerid ) { static From f179841d38b945d23470a701481cd3d57d6c2553 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 16:44:11 +0100 Subject: [PATCH 12/25] changed timer durations based on ticks --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 781a457..6109b33 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -284,7 +284,7 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) if ( ( szTick - p_lastFeedUpdate[ playerid ] ) < MAX_UPDATE_RATE && modified ) { - p_damageFeedTimer[ playerid ] = SetTimerEx( "OnPlayerFeedUpdate", MAX_UPDATE_RATE - ( szTick - lowest_tick ) + 10, false, "d", playerid ); + p_damageFeedTimer[ playerid ] = SetTimerEx( "OnPlayerFeedUpdate", MAX_UPDATE_RATE - ( szTick - p_lastFeedUpdate[ playerid ] ) + 10, false, "d", playerid ); } else { From 44f16fcc3d1fca9132e57ce36beb2b089b23cf6c Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 11:56:56 +0100 Subject: [PATCH 13/25] changing targetid --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 6109b33..9a4b80e 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -453,7 +453,7 @@ stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issueri GetPlayerName( issuerid, array[ wID ][ E_NAME ] , MAX_PLAYER_NAME ); - UpdateDamageFeed( playerid, true ); + UpdateDamageFeed( issuerid, true ); } stock ShowSoundsMenu( playerid ) From 23fc8aa6088dec2ba354e8e6208f0106821edfc0 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 13 Oct 2018 00:49:38 +1100 Subject: [PATCH 14/25] spectate check for player --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 9a4b80e..b9297b5 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -98,8 +98,8 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) return 1; } /* ** Functions ** */ -function OnHitmarkerHide( playerid ) - return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); +function OnHitmarkerHide( playerid ) + return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart ) { @@ -158,7 +158,7 @@ public OnPlayerFeedUpdate( playerid ) stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid ) { - foreach( new i : Player ) if ( i != playerid ) { + foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid && i != playerid ) { AddDamageHit( g_damageGiven[ i ], i, issuerid, amount, weaponid ); } @@ -167,7 +167,7 @@ stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid ) stock DamageFeedAddHitTaken( playerid, issuerid, Float: amount, weaponid ) { - foreach( new i : Player ) if ( i != playerid ) { + foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid && i != playerid ) { AddDamageHit( g_damageTaken[ i ], i, issuerid, amount, weaponid ); } @@ -311,7 +311,7 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) stock UpdateDamageFeedLabel( playerid ) { - new + new szLabel[ 64 * MAX_FEED_HEIGHT ] = ""; for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++) From 7fde0d019ec0a002cf895b6e066f244c492e26b0 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 15:07:26 +0100 Subject: [PATCH 15/25] player change --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index b9297b5..1daef2d 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -453,7 +453,7 @@ stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issueri GetPlayerName( issuerid, array[ wID ][ E_NAME ] , MAX_PLAYER_NAME ); - UpdateDamageFeed( issuerid, true ); + UpdateDamageFeed( playerid, true ); } stock ShowSoundsMenu( playerid ) From b73f2bb9e403ccaf5861f0962ca9bf6d00b4fbc4 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 13 Oct 2018 01:12:27 +1100 Subject: [PATCH 16/25] replace hitmarker with damage feed --- .../irresistible/cnr/features/damage_feed.pwn | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 1daef2d..440c3fe 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -1,6 +1,6 @@ /* * Irresistible Gaming (c) 2018 - * Developed by Steven Howard + * Developed by Steven Howard, Oscar "Slice" Broman * Module: cnr/features/damage_feed.pwn * Purpose: damage feed for dmers */ @@ -9,7 +9,7 @@ #include < YSI\y_hooks > /* ** Macros ** */ -#define IsDamageFeedActive(%0) (p_FeedActive{%0}) +#define IsDamageFeedActive(%0) ( IsPlayerSettingToggled( %0, SETTING_HITMARKER ) ) /* ** Definitions ** */ #define MAX_FEED_HEIGHT ( 5 ) @@ -43,7 +43,7 @@ static stock 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, ... }, + //PlayerText: p_DamageTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, g_HitmarkerSounds [ ][ E_HITMARKER_SOUND ] = { @@ -52,8 +52,8 @@ static stock }, p_damageFeedTimer [ MAX_PLAYERS ] = { -1, ... }, - p_DamageTDTimer [ MAX_PLAYERS ] = { -1, ... }, - bool: p_FeedActive [ MAX_PLAYERS char ], + //p_DamageTDTimer [ MAX_PLAYERS ] = { -1, ... }, + //bool: p_FeedActive [ MAX_PLAYERS char ], p_lastFeedUpdate [ MAX_PLAYERS ] ; @@ -68,13 +68,13 @@ hook OnPlayerConnect( playerid ) p_lastFeedUpdate[ playerid ] = GetTickCount( ); /* ** Textdraws ** */ - p_DamageTD[ playerid ] = CreatePlayerTextDraw(playerid, 357.000000, 208.000000, "~r~~h~300.24 DAMAGE"); + /*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); + PlayerTextDrawSetProportional(playerid, p_DamageTD[ playerid ], 1);*/ return 1; } @@ -98,13 +98,13 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) return 1; } /* ** Functions ** */ -function OnHitmarkerHide( playerid ) - return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); +// function OnHitmarkerHide( playerid ) +// return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart ) { /* ** Hitmarker ** */ - if ( IsPlayerSettingToggled( issuerid, SETTING_HITMARKER ) ) + /*if ( IsPlayerSettingToggled( issuerid, SETTING_HITMARKER ) ) { new soundid = p_VIPLevel[ issuerid ] ? p_HitmarkerSound{ issuerid } : 0; @@ -116,10 +116,10 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar KillTimer( p_DamageTDTimer[ issuerid ] ); p_DamageTDTimer[ issuerid ] = SetTimerEx( "OnHitmarkerHide", 3000, false, "d", issuerid ); - } + }*/ /* ** Hitmarker (while spectating) ** */ - foreach ( new i : Player ) + /*foreach ( new i : Player ) { if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid ) { @@ -134,11 +134,21 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar KillTimer( p_DamageTDTimer[ i ] ); p_DamageTDTimer[ i ] = SetTimerEx( "OnHitmarkerHide", 3000, false, "d", i ); } - } + }*/ /* ** Damage Feed ** */ - if ( issuerid != INVALID_PLAYER_ID ) { + if ( issuerid != INVALID_PLAYER_ID ) + { DamageFeedAddHitGiven( issuerid, playerid, amount, weaponid ); + + // play noise + if ( IsDamageFeedActive( issuerid ) ) + { + new + soundid = p_VIPLevel[ issuerid ] ? p_HitmarkerSound{ issuerid } : 0; + + PlayerPlaySound( issuerid, g_HitmarkerSounds[ soundid ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); + } } DamageFeedAddHitTaken( playerid, issuerid, amount, weaponid ); @@ -471,13 +481,13 @@ stock ShowSoundsMenu( playerid ) /* ** Commands ** */ -CMD:feed( playerid, params[ ] ) +/*CMD:feed( playerid, params[ ] ) { p_FeedActive{ playerid } = !p_FeedActive{ playerid }; SendServerMessage( playerid, "You have %s the damage feed.", p_FeedActive{ playerid } ? ( "toggled" ) : ( "un-toggled" ) ); return 1; -} +}*/ CMD:hitmarker( playerid, params[ ] ) { From c45e66e6bb66308f233df9425ec2b6384f3de3d2 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 13 Oct 2018 01:12:47 +1100 Subject: [PATCH 17/25] fix admin spec issue --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 440c3fe..1416453 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -168,7 +168,7 @@ public OnPlayerFeedUpdate( playerid ) stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid ) { - foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid && i != playerid ) { + foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == playerid && i != playerid ) { AddDamageHit( g_damageGiven[ i ], i, issuerid, amount, weaponid ); } @@ -177,7 +177,7 @@ stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid ) stock DamageFeedAddHitTaken( playerid, issuerid, Float: amount, weaponid ) { - foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == issuerid && i != playerid ) { + foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == playerid && i != playerid ) { AddDamageHit( g_damageTaken[ i ], i, issuerid, amount, weaponid ); } From 0250296b2b8ddfe32ff295750785c80905f953c2 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 15:59:20 +0100 Subject: [PATCH 18/25] changes textdraw colors --- .../irresistible/cnr/features/damage_feed.pwn | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 1416453..42e7467 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -19,7 +19,7 @@ #define TYPE_GIVEN ( 1 ) #define TYPE_TAKEN ( 2 ) -#define TEXTDRAW_ADDON ( 120.0 ) +#define TEXTDRAW_ADDON ( 100.0 ) /* ** Forwards ** */ forward OnPlayerFeedUpdate ( playerid ); @@ -209,11 +209,11 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) if ( handle == PlayerText: INVALID_TEXT_DRAW ) return print("[DAMAGE FEED ERROR]: Unable to create TD (given damage)" ); + PlayerTextDrawBackgroundColor(playerid, handle, 117 ); PlayerTextDrawAlignment( playerid, handle, 2 ); - PlayerTextDrawBackgroundColor( playerid, handle, 255 ); PlayerTextDrawFont( playerid, handle, 1 ); PlayerTextDrawLetterSize( playerid, handle, 0.200000, 0.899999 ); - PlayerTextDrawColor( playerid, handle, -16776961 ); + PlayerTextDrawColor( playerid, handle, 0xDD2020FF ); PlayerTextDrawSetOutline( playerid, handle, 1 ); PlayerTextDrawSetProportional( playerid, handle, 1 ); PlayerTextDrawSetSelectable( playerid, handle, 0 ); @@ -228,10 +228,11 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) if ( handle == PlayerText: INVALID_TEXT_DRAW ) return print("[DAMAGE FEED ERROR]: Unable to create TD (taken damage)" ); - PlayerTextDrawBackgroundColor( playerid, handle, 255 ); + PlayerTextDrawBackgroundColor(playerid, handle, 117 ); + PlayerTextDrawAlignment( playerid, handle, 2 ); PlayerTextDrawFont( playerid, handle, 1 ); PlayerTextDrawLetterSize( playerid, handle, 0.200000, 0.899999 ); - PlayerTextDrawColor( playerid, handle, 16711935 ); + PlayerTextDrawColor( playerid, handle, 1069804543 ); PlayerTextDrawSetOutline( playerid, handle, 1 ); PlayerTextDrawSetProportional( playerid, handle, 1 ); PlayerTextDrawSetSelectable( playerid, handle, 0 ); @@ -340,11 +341,11 @@ stock UpdateDamageFeedLabel( playerid ) if ( g_damageGiven[ playerid ][ givenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s~g~~h~%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); + format( szLabel, sizeof( szLabel ), "%s%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); } else { - format( szLabel, sizeof( szLabel ), "%s~g~~h~%s - %s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); + format( szLabel, sizeof( szLabel ), "%s%s - %s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); } } @@ -382,11 +383,11 @@ stock UpdateDamageFeedLabel( playerid ) if ( g_damageTaken[ playerid ][ takenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s~b~~h~%s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s%s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] ); } else { - format( szLabel, sizeof( szLabel ), "%s~b~~h~%s - %s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] + 0.009 ); + format( szLabel, sizeof( szLabel ), "%s%s - %s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] ); } } @@ -479,16 +480,7 @@ stock ShowSoundsMenu( playerid ) ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" ); } - /* ** Commands ** */ -/*CMD:feed( playerid, params[ ] ) -{ - p_FeedActive{ playerid } = !p_FeedActive{ playerid }; - - SendServerMessage( playerid, "You have %s the damage feed.", p_FeedActive{ playerid } ? ( "toggled" ) : ( "un-toggled" ) ); - return 1; -}*/ - CMD:hitmarker( playerid, params[ ] ) { if ( p_VIPLevel[ playerid ] < 1 ) @@ -496,4 +488,4 @@ CMD:hitmarker( playerid, params[ ] ) ShowSoundsMenu( playerid ); return 1; -} +} \ No newline at end of file From bdb45e28d890f400247fb5e2a1fe32be60c462f3 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 17:00:44 +0100 Subject: [PATCH 19/25] moves hitmarkersound into damage_feed.pwn cleanup --- gamemodes/irresistible/cnr/features/_features.pwn | 1 + gamemodes/irresistible/cnr/features/damage_feed.pwn | 6 ++++-- gamemodes/irresistible/cnr/player.pwn | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 3652200..d82c53f 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -39,6 +39,7 @@ #include "irresistible\cnr\features\fires.pwn" #include "irresistible\cnr\features\car_jacker.pwn" #include "irresistible\cnr\features\damage_feed.pwn" + // disabled // #include "irresistible\cnr\features\eastereggs.pwn" diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 42e7467..fee958f 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -37,6 +37,10 @@ enum E_HITMARKER_SOUND E_NAME[ 10 ], E_SOUND_ID, }; +new + p_HitmarkerSound [ MAX_PLAYERS char ] +; + static stock g_damageGiven [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], g_damageTaken [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], @@ -52,8 +56,6 @@ static stock }, p_damageFeedTimer [ MAX_PLAYERS ] = { -1, ... }, - //p_DamageTDTimer [ MAX_PLAYERS ] = { -1, ... }, - //bool: p_FeedActive [ MAX_PLAYERS char ], p_lastFeedUpdate [ MAX_PLAYERS ] ; diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index 16f75f6..9eff290 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -234,8 +234,7 @@ new p_AimedAtPolice [ MAX_PLAYERS ], bool: p_PassiveModeDisabled [ MAX_PLAYERS char ], p_PassiveModeExpireTimer [ MAX_PLAYERS ] = { -1, ... }, - Text3D: p_PassiveModeLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID }, - p_HitmarkerSound [ MAX_PLAYERS char ] + Text3D: p_PassiveModeLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID } ; /* ** Getters And Setters** */ From b74ab57bdf017478def50c8d7ea1f3c06660bbac Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 17:04:19 +0100 Subject: [PATCH 20/25] removes vip requirement to change hitmarker sounds --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 3 --- 1 file changed, 3 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index fee958f..055d271 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -485,9 +485,6 @@ stock ShowSoundsMenu( playerid ) /* ** Commands ** */ CMD:hitmarker( playerid, params[ ] ) { - if ( p_VIPLevel[ playerid ] < 1 ) - return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); - ShowSoundsMenu( playerid ); return 1; } \ No newline at end of file From 52146a04d2938d25731a886eb3792cf5098914db Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 22:13:07 +0100 Subject: [PATCH 21/25] attachs a 3D text label where the player damaged a player (known from dming) --- .../irresistible/cnr/features/damage_feed.pwn | 81 ++++++++++--------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 055d271..ba23dc5 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -12,6 +12,7 @@ #define IsDamageFeedActive(%0) ( IsPlayerSettingToggled( %0, SETTING_HITMARKER ) ) /* ** Definitions ** */ +#define MAX_BULLETS ( 24 ) #define MAX_FEED_HEIGHT ( 5 ) #define HIDE_FEED_DELAY ( 3000 ) #define MAX_UPDATE_RATE ( 250 ) @@ -29,12 +30,12 @@ forward OnPlayerTakenDamage ( playerid, issuerid, Float: amount, weaponid, bod enum E_DAMAGE_FEED { E_ISSUER, E_NAME[ MAX_PLAYER_NAME ], Float: E_AMOUNT, - E_WEAPON, E_TICK, + E_WEAPON, E_TICK }; enum E_HITMARKER_SOUND { - E_NAME[ 10 ], E_SOUND_ID, + E_NAME[ 10 ], E_SOUND_ID }; new @@ -45,6 +46,9 @@ static stock g_damageGiven [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], g_damageTaken [ MAX_PLAYERS ][ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], + Text3D: g_BulletLabel [ MAX_PLAYERS ], + g_BulletTimer [ MAX_PLAYERS ], + 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, ... }, @@ -94,53 +98,47 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) { p_HitmarkerSound{ playerid } = listitem; SendClientMessageFormatted( playerid, -1, ""COL_GREY"[SERVER]"COL_WHITE" You have changed your hitmarker sound to "COL_GREY"%s"COL_WHITE".", g_HitmarkerSounds[ listitem ] [ E_NAME ] ); + + PlayerPlaySound( playerid, g_HitmarkerSounds[ listitem ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); ShowSoundsMenu( playerid ); } return 1; } + /* ** Functions ** */ -// function OnHitmarkerHide( playerid ) -// return PlayerTextDrawHide( playerid, p_DamageTD[ playerid ] ); +function OnHideBulletLabel( playerid ) +{ + DestroyDynamic3DTextLabel( g_BulletLabel[ playerid ] ); + KillTimer( g_BulletTimer[ playerid ] ); g_BulletTimer[ playerid ] = -1; + return 1; +} public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart ) { - /* ** 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 ** */ + /* ** Label Damage Indicator ** */ if ( issuerid != INVALID_PLAYER_ID ) { + static Float: fromX, Float: fromY, Float: fromZ; + static Float: toX, Float: toY, Float: toZ; + + if ( IsValidDynamic3DTextLabel( g_BulletLabel[ issuerid ] ) ) + { + DestroyDynamic3DTextLabel( g_BulletLabel[ issuerid ] ); + + KillTimer( g_BulletTimer[ issuerid ] ); + g_BulletTimer[ issuerid ] = -1; + } + + GetPlayerLastShotVectors( issuerid, fromX, fromY, fromZ, toX, toY, toZ ); + + g_BulletLabel[ issuerid ] = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xC0C0C088, toX, toY, toZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ) ); + Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL ); + + printf( "[LABEL]: Label for %d, at %f %f %f ", playerid, toX, toY, toZ ); + g_BulletTimer[ issuerid ] = SetTimerEx( "OnHideBulletLabel", 3000, false, "d", issuerid ); + + /* ** Hitmarker ** */ DamageFeedAddHitGiven( issuerid, playerid, amount, weaponid ); // play noise @@ -168,6 +166,13 @@ public OnPlayerFeedUpdate( playerid ) return 1; } +stock CreateBulletLabel( playerid, weaponid, Float: amount ) +{ + if ( IsPlayerInCasino( playerid ) || IsPlayerInPaintBall( playerid ) || IsPlayerInEvent( playerid ) || IsPlayerInMinigame( playerid ) ) + return; + +} + stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid ) { foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == playerid && i != playerid ) { From dd9a68eaa4b7ec6a3a8a393e22e36fd2758186fb Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 12 Oct 2018 23:04:18 +0100 Subject: [PATCH 22/25] adds a object above the players head according to what damage has been given (armour and/or health) Inspired by Shini --- .../irresistible/cnr/features/damage_feed.pwn | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index ba23dc5..a8b492e 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -10,9 +10,9 @@ /* ** Macros ** */ #define IsDamageFeedActive(%0) ( IsPlayerSettingToggled( %0, SETTING_HITMARKER ) ) +#define IsPlayerHit(%0) ( p_GotHit{%0} ) /* ** Definitions ** */ -#define MAX_BULLETS ( 24 ) #define MAX_FEED_HEIGHT ( 5 ) #define HIDE_FEED_DELAY ( 3000 ) #define MAX_UPDATE_RATE ( 250 ) @@ -49,6 +49,9 @@ static stock Text3D: g_BulletLabel [ MAX_PLAYERS ], g_BulletTimer [ MAX_PLAYERS ], + p_PlayerDamageObject [ MAX_PLAYERS ], + bool: p_GotHit [ MAX_PLAYERS char ], + 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, ... }, @@ -138,6 +141,24 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar printf( "[LABEL]: Label for %d, at %f %f %f ", playerid, toX, toY, toZ ); g_BulletTimer[ issuerid ] = SetTimerEx( "OnHideBulletLabel", 3000, false, "d", issuerid ); + /* ** Armour and Health Object Damage ** */ + + if ( !IsPlayerHit( playerid ) ) + { + static + Float: fArmour; + + if ( GetPlayerArmour( playerid, fArmour ) ) + { + p_PlayerDamageObject[ playerid ] = CreateObject( fArmour == 0 ? ( 1240 ) : ( 1242 ), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0 ); + AttachObjectToPlayer( p_PlayerDamageObject[ playerid ], playerid, 0.0, 0.0, 1.5, 0.0, 0.0, 0.0 ); + SetTimerEx( "HideDamageObject", 1000, false, "d", playerid ); + + Streamer_Update(playerid, STREAMER_TYPE_OBJECT ); + p_GotHit{ playerid } = true; + } + } + /* ** Hitmarker ** */ DamageFeedAddHitGiven( issuerid, playerid, amount, weaponid ); @@ -155,6 +176,13 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar return 1; } +function HideDamageObject( playerid ) +{ + DestroyObject( p_PlayerDamageObject[ playerid ] ); + p_GotHit{ playerid } = false; + return 1; +} + public OnPlayerFeedUpdate( playerid ) { p_damageFeedTimer[ playerid ] = -1; From 3f96fe199b856b6ce76dce468de687061c6de85d Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 11:12:08 +0100 Subject: [PATCH 23/25] changed from object to a SetPlayerAttachedObject --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index a8b492e..5a5b367 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -150,8 +150,13 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar if ( GetPlayerArmour( playerid, fArmour ) ) { - p_PlayerDamageObject[ playerid ] = CreateObject( fArmour == 0 ? ( 1240 ) : ( 1242 ), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0 ); - AttachObjectToPlayer( p_PlayerDamageObject[ playerid ], playerid, 0.0, 0.0, 1.5, 0.0, 0.0, 0.0 ); + //SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 2, 0.490000, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.027000); + SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 2, 0.799999, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999); + + // SetPlayerAttachedObject(playerid, 4, 1240, 2, 0.655999, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999); + + // p_PlayerDamageObject[ playerid ] = CreateObject( , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0 ); + // AttachObjectToPlayer( p_PlayerDamageObject[ playerid ], playerid, 0.0, 0.0, 1.5, 0.0, 0.0, 0.0 ); SetTimerEx( "HideDamageObject", 1000, false, "d", playerid ); Streamer_Update(playerid, STREAMER_TYPE_OBJECT ); @@ -178,6 +183,9 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar function HideDamageObject( playerid ) { + if( IsPlayerAttachedObjectSlotUsed( playerid, 4 ) ) + RemovePlayerAttachedObject( playerid, 4 ); + DestroyObject( p_PlayerDamageObject[ playerid ] ); p_GotHit{ playerid } = false; return 1; From da428e56b655e3a86885632bb4535adf69d6bd01 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 11:15:35 +0100 Subject: [PATCH 24/25] cleaning up invalid prints and comments --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 5a5b367..0951f52 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -138,7 +138,6 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar g_BulletLabel[ issuerid ] = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xC0C0C088, toX, toY, toZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ) ); Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL ); - printf( "[LABEL]: Label for %d, at %f %f %f ", playerid, toX, toY, toZ ); g_BulletTimer[ issuerid ] = SetTimerEx( "OnHideBulletLabel", 3000, false, "d", issuerid ); /* ** Armour and Health Object Damage ** */ @@ -150,13 +149,7 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar if ( GetPlayerArmour( playerid, fArmour ) ) { - //SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 2, 0.490000, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.027000); SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 2, 0.799999, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999); - - // SetPlayerAttachedObject(playerid, 4, 1240, 2, 0.655999, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999); - - // p_PlayerDamageObject[ playerid ] = CreateObject( , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0 ); - // AttachObjectToPlayer( p_PlayerDamageObject[ playerid ], playerid, 0.0, 0.0, 1.5, 0.0, 0.0, 0.0 ); SetTimerEx( "HideDamageObject", 1000, false, "d", playerid ); Streamer_Update(playerid, STREAMER_TYPE_OBJECT ); From 0e080fcd7cc9319441ef580cfe77b86792f6fcae Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 11:44:55 +0100 Subject: [PATCH 25/25] 3d text is attached to damaged player lifted the object above player name --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 0951f52..e05c372 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -135,7 +135,7 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar GetPlayerLastShotVectors( issuerid, fromX, fromY, fromZ, toX, toY, toZ ); - g_BulletLabel[ issuerid ] = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xC0C0C088, toX, toY, toZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ) ); + g_BulletLabel[ issuerid ] = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xDD202088, toX, toY, toZ, 100.0, playerid, INVALID_VEHICLE_ID, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ) ); Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL ); g_BulletTimer[ issuerid ] = SetTimerEx( "OnHideBulletLabel", 3000, false, "d", issuerid ); @@ -149,7 +149,7 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar if ( GetPlayerArmour( playerid, fArmour ) ) { - SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 2, 0.799999, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999); + SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 1, 1.400000, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999); SetTimerEx( "HideDamageObject", 1000, false, "d", playerid ); Streamer_Update(playerid, STREAMER_TYPE_OBJECT );