From 8f6058b86a94450e07dcdd576fc7a77ac6a293cc Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Thu, 11 Oct 2018 00:40:49 +0100 Subject: [PATCH 01/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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 ); From 763689448f2bf459dbc9f9678483d925304051c8 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 13 Oct 2018 23:21:05 +1100 Subject: [PATCH 26/39] damage feed improvements --- .../irresistible/cnr/features/damage_feed.pwn | 131 +++++++++--------- 1 file changed, 62 insertions(+), 69 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index e05c372..9283629 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -10,7 +10,6 @@ /* ** Macros ** */ #define IsDamageFeedActive(%0) ( IsPlayerSettingToggled( %0, SETTING_HITMARKER ) ) -#define IsPlayerHit(%0) ( p_GotHit{%0} ) /* ** Definitions ** */ #define MAX_FEED_HEIGHT ( 5 ) @@ -38,25 +37,24 @@ enum E_HITMARKER_SOUND E_NAME[ 10 ], E_SOUND_ID }; -new +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 ], + 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 ], + //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, ... }, - g_HitmarkerSounds [ ][ E_HITMARKER_SOUND ] = + g_HitmarkerSounds [ ] [ E_HITMARKER_SOUND ] = { { "Bell Ding", 17802 }, { "Soft Beep", 5205 }, { "Low Blip", 1138 }, { "Med Blip", 1137 }, { "High Blip", 1139 }, { "Bling", 5201 } @@ -70,8 +68,8 @@ static stock hook OnPlayerConnect( playerid ) { for( new x = 0; x < sizeof( g_damageGiven[ ] ); x ++) { - g_damageGiven[ playerid ][ x ][ E_TICK ] = 0; - g_damageTaken[ playerid ][ x ][ E_TICK ] = 0; + g_damageGiven[ playerid ] [ x ] [ E_TICK ] = 0; + g_damageTaken[ playerid ] [ x ] [ E_TICK ] = 0; } p_lastFeedUpdate[ playerid ] = GetTickCount( ); @@ -101,7 +99,7 @@ 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 ); } @@ -110,10 +108,9 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) } /* ** Functions ** */ -function OnHideBulletLabel( playerid ) +function DamageFeed_HideBulletLabel( labelid ) { - DestroyDynamic3DTextLabel( g_BulletLabel[ playerid ] ); - KillTimer( g_BulletTimer[ playerid ] ); g_BulletTimer[ playerid ] = -1; + DestroyDynamic3DTextLabel( Text3D: labelid ); return 1; } @@ -125,34 +122,31 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar 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 ), 0xDD202088, toX, toY, toZ, 100.0, playerid, INVALID_VEHICLE_ID, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ) ); - Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL ); + new + Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerVirtualWorld( playerid ), .worldid = GetPlayerInterior( playerid ), .testlos = 1 ); - g_BulletTimer[ issuerid ] = SetTimerEx( "OnHideBulletLabel", 3000, false, "d", issuerid ); + if ( IsValidDynamic3DTextLabel( bullet_label ) ) + { + Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL ); + Streamer_Update( playerid, STREAMER_TYPE_3D_TEXT_LABEL ); + SetTimerEx( "DamageFeed_HideBulletLabel", 1250, false, "d", _: bullet_label ); + } /* ** Armour and Health Object Damage ** */ - if ( !IsPlayerHit( playerid ) ) + if ( ! p_GotHit{ playerid } ) { - static - Float: fArmour; + static + Float: armour; - if ( GetPlayerArmour( playerid, fArmour ) ) + if ( GetPlayerArmour( playerid, armour ) ) { - 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); + SetPlayerAttachedObject( playerid, 4, armour - amount <= 0.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 ); + + Streamer_Update( playerid, STREAMER_TYPE_OBJECT ); p_GotHit{ playerid } = true; } } @@ -177,9 +171,8 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar function HideDamageObject( playerid ) { if( IsPlayerAttachedObjectSlotUsed( playerid, 4 ) ) - RemovePlayerAttachedObject( playerid, 4 ); + RemovePlayerAttachedObject( playerid, 4 ); - DestroyObject( p_PlayerDamageObject[ playerid ] ); p_GotHit{ playerid } = false; return 1; } @@ -283,45 +276,45 @@ stock UpdateDamageFeed( playerid, bool: modified = false ) for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++) { - if ( !g_damageGiven[ playerid ][ givenid ][ E_TICK ] ) { + if ( !g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] ) { break; } - if ( szTick - g_damageGiven[ playerid ][ givenid ][ E_TICK ] >= HIDE_FEED_DELAY ) + if ( szTick - g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] >= HIDE_FEED_DELAY ) { modified = true; for( new j = givenid; j < sizeof( g_damageGiven[ ] ) - 1; j++ ) { - g_damageGiven[ playerid ][ j ][ E_TICK ] = 0; + g_damageGiven[ playerid ] [ j ] [ E_TICK ] = 0; } break; } - if ( g_damageGiven[ playerid ][ givenid ][ E_TICK ] < lowest_tick ) { - lowest_tick = g_damageGiven[ playerid ][ givenid ][ E_TICK ]; + if ( g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] < lowest_tick ) { + lowest_tick = g_damageGiven[ playerid ] [ givenid ] [ E_TICK ]; } } for( new takenid = 0; takenid < sizeof( g_damageTaken[ ] ) - 1; takenid ++) { - if ( !g_damageTaken[ playerid ][ takenid ][ E_TICK ] ) { + if ( !g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] ) { break; } - if ( szTick - g_damageTaken[ playerid ][ takenid ][ E_TICK ] >= HIDE_FEED_DELAY ) + if ( szTick - g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] >= HIDE_FEED_DELAY ) { modified = true; for( new j = takenid; j < sizeof( g_damageTaken[ ] ) - 1; j++ ) { - g_damageTaken[ playerid ][ j ][ E_TICK ] = 0; + g_damageTaken[ playerid ] [ j ] [ E_TICK ] = 0; } break; } - if ( g_damageTaken[ playerid ][ takenid ][ E_TICK ] < lowest_tick ) { - lowest_tick = g_damageTaken[ playerid ][ takenid ][ E_TICK ]; + if ( g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] < lowest_tick ) { + lowest_tick = g_damageTaken[ playerid ] [ takenid ] [ E_TICK ]; } } @@ -363,25 +356,25 @@ stock UpdateDamageFeedLabel( playerid ) for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++) { - if ( !g_damageGiven[ playerid ][ givenid ][ E_TICK ] ) + if ( !g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] ) break; new szWeapon[ 32 ]; - if ( g_damageGiven[ playerid ][ givenid ][ E_WEAPON ] == -1 ) { + if ( g_damageGiven[ playerid ] [ givenid ] [ E_WEAPON ] == -1 ) { szWeapon = "Multiple"; } else { - GetWeaponName( g_damageGiven[ playerid ][ givenid ][ E_WEAPON ], szWeapon, sizeof( szWeapon ) ); + GetWeaponName( g_damageGiven[ playerid ] [ givenid ] [ E_WEAPON ], szWeapon, sizeof( szWeapon ) ); } - if ( g_damageGiven[ playerid ][ givenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) + if ( g_damageGiven[ playerid ] [ givenid ] [ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] ); + format( szLabel, sizeof( szLabel ), "%s%s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ] [ givenid ] [ E_AMOUNT ] ); } else { - format( szLabel, sizeof( szLabel ), "%s%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 +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ] [ givenid ] [ E_NAME ], g_damageGiven[ playerid ] [ givenid ] [ E_AMOUNT ] ); } } @@ -405,25 +398,25 @@ stock UpdateDamageFeedLabel( playerid ) for( new takenid = 0; takenid < sizeof( g_damageTaken[ ] ) - 1; takenid ++) { - if ( !g_damageTaken[ playerid ][ takenid ][ E_TICK ] ) + if ( !g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] ) break; new szWeapon[ 32 ]; - if ( g_damageTaken[ playerid ][ takenid ][ E_WEAPON ] == -1 ) { + if ( g_damageTaken[ playerid ] [ takenid ] [ E_WEAPON ] == -1 ) { szWeapon = "Multiple"; } else { - GetWeaponName( g_damageTaken[ playerid ][ takenid ][ E_WEAPON ], szWeapon, sizeof( szWeapon ) ); + GetWeaponName( g_damageTaken[ playerid ] [ takenid ] [ E_WEAPON ], szWeapon, sizeof( szWeapon ) ); } - if ( g_damageTaken[ playerid ][ takenid ][ E_ISSUER ] == INVALID_PLAYER_ID ) + if ( g_damageTaken[ playerid ] [ takenid ] [ E_ISSUER ] == INVALID_PLAYER_ID ) { - format( szLabel, sizeof( szLabel ), "%s%s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] ); + format( szLabel, sizeof( szLabel ), "%s%s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ] [ takenid ] [ E_AMOUNT ] ); } else { - format( szLabel, sizeof( szLabel ), "%s%s - %s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] ); + format( szLabel, sizeof( szLabel ), "%s%s - %s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ] [ takenid ] [ E_NAME ], g_damageTaken[ playerid ] [ takenid ] [ E_AMOUNT ] ); } } @@ -444,17 +437,17 @@ stock UpdateDamageFeedLabel( playerid ) } } -stock RemoveDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], index ) +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; + array[ i ] [ E_TICK ] = 0; } } } -stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issuerid, Float: amount, weapon ) +stock AddDamageHit( array[ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ], playerid, issuerid, Float: amount, weapon ) { if ( ! IsDamageFeedActive( playerid ) ) { return; @@ -466,18 +459,18 @@ stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issueri for( new i = 0; i < sizeof( array ); i ++ ) { - if ( ! array[ i ][ E_TICK ] ) { + if ( ! array[ i ] [ E_TICK ] ) { break; } - if ( szTick - array[ i ][ E_TICK ] >= HIDE_FEED_DELAY ) { + if ( szTick - array[ i ] [ E_TICK ] >= HIDE_FEED_DELAY ) { RemoveDamageHit( array, i ); break; } - if ( array[ i ][ E_ISSUER ] == issuerid ) + if ( array[ i ] [ E_ISSUER ] == issuerid ) { - amount += array[ i ][ E_AMOUNT ]; + amount += array[ i ] [ E_AMOUNT ]; wID = i; break; } @@ -493,12 +486,12 @@ stock AddDamageHit( array[ MAX_FEED_HEIGHT ][ E_DAMAGE_FEED ], playerid, issueri } } - array[ wID ][ E_TICK ] = szTick; - array[ wID ][ E_AMOUNT ] = amount; - array[ wID ][ E_ISSUER ] = issuerid; - array[ wID ][ E_WEAPON ] = weapon; + array[ wID ] [ E_TICK ] = szTick; + array[ wID ] [ E_AMOUNT ] = amount; + array[ wID ] [ E_ISSUER ] = issuerid; + array[ wID ] [ E_WEAPON ] = weapon; - GetPlayerName( issuerid, array[ wID ][ E_NAME ] , MAX_PLAYER_NAME ); + GetPlayerName( issuerid, array[ wID ] [ E_NAME ] , MAX_PLAYER_NAME ); UpdateDamageFeed( playerid, true ); } @@ -521,4 +514,4 @@ CMD:hitmarker( playerid, params[ ] ) { ShowSoundsMenu( playerid ); return 1; -} \ No newline at end of file +} From e46ece5acefef2dac30aa177438c0a287c3a496d Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 14:07:39 +0100 Subject: [PATCH 27/39] removes invalid vehicles http://forum.sfcnr.com/showthread.php?60671-Infernus-placements --- gamemodes/irresistible/cnr/static/server_vehicles.pwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamemodes/irresistible/cnr/static/server_vehicles.pwn b/gamemodes/irresistible/cnr/static/server_vehicles.pwn index 7913664..7f2e56a 100644 --- a/gamemodes/irresistible/cnr/static/server_vehicles.pwn +++ b/gamemodes/irresistible/cnr/static/server_vehicles.pwn @@ -112,7 +112,7 @@ static stock InitializeServerVehicles( ) AddStaticVehicle( 511, -1245.295776, -95.022689, 15.472208, 135.868728, -1, -1 ); AddStaticVehicle( 563, -1185.826293, 25.737642, 14.870979, 226.734649, -1, -1 ); AddStaticVehicle( 563, -1224.193359, -10.034203, 14.869047, 223.632965, -1, -1 ); - AddStaticVehicle( 411, -1238.649780, 50.157535, 13.858886, 225.435058, -1, -1 ); + //AddStaticVehicle( 411, -1238.649780, 50.157535, 13.858886, 225.435058, -1, -1 ); AddStaticVehicle( 522, -1241.090942, 63.254283, 13.680734, 44.845169, -1, -1 ); AddStaticVehicleEx( 597, -1634.655029, 651.717651, 6.954792, 180.744827, -1, -1, 240, 1 ); AddStaticVehicle( 497, -1682.705566, 705.820434, 30.778402, 90.953826, -1, -1 ); @@ -227,7 +227,7 @@ static stock InitializeServerVehicles( ) AddStaticVehicle( 507, -2545.616699, 642.781616, 14.280050, 88.164779, -1, -1 ); AddStaticVehicle( 451, -2572.311035, 658.140808, 14.159088, 92.413055, -1, -1 ); AddStaticVehicle( 576, -2572.658935, 647.644714, 14.062355, 89.737174, -1, -1 ); - AddStaticVehicle( 411, -1943.248291, 487.249816, 31.713851, 90.106033, -1, -1 ); + //AddStaticVehicle( 411, -1943.248291, 487.249816, 31.713851, 90.106033, -1, -1 ); AddStaticVehicle( 522, -1988.700683, 301.183624, 34.739818, 89.835449, -1, -1 ); AddStaticVehicle( 579, -1987.592651, 304.252044, 35.113090, 90.826240, -1, -1 ); AddStaticVehicle( 489, -1987.468261, 307.747619, 35.318893, 88.531921, -1, -1 ); From 9c49fa35b439bb9b5facf679c85d22bd4a87c378 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 00:08:22 +1100 Subject: [PATCH 28/39] passive disables deathmatch --- gamemodes/irresistible/cnr/dialog_ids.pwn | 3 +- gamemodes/irresistible/cnr/player.pwn | 2 +- .../irresistible/cnr/player_settings.pwn | 10 ++--- gamemodes/sf-cnr.pwn | 39 +++++++++++++++---- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/gamemodes/irresistible/cnr/dialog_ids.pwn b/gamemodes/irresistible/cnr/dialog_ids.pwn index 53188a2..70b5479 100644 --- a/gamemodes/irresistible/cnr/dialog_ids.pwn +++ b/gamemodes/irresistible/cnr/dialog_ids.pwn @@ -210,7 +210,8 @@ #define DIALOG_COMPONENTS_SELL 1200 #define DIALOG_HOUSE_SELL 1201 #define DIALOG_BUSINESS_SELL_CONFIRM 1202 - +#define DIALOG_PASSIVE_MODE 1203 + /* ** Hooks ** */ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) { diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index 1953156..7c753fd 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -232,7 +232,7 @@ new p_PlayerAltBindTick [ MAX_PLAYERS ], p_AimedAtPolice [ MAX_PLAYERS ], 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 } ; diff --git a/gamemodes/irresistible/cnr/player_settings.pwn b/gamemodes/irresistible/cnr/player_settings.pwn index 754807e..e837508 100644 --- a/gamemodes/irresistible/cnr/player_settings.pwn +++ b/gamemodes/irresistible/cnr/player_settings.pwn @@ -68,9 +68,9 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) ShowPlayerTogglableTextdraws( playerid, .force = false ); } - else if ( settingid == SETTING_PASSIVE_MODE ) { + /*else if ( settingid == SETTING_PASSIVE_MODE ) { ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing - } + }*/ 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 ); ShowPlayerTogglableTextdraws( playerid, .force = false ); } - else if ( settingid == SETTING_PASSIVE_MODE ) { + /*else if ( settingid == SETTING_PASSIVE_MODE ) { 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 ); } 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" )) { cmd_cp( playerid, "" ); // Redirect to control panel again... diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 8a2f7c6..1935abf 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2829,10 +2829,10 @@ public OnPlayerTakePlayerDamage( playerid, issuerid, &Float: amount, weaponid, b // Passive mode enabled for player? 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 - } - return 0; + }*/ + return ShowPlayerHelpDialog( issuerid, 2000, "~r~You cannot deathmatch with /passive enabled." ), 0; } // 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 ( 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 ( 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 ( 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 ); + + 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; //if ( !p_CitySet{ playerid } ) @@ -10520,6 +10526,19 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) 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", "" ); } + } + 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 ) { @@ -17914,8 +17933,12 @@ stock DisablePlayerSpawnProtection( playerid ) stock SetPlayerPassiveMode( playerid ) { + // disable passive mode if it is enabled if ( IsPlayerSettingToggled( playerid, SETTING_PASSIVE_MODE ) ) + { + ResetPlayerPassiveMode( playerid, .passive_disabled = true ); return 0; + } // reset any labels etc ResetPlayerPassiveMode( playerid ); @@ -17930,21 +17953,21 @@ stock SetPlayerPassiveMode( 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 ) { DestroyDynamic3DTextLabel( p_PassiveModeLabel[ playerid ] ); - KillTimer( p_PassiveModeExpireTimer[ playerid ] ); + //KillTimer( p_PassiveModeExpireTimer[ playerid ] ); p_PassiveModeLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID; - p_PassiveModeExpireTimer[ playerid ] = -1; + //p_PassiveModeExpireTimer[ playerid ] = -1; p_PassiveModeDisabled{ playerid } = passive_disabled; TextDrawHideForPlayer( playerid, g_PassiveModeTD ); 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 ( 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 ); } return 1; -} +}*/ stock SendClientMessageToCops( colour, format[ ], va_args<> ) // Conversion to foreach 14 stuffed the define, not sure how... { From c15ea9ef49c8a0696dce11f9a9be1421371f6606 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 14:11:21 +0100 Subject: [PATCH 29/39] adds /viewpolicechat for level 5 admins --- gamemodes/irresistible/cnr/commands/admin/_admin.pwn | 1 + .../irresistible/cnr/commands/admin/admin_five.pwn | 12 ++++++++++++ gamemodes/irresistible/cnr/player.pwn | 1 + gamemodes/sf-cnr.pwn | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/gamemodes/irresistible/cnr/commands/admin/_admin.pwn b/gamemodes/irresistible/cnr/commands/admin/_admin.pwn index 92a959b..20c6223 100644 --- a/gamemodes/irresistible/cnr/commands/admin/_admin.pwn +++ b/gamemodes/irresistible/cnr/commands/admin/_admin.pwn @@ -156,6 +156,7 @@ static stock { 5, "/destroybusiness", "Deletes a business" }, { 5, "/seteventhost", "Setting event host to player" }, { 5, "/weather", "Settings world weather" }, + { 5, "/viewpolicechat", "Viewing the police radio/chat" }, /* ** Level 6 Commands ** */ { 6, "/reloadeditor", "Reloads object editer script" }, diff --git a/gamemodes/irresistible/cnr/commands/admin/admin_five.pwn b/gamemodes/irresistible/cnr/commands/admin/admin_five.pwn index 6630a21..cc492a1 100644 --- a/gamemodes/irresistible/cnr/commands/admin/admin_five.pwn +++ b/gamemodes/irresistible/cnr/commands/admin/admin_five.pwn @@ -20,6 +20,18 @@ CMD:armorall( playerid, params[ ] ) return 1; } +CMD:viewpolicechat( playerid, params[ ] ) +{ + if ( p_AdminLevel[ playerid ] < 5 && !IsPlayerUnderCover( playerid ) ) return SendError( playerid, ADMIN_COMMAND_REJECT ); + p_ToggleCopChat{ playerid } = !p_ToggleCopChat{ playerid }; + + SendClientMessageFormatted( playerid, -1, ""COL_PINK"[ADMIN]"COL_WHITE" You have %s viewing police.", p_ToggleCopChat{ playerid } == true ? ("toggled") : ("un-toggled") ); + if ( !IsPlayerUnderCover( playerid ) ) { + AddAdminLogLineFormatted( "%s(%d) has %s viewing police chat", ReturnPlayerName( playerid ), playerid, p_ToggleCopChat{ playerid } == true ? ("toggled") : ("un-toggled") ); + } + return 1; +} + CMD:check( playerid, params[ ] ) { new diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index 1953156..0fb853b 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -39,6 +39,7 @@ new p_Ropes [ MAX_PLAYERS ], bool: p_Kidnapped [ MAX_PLAYERS char ], bool: p_ToggledViewPM [ MAX_PLAYERS char ], + bool: p_ToggleCopChat [ MAX_PLAYERS char ], p_TicketTimestamp [ MAX_PLAYERS ], p_TicketIssuer [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, p_CheckpointEnterTick [ MAX_PLAYERS ], diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 8a2f7c6..b2d5ee9 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -3427,6 +3427,14 @@ public OnPlayerText( playerid, text[ ] ) } } SendClientMessageToCops( -1, ""COL_BLUE" %s(%d):"COL_WHITE" %s", ReturnPlayerName( playerid ), playerid, szBigString[ 1 ] ); + + foreach(new i : Player) + { + if ( ( p_AdminLevel[ i ] >= 5 || IsPlayerUnderCover( i ) ) && p_ToggleCopChat{ i } == true ) + { + SendClientMessageFormatted( i, -1, ""COL_BLUE" %s(%d):"COL_GREY" %s", ReturnPlayerName( playerid ), playerid, szBigString[ 1 ] ); + } + } return 0; } From ad8a8b9385e35dbe6ff00ecf12edc90a449f378f Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 14:15:48 +0100 Subject: [PATCH 30/39] removes 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 9283629..eff6826 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -16,9 +16,6 @@ #define HIDE_FEED_DELAY ( 3000 ) #define MAX_UPDATE_RATE ( 250 ) -#define TYPE_GIVEN ( 1 ) -#define TYPE_TAKEN ( 2 ) - #define TEXTDRAW_ADDON ( 100.0 ) /* ** Forwards ** */ From aeabfdcdf50b71d06b86d9c937181acda2a086a2 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 14:16:59 +0100 Subject: [PATCH 31/39] removed unused function --- 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 eff6826..29cb940 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -185,13 +185,6 @@ 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 fdb9f9aa77802e8d33b7c4d822d1411cfd5ced9c Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 01:36:32 +1100 Subject: [PATCH 32/39] hit amount amount bug fix in interior (label) --- 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 9283629..6beeea3 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -125,7 +125,7 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar GetPlayerLastShotVectors( issuerid, fromX, fromY, fromZ, toX, toY, toZ ); new - Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerVirtualWorld( playerid ), .worldid = GetPlayerInterior( playerid ), .testlos = 1 ); + Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerInterior( playerid ), .worldid = GetPlayerVirtualWorld( playerid ), .testlos = 1 ); if ( IsValidDynamic3DTextLabel( bullet_label ) ) { From 76d2629b0aa57b66c12a30773b6454c6539af96c Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 15:38:02 +0100 Subject: [PATCH 33/39] starting sync player. --- .../irresistible/cnr/features/damage_feed.pwn | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 29cb940..1b008ed 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -46,6 +46,7 @@ static stock //g_BulletTimer [ MAX_PLAYERS ], bool: p_GotHit [ MAX_PLAYERS char ], + bool: p_SyncingPlayer [ MAX_PLAYERS char ], PlayerText: g_damageFeedTakenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: g_damageFeedGivenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, @@ -86,6 +87,7 @@ hook OnPlayerConnect( playerid ) hook OnPlayerDisconnect( playerid, reason ) { p_HitmarkerSound{ playerid } = 0; + p_SyncingPlayer{ playerid } = false; return 1; } @@ -104,6 +106,14 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) return 1; } +hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) +{ + if ( PRESSED( KEY_SPRINT ) && PRESSED( KEY_AIM ) ) { + SyncPlayer( playerid ); + } + return 1; +} + /* ** Functions ** */ function DamageFeed_HideBulletLabel( labelid ) { @@ -499,6 +509,53 @@ stock ShowSoundsMenu( playerid ) ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" ); } +stock SyncPlayer( playerid ) +{ + if ( !IsPlayerConnected( playerid ) || !IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerInAnyVehicle( playerid ) || IsPlayerAFK( playerid ) ) + return 0; + + p_SyncingPlayer{ playerid } = true; + + /* ** Obtaining Information ** */ + static + Float: fX, Float: fY, Float: fZ, Float: fA, Float: iHealth, Float: iArmour, + iSkin, iInterior, iWorld, iWeapon, weaponData[ 13 ][ 2 ]; + + GetPlayerHealth( playerid, iHealth ); + GetPlayerArmour( playerid, iArmour ); + iWeapon = GetPlayerWeapon( playerid ); + iWorld = GetPlayerVirtualWorld( playerid ); + iInterior = GetPlayerInterior( playerid ); + + GetPlayerPos( playerid, fX, fY, fZ ); + GetPlayerFacingAngle( playerid, fA ); + + for( new slotid = 0; slotid < 13; slotid ++ ) { + GetPlayerWeaponData(playerid, slotid, weaponData[ slotid ] [ 0 ], weaponData[ slotid ] [ 1 ] ); + } + + ClearAnimations( playerid ); + + /* ** Reinstating Information ** */ + SetSpawnInfo( playerid, GetPlayerTeam( playerid ), iSkin, fX, fY, fZ - 0.4, fA, 0, 0, 0, 0, 0, 0 ); + SpawnPlayer( playerid ); + + SetPlayerHealth( playerid, iHealth ); + SetPlayerArmour( playerid, iArmour ); + + SetPlayerInterior( playerid, iInterior ); + SetPlayerVirtualWorld( playerid, iWorld ); + + for( new slotid = 0; slotid < 13; slotid ++ ) { + GivePlayerWeapon(playerid, weaponData[ slotid ] [ 0 ], weaponData[ slotid ] [ 1 ] ); + } + + SetPlayerArmedWeapon( playerid, iWeapon ); + + SendServerMessage( playerid, "You are now synced." ); + return 1; +} + /* ** Commands ** */ CMD:hitmarker( playerid, params[ ] ) { From 7606829ff9cbdca15b3f7834878d53407884a707 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 01:43:21 +1100 Subject: [PATCH 34/39] fix moviemode bug with xp bs showing wrongly --- gamemodes/irresistible/cnr/experience.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/experience.pwn b/gamemodes/irresistible/cnr/experience.pwn index fd3be78..a9b7733 100644 --- a/gamemodes/irresistible/cnr/experience.pwn +++ b/gamemodes/irresistible/cnr/experience.pwn @@ -179,7 +179,7 @@ hook OnPlayerDisconnect( playerid, reason ) hook OnPlayerMovieMode( playerid, bool: toggled ) { - if ( toggled ) + if ( ! toggled ) { TextDrawShowForPlayer( playerid, g_CurrentRankTD ); TextDrawShowForPlayer( playerid, g_currentXPTD ); From 3fe26389594e70b3a6919b657af4e821c93daeec Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 15:44:04 +0100 Subject: [PATCH 35/39] textdraw changes --- .../irresistible/cnr/features/damage_feed.pwn | 93 ++++++------------- 1 file changed, 26 insertions(+), 67 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 1b008ed..2ab6629 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -81,6 +81,27 @@ hook OnPlayerConnect( playerid ) PlayerTextDrawSetOutline(playerid, p_DamageTD[ playerid ], 1); PlayerTextDrawSetProportional(playerid, p_DamageTD[ playerid ], 1);*/ + /* ** Textdraws ** */ + g_damageFeedGivenTD[ playerid ] = CreatePlayerTextDraw( playerid, ( 320.0 - TEXTDRAW_ADDON ), 340.0, "_"); + PlayerTextDrawBackgroundColor(playerid, g_damageFeedGivenTD[ playerid ], 117 ); + PlayerTextDrawAlignment( playerid, g_damageFeedGivenTD[ playerid ], 2 ); + PlayerTextDrawFont( playerid, g_damageFeedGivenTD[ playerid ], 1 ); + PlayerTextDrawLetterSize( playerid, g_damageFeedGivenTD[ playerid ], 0.200000, 0.899999 ); + PlayerTextDrawColor( playerid, g_damageFeedGivenTD[ playerid ], 0xDD2020FF ); + PlayerTextDrawSetOutline( playerid, g_damageFeedGivenTD[ playerid ], 1 ); + PlayerTextDrawSetProportional( playerid, g_damageFeedGivenTD[ playerid ], 1 ); + PlayerTextDrawSetSelectable( playerid, g_damageFeedGivenTD[ playerid ], 0 ); + + g_damageFeedTakenTD[ playerid ] = CreatePlayerTextDraw( playerid, ( TEXTDRAW_ADDON + 320.0 ), 340.0, "_"); + PlayerTextDrawBackgroundColor(playerid, g_damageFeedTakenTD[ playerid ], 117 ); + PlayerTextDrawAlignment( playerid, g_damageFeedTakenTD[ playerid ], 2 ); + PlayerTextDrawFont( playerid, g_damageFeedTakenTD[ playerid ], 1 ); + PlayerTextDrawLetterSize( playerid, g_damageFeedTakenTD[ playerid ], 0.200000, 0.899999 ); + PlayerTextDrawColor( playerid, g_damageFeedTakenTD[ playerid ], 1069804543 ); + PlayerTextDrawSetOutline( playerid, g_damageFeedTakenTD[ playerid ], 1 ); + PlayerTextDrawSetProportional( playerid, g_damageFeedTakenTD[ playerid ], 1 ); + PlayerTextDrawSetSelectable( playerid, g_damageFeedTakenTD[ playerid ], 0 ); + return 1; } @@ -106,14 +127,6 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) return 1; } -hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) -{ - if ( PRESSED( KEY_SPRINT ) && PRESSED( KEY_AIM ) ) { - SyncPlayer( playerid ); - } - return 1; -} - /* ** Functions ** */ function DamageFeed_HideBulletLabel( labelid ) { @@ -132,7 +145,7 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar GetPlayerLastShotVectors( issuerid, fromX, fromY, fromZ, toX, toY, toZ ); new - Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerVirtualWorld( playerid ), .worldid = GetPlayerInterior( playerid ), .testlos = 1 ); + Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerInterior( playerid ), .worldid = GetPlayerVirtualWorld( playerid ), .testlos = 1 ); if ( IsValidDynamic3DTextLabel( bullet_label ) ) { @@ -215,60 +228,6 @@ stock DamageFeedAddHitTaken( playerid, issuerid, Float: amount, weaponid ) stock UpdateDamageFeed( playerid, bool: modified = false ) { - 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, ( 320.0 - TEXTDRAW_ADDON ), 340.0, "_"); - - 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 ); - PlayerTextDrawFont( playerid, handle, 1 ); - PlayerTextDrawLetterSize( playerid, handle, 0.200000, 0.899999 ); - PlayerTextDrawColor( playerid, handle, 0xDD2020FF ); - 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, ( TEXTDRAW_ADDON + 320.0 ), 340.0, "_"); - - if ( handle == PlayerText: INVALID_TEXT_DRAW ) - return print("[DAMAGE FEED ERROR]: Unable to create TD (taken damage)" ); - - PlayerTextDrawBackgroundColor(playerid, handle, 117 ); - PlayerTextDrawAlignment( playerid, handle, 2 ); - PlayerTextDrawFont( playerid, handle, 1 ); - PlayerTextDrawLetterSize( playerid, handle, 0.200000, 0.899999 ); - PlayerTextDrawColor( playerid, handle, 1069804543 ); - 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; @@ -509,14 +468,14 @@ stock ShowSoundsMenu( playerid ) ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" ); } -stock SyncPlayer( playerid ) +/*stock SyncPlayer( playerid ) { if ( !IsPlayerConnected( playerid ) || !IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerInAnyVehicle( playerid ) || IsPlayerAFK( playerid ) ) return 0; p_SyncingPlayer{ playerid } = true; - /* ** Obtaining Information ** */ + // ** Obtaining Information ** static Float: fX, Float: fY, Float: fZ, Float: fA, Float: iHealth, Float: iArmour, iSkin, iInterior, iWorld, iWeapon, weaponData[ 13 ][ 2 ]; @@ -536,7 +495,7 @@ stock SyncPlayer( playerid ) ClearAnimations( playerid ); - /* ** Reinstating Information ** */ + // ** Reinstating Information ** * SetSpawnInfo( playerid, GetPlayerTeam( playerid ), iSkin, fX, fY, fZ - 0.4, fA, 0, 0, 0, 0, 0, 0 ); SpawnPlayer( playerid ); @@ -554,7 +513,7 @@ stock SyncPlayer( playerid ) SendServerMessage( playerid, "You are now synced." ); return 1; -} +}*/ /* ** Commands ** */ CMD:hitmarker( playerid, params[ ] ) From c2085bcdd2d0366404a49c93ae6cfa737c921ccf Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 01:55:53 +1100 Subject: [PATCH 36/39] updates.txt update --- scriptfiles/updates.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scriptfiles/updates.txt b/scriptfiles/updates.txt index f6596fa..d33f219 100644 --- a/scriptfiles/updates.txt +++ b/scriptfiles/updates.txt @@ -1,12 +1,20 @@ +(+) Newly registered players will be asked if they prefer DM or RP - if they like RP, passive mode is on. (+) Added confirmation dialog before selling a home / business / vehicle components. (+) Pilot and train minijobs are now saved to the database (and in /highscores). (+) Adds some strippers in the LV brothel (for fun). (+) Adds Hide From Minimap perk (costs $25,000) ... hides you for 1 minute. -(/) You can now set spikes in non-air and non-sea vehicles using your AIM key. +(+) Fire tracker is now /fires ... and it shows the fires on the map as red blips. +(+) New hitmarker system ... activate using /cp - Now shows taken/given damage! +(/) Passive mode now completely disables deathmatch. +(/) You can now set spikes in non-air and non-sea vehicles using your CAPSLOCK key. (/) Car jackers now need to wait only 1 min before exporting another vehicle (before 2 min). (/) Players with level 100 in a specific level are able to accrue more XP in the level. +(/) Explosive rounds used on vehicles will have a more significant impact. +(/) Explosive rounds require the key N to activate. +(/) Rank is now XP based now (prior score based). (*) Should be faster to place multiple drills using left alt. (*) Fixes death bug with players suiciding in a vehicle. (*) Fixed Alcatraz map escaping issues. (*) Addressed issue with being unable to rob ChuffSec. +(*) Fixed issue with business exports being randomly canceled. (-) Removed a counter in cluckin' bell for ease of access to the safe. \ No newline at end of file From 7d0d72260bcd316635f801787643a863af00ba94 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 17:04:32 +0100 Subject: [PATCH 37/39] global object replacement --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 2ab6629..25e1a7e 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -47,6 +47,7 @@ static stock bool: p_GotHit [ MAX_PLAYERS char ], bool: p_SyncingPlayer [ MAX_PLAYERS char ], + p_DamageObject [ MAX_PLAYERS ] = { -1, ... }, PlayerText: g_damageFeedTakenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: g_damageFeedGivenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, @@ -163,7 +164,10 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar if ( GetPlayerArmour( playerid, armour ) ) { - SetPlayerAttachedObject( playerid, 4, armour - amount <= 0.0 ? ( 1240 ) : ( 1242 ), 1, 1.400000, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999 ); + p_DamageObject[ playerid ] = CreateObject( armour - amount <= 0.0 ? ( 1240 ) : ( 1242 ), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0 ); + AttachObjectToPlayer( p_DamageObject[ playerid ], playerid, 0.0, 0.0, 1.5, 0.0, 0.0, 0.0 ); + + //SetPlayerAttachedObject( playerid, 4, armour - amount <= 0.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 ); @@ -190,8 +194,8 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar function HideDamageObject( playerid ) { - if( IsPlayerAttachedObjectSlotUsed( playerid, 4 ) ) - RemovePlayerAttachedObject( playerid, 4 ); + if( IsValidObject( p_DamageObject[ playerid ] ) ) + DestroyObject( p_DamageObject[ playerid ] ); p_GotHit{ playerid } = false; return 1; From 18ff02951b48b2c106ff827acf36b45f900aa84e Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Sat, 13 Oct 2018 17:06:06 +0100 Subject: [PATCH 38/39] hidden syncing for the time being --- 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 25e1a7e..04a7d15 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -46,7 +46,7 @@ static stock //g_BulletTimer [ MAX_PLAYERS ], bool: p_GotHit [ MAX_PLAYERS char ], - bool: p_SyncingPlayer [ MAX_PLAYERS char ], + //bool: p_SyncingPlayer [ MAX_PLAYERS char ], p_DamageObject [ MAX_PLAYERS ] = { -1, ... }, PlayerText: g_damageFeedTakenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, @@ -109,7 +109,7 @@ hook OnPlayerConnect( playerid ) hook OnPlayerDisconnect( playerid, reason ) { p_HitmarkerSound{ playerid } = 0; - p_SyncingPlayer{ playerid } = false; + //p_SyncingPlayer{ playerid } = false; return 1; } From 9ed522155021cd3f85d88f5e8eedc989e6d0a029 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 14 Oct 2018 13:38:34 +1100 Subject: [PATCH 39/39] destroy damage object if it exists --- gamemodes/irresistible/cnr/features/damage_feed.pwn | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 04a7d15..f887609 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -164,13 +164,15 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar if ( GetPlayerArmour( playerid, armour ) ) { + DestroyObject( p_DamageObject[ playerid ] ); + p_DamageObject[ playerid ] = CreateObject( armour - amount <= 0.0 ? ( 1240 ) : ( 1242 ), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0 ); AttachObjectToPlayer( p_DamageObject[ playerid ], playerid, 0.0, 0.0, 1.5, 0.0, 0.0, 0.0 ); //SetPlayerAttachedObject( playerid, 4, armour - amount <= 0.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 ); + //Streamer_Update( playerid, STREAMER_TYPE_OBJECT ); p_GotHit{ playerid } = true; } } @@ -194,8 +196,10 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar function HideDamageObject( playerid ) { - if( IsValidObject( p_DamageObject[ playerid ] ) ) + if( IsValidObject( p_DamageObject[ playerid ] ) ) { DestroyObject( p_DamageObject[ playerid ] ); + p_DamageObject[ playerid ] = -1; + } p_GotHit{ playerid } = false; return 1; @@ -476,7 +480,7 @@ stock ShowSoundsMenu( playerid ) { if ( !IsPlayerConnected( playerid ) || !IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerInAnyVehicle( playerid ) || IsPlayerAFK( playerid ) ) return 0; - + p_SyncingPlayer{ playerid } = true; // ** Obtaining Information ** @@ -498,7 +502,7 @@ stock ShowSoundsMenu( playerid ) } ClearAnimations( playerid ); - + // ** Reinstating Information ** * SetSpawnInfo( playerid, GetPlayerTeam( playerid ), iSkin, fX, fY, fZ - 0.4, fA, 0, 0, 0, 0, 0, 0 ); SpawnPlayer( playerid );