2018-10-10 23:40:49 +00:00
/*
* Irresistible Gaming (c) 2018
2018-10-12 14:12:27 +00:00
* Developed by Steven Howard, Oscar "Slice" Broman
2018-10-11 10:10:16 +00:00
* Module: cnr/features/damage_feed.pwn
2018-10-10 23:40:49 +00:00
* Purpose: damage feed for dmers
*/
/* ** Includes ** */
#include < YSI\y_hooks >
2018-10-11 09:37:47 +00:00
/* ** Macros ** */
2018-10-12 14:12:27 +00:00
#define IsDamageFeedActive(%0) ( IsPlayerSettingToggled( %0, SETTING_HITMARKER ) )
2018-10-11 09:37:47 +00:00
2018-10-10 23:40:49 +00:00
/* ** Definitions ** */
#define MAX_FEED_HEIGHT ( 5 )
#define HIDE_FEED_DELAY ( 3000 )
#define MAX_UPDATE_RATE ( 250 )
2018-10-12 14:59:20 +00:00
#define TEXTDRAW_ADDON ( 100.0 )
2018-10-11 13:06:18 +00:00
2018-10-11 09:37:47 +00:00
/* ** Forwards ** */
2018-10-11 13:06:18 +00:00
forward OnPlayerFeedUpdate ( playerid );
2018-10-11 13:21:51 +00:00
forward OnPlayerTakenDamage ( playerid, issuerid, Float: amount, weaponid, bodypart );
2018-10-11 09:37:47 +00:00
2018-10-10 23:40:49 +00:00
/* ** Variables ** */
2018-10-14 08:51:07 +00:00
enum E_SYNC_DATA
{
Float: E_X, Float: E_Y, Float: E_Z,
Float: E_A, Float: E_HEALTH, Float: E_ARMOUR,
E_SKIN, E_WORLD, E_INTERIOR,
E_CURRENT_WEAPON, E_WEAPON_ID[ 13 ], E_WEAPON_AMMO[ 13 ],
2018-10-14 12:02:49 +00:00
E_WANTED_LEVEL
2018-10-14 08:51:07 +00:00
};
2018-10-10 23:40:49 +00:00
enum E_DAMAGE_FEED
{
E_ISSUER, E_NAME[ MAX_PLAYER_NAME ], Float: E_AMOUNT,
2018-10-12 21:13:07 +00:00
E_WEAPON, E_TICK
2018-10-10 23:40:49 +00:00
};
2018-10-11 13:35:21 +00:00
enum E_HITMARKER_SOUND
{
2018-10-12 21:13:07 +00:00
E_NAME[ 10 ], E_SOUND_ID
2018-10-11 13:35:21 +00:00
};
2018-10-13 12:21:05 +00:00
new
2018-10-12 16:00:44 +00:00
p_HitmarkerSound [ MAX_PLAYERS char ]
;
2018-10-11 13:21:51 +00:00
static stock
2018-10-13 12:21:05 +00:00
g_damageGiven [ MAX_PLAYERS ] [ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ],
g_damageTaken [ MAX_PLAYERS ] [ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ],
2018-10-14 08:51:07 +00:00
g_syncData [ MAX_PLAYERS ] [ E_SYNC_DATA ],
2018-10-13 12:21:05 +00:00
//Text3D: g_BulletLabel [ MAX_PLAYERS ],
//g_BulletTimer [ MAX_PLAYERS ],
2018-10-12 21:13:07 +00:00
2018-10-12 22:04:18 +00:00
bool: p_GotHit [ MAX_PLAYERS char ],
2018-10-14 08:51:07 +00:00
bool: p_SyncingPlayer [ MAX_PLAYERS char ],
2018-10-13 16:04:32 +00:00
p_DamageObject [ MAX_PLAYERS ] = { -1, ... },
2018-10-12 22:04:18 +00:00
2018-10-10 23:40:49 +00:00
PlayerText: g_damageFeedTakenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
2018-10-11 09:37:47 +00:00
PlayerText: g_damageFeedGivenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
2018-10-12 14:12:27 +00:00
//PlayerText: p_DamageTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
2018-10-10 23:40:49 +00:00
2018-10-13 12:21:05 +00:00
g_HitmarkerSounds [ ] [ E_HITMARKER_SOUND ] =
2018-10-11 13:35:21 +00:00
{
{ "Bell Ding", 17802 }, { "Soft Beep", 5205 }, { "Low Blip", 1138 }, { "Med Blip", 1137 },
{ "High Blip", 1139 }, { "Bling", 5201 }
},
2018-10-11 13:21:51 +00:00
p_damageFeedTimer [ MAX_PLAYERS ] = { -1, ... },
2018-10-10 23:40:49 +00:00
p_lastFeedUpdate [ MAX_PLAYERS ]
;
/* ** Hooks ** */
hook OnPlayerConnect( playerid )
{
2018-10-11 09:37:47 +00:00
for( new x = 0; x < sizeof( g_damageGiven[ ] ); x ++) {
2018-10-13 12:21:05 +00:00
g_damageGiven[ playerid ] [ x ] [ E_TICK ] = 0;
g_damageTaken[ playerid ] [ x ] [ E_TICK ] = 0;
2018-10-10 23:40:49 +00:00
}
p_lastFeedUpdate[ playerid ] = GetTickCount( );
2018-10-11 13:21:51 +00:00
/* ** Textdraws ** */
2018-10-12 14:12:27 +00:00
/*p_DamageTD[ playerid ] = CreatePlayerTextDraw(playerid, 357.000000, 208.000000, "~r~~h~300.24 DAMAGE");
2018-10-11 13:21:51 +00:00
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);
2018-10-12 14:12:27 +00:00
PlayerTextDrawSetProportional(playerid, p_DamageTD[ playerid ], 1);*/
2018-10-11 13:21:51 +00:00
2018-10-13 14:44:04 +00:00
/* ** 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 );
2018-10-10 23:40:49 +00:00
return 1;
}
2018-10-11 13:35:21 +00:00
hook OnPlayerDisconnect( playerid, reason )
{
p_HitmarkerSound{ playerid } = 0;
2018-10-14 08:51:07 +00:00
p_SyncingPlayer{ playerid } = false;
2018-10-11 13:35:21 +00:00
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 ] );
2018-10-13 12:21:05 +00:00
2018-10-12 21:13:07 +00:00
PlayerPlaySound( playerid, g_HitmarkerSounds[ listitem ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 );
2018-10-11 13:35:21 +00:00
ShowSoundsMenu( playerid );
}
return 1;
}
2018-10-12 21:13:07 +00:00
2018-10-14 08:51:07 +00:00
hook SetPlayerRandomSpawn( playerid )
{
if ( p_SyncingPlayer{ playerid } == true )
{
//ResetPlayerWeapons( playerid );
2018-10-14 12:02:49 +00:00
SetPlayerWantedLevel( playerid, g_syncData[ playerid ][ E_WANTED_LEVEL ] );
2018-10-14 08:51:07 +00:00
SetPlayerHealth( playerid, g_syncData[ playerid ][ E_HEALTH ] );
SetPlayerArmour( playerid, g_syncData[ playerid ][ E_ARMOUR ] );
SetPlayerVirtualWorld( playerid, g_syncData[ playerid ][ E_WORLD ] );
SetPlayerInterior( playerid, g_syncData[ playerid ][ E_INTERIOR ] );
SetPlayerSkin( playerid, g_syncData[ playerid ][ E_SKIN ] );
SetPlayerPos( playerid, g_syncData[ playerid ][ E_X ], g_syncData[ playerid ][ E_Y ], g_syncData[ playerid ][ E_Z ] );
SetPlayerFacingAngle( playerid, g_syncData[ playerid ][ E_A ] );
2018-10-14 12:02:49 +00:00
/*
for( new slotid = 0; slotid < 13; slotid ++ ) {
2018-10-14 08:51:07 +00:00
GivePlayerWeapon( playerid, g_syncData[ playerid ][ E_WEAPON_ID ][ slotid ], g_syncData[ playerid ][ E_WEAPON_AMMO ][ slotid ] );
}
2018-10-14 12:02:49 +00:00
*/
2018-10-14 08:51:07 +00:00
SetPlayerArmedWeapon( playerid, g_syncData[ playerid ][ E_CURRENT_WEAPON ] );
SetCameraBehindPlayer( playerid );
p_SyncingPlayer{ playerid } = false;
return Y_HOOKS_BREAK_RETURN_1;
}
return 1;
}
hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
if ( newkeys & KEY_SPRINT && newkeys & KEY_AIM ) {
SyncPlayer( playerid, .message = false );
}
return 1;
}
2018-10-10 23:40:49 +00:00
/* ** Functions ** */
2018-10-13 12:21:05 +00:00
function DamageFeed_HideBulletLabel( labelid )
2018-10-12 21:13:07 +00:00
{
2018-10-13 12:21:05 +00:00
DestroyDynamic3DTextLabel( Text3D: labelid );
2018-10-12 21:13:07 +00:00
return 1;
}
2018-10-11 13:21:51 +00:00
public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypart )
2018-10-11 10:26:08 +00:00
{
2018-10-12 21:13:07 +00:00
/* ** Label Damage Indicator ** */
if ( issuerid != INVALID_PLAYER_ID )
2018-10-11 13:21:51 +00:00
{
2018-10-12 21:13:07 +00:00
static Float: fromX, Float: fromY, Float: fromZ;
static Float: toX, Float: toY, Float: toZ;
2018-10-11 13:21:51 +00:00
2018-10-12 21:13:07 +00:00
GetPlayerLastShotVectors( issuerid, fromX, fromY, fromZ, toX, toY, toZ );
2018-10-11 13:21:51 +00:00
2018-10-13 12:21:05 +00:00
new
2018-10-13 14:44:04 +00:00
Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerInterior( playerid ), .worldid = GetPlayerVirtualWorld( playerid ), .testlos = 1 );
2018-10-11 13:21:51 +00:00
2018-10-13 12:21:05 +00:00
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 );
}
2018-10-12 21:13:07 +00:00
2018-10-12 22:04:18 +00:00
/* ** Armour and Health Object Damage ** */
2018-10-13 12:21:05 +00:00
if ( ! p_GotHit{ playerid } )
2018-10-12 22:04:18 +00:00
{
2018-10-13 12:21:05 +00:00
static
Float: armour;
2018-10-12 22:04:18 +00:00
2018-10-13 12:21:05 +00:00
if ( GetPlayerArmour( playerid, armour ) )
2018-10-12 22:04:18 +00:00
{
2018-10-14 02:38:34 +00:00
DestroyObject( p_DamageObject[ playerid ] );
2018-10-13 16:04:32 +00:00
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 );
2018-10-12 22:04:18 +00:00
SetTimerEx( "HideDamageObject", 1000, false, "d", playerid );
2018-10-13 12:21:05 +00:00
2018-10-14 02:38:34 +00:00
//Streamer_Update( playerid, STREAMER_TYPE_OBJECT );
2018-10-12 22:04:18 +00:00
p_GotHit{ playerid } = true;
}
}
2018-10-12 21:13:07 +00:00
/* ** Hitmarker ** */
2018-10-11 15:36:56 +00:00
DamageFeedAddHitGiven( issuerid, playerid, amount, weaponid );
2018-10-12 14:12:27 +00:00
// 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 );
}
2018-10-11 13:21:51 +00:00
}
2018-10-11 15:36:56 +00:00
DamageFeedAddHitTaken( playerid, issuerid, amount, weaponid );
2018-10-11 10:26:08 +00:00
return 1;
}
2018-10-12 22:04:18 +00:00
function HideDamageObject( playerid )
{
2018-10-14 02:38:34 +00:00
if( IsValidObject( p_DamageObject[ playerid ] ) ) {
2018-10-13 16:04:32 +00:00
DestroyObject( p_DamageObject[ playerid ] );
2018-10-14 02:38:34 +00:00
p_DamageObject[ playerid ] = -1;
}
2018-10-13 10:12:08 +00:00
2018-10-12 22:04:18 +00:00
p_GotHit{ playerid } = false;
return 1;
}
2018-10-11 09:37:47 +00:00
public OnPlayerFeedUpdate( playerid )
2018-10-10 23:40:49 +00:00
{
2018-10-11 09:37:47 +00:00
p_damageFeedTimer[ playerid ] = -1;
if ( IsPlayerConnected( playerid ) && IsDamageFeedActive( playerid ) ) {
UpdateDamageFeed( playerid, true );
}
2018-10-10 23:40:49 +00:00
return 1;
}
2018-10-11 15:36:56 +00:00
stock DamageFeedAddHitGiven( playerid, issuerid, Float: amount, weaponid )
{
2018-10-12 14:12:47 +00:00
foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == playerid && i != playerid ) {
2018-10-11 15:36:56 +00:00
AddDamageHit( g_damageGiven[ i ], i, issuerid, amount, weaponid );
}
AddDamageHit( g_damageGiven[ playerid ], playerid, issuerid, amount, weaponid );
}
stock DamageFeedAddHitTaken( playerid, issuerid, Float: amount, weaponid )
{
2018-10-12 14:12:47 +00:00
foreach( new i : Player ) if ( p_Spectating{ i } && p_whomSpectating[ i ] == playerid && i != playerid ) {
2018-10-11 15:36:56 +00:00
AddDamageHit( g_damageTaken[ i ], i, issuerid, amount, weaponid );
}
AddDamageHit( g_damageTaken[ playerid ], playerid, issuerid, amount, weaponid );
}
2018-10-10 23:40:49 +00:00
stock UpdateDamageFeed( playerid, bool: modified = false )
{
2018-10-11 09:37:47 +00:00
/* ** Core ** */
2018-10-10 23:40:49 +00:00
new szTick = GetTickCount( );
2018-10-11 09:37:47 +00:00
if ( szTick == 0 ) szTick = 1;
new lowest_tick = szTick + 1;
2018-10-10 23:40:49 +00:00
2018-10-11 09:37:47 +00:00
for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++)
2018-10-10 23:40:49 +00:00
{
2018-10-13 12:21:05 +00:00
if ( !g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] ) {
2018-10-10 23:40:49 +00:00
break;
}
2018-10-13 12:21:05 +00:00
if ( szTick - g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] >= HIDE_FEED_DELAY )
2018-10-10 23:40:49 +00:00
{
modified = true;
2018-10-11 09:37:47 +00:00
for( new j = givenid; j < sizeof( g_damageGiven[ ] ) - 1; j++ ) {
2018-10-13 12:21:05 +00:00
g_damageGiven[ playerid ] [ j ] [ E_TICK ] = 0;
2018-10-10 23:40:49 +00:00
}
break;
}
2018-10-13 12:21:05 +00:00
if ( g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] < lowest_tick ) {
lowest_tick = g_damageGiven[ playerid ] [ givenid ] [ E_TICK ];
2018-10-10 23:40:49 +00:00
}
}
2018-10-11 09:37:47 +00:00
for( new takenid = 0; takenid < sizeof( g_damageTaken[ ] ) - 1; takenid ++)
2018-10-10 23:40:49 +00:00
{
2018-10-13 12:21:05 +00:00
if ( !g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] ) {
2018-10-10 23:40:49 +00:00
break;
}
2018-10-13 12:21:05 +00:00
if ( szTick - g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] >= HIDE_FEED_DELAY )
2018-10-10 23:40:49 +00:00
{
modified = true;
2018-10-11 09:37:47 +00:00
for( new j = takenid; j < sizeof( g_damageTaken[ ] ) - 1; j++ ) {
2018-10-13 12:21:05 +00:00
g_damageTaken[ playerid ] [ j ] [ E_TICK ] = 0;
2018-10-10 23:40:49 +00:00
}
break;
}
2018-10-13 12:21:05 +00:00
if ( g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] < lowest_tick ) {
lowest_tick = g_damageTaken[ playerid ] [ takenid ] [ E_TICK ];
2018-10-10 23:40:49 +00:00
}
}
if ( p_damageFeedTimer[ playerid ] != -1 ) {
KillTimer( p_damageFeedTimer[ playerid ] );
}
2018-10-11 09:37:47 +00:00
if ( ( szTick - p_lastFeedUpdate[ playerid ] ) < MAX_UPDATE_RATE && modified )
2018-10-10 23:40:49 +00:00
{
2018-10-11 15:44:11 +00:00
p_damageFeedTimer[ playerid ] = SetTimerEx( "OnPlayerFeedUpdate", MAX_UPDATE_RATE - ( szTick - p_lastFeedUpdate[ playerid ] ) + 10, false, "d", playerid );
2018-10-10 23:40:49 +00:00
}
else
{
2018-10-11 09:37:47 +00:00
if ( lowest_tick == ( szTick + 1 ) )
{
2018-10-10 23:40:49 +00:00
p_damageFeedTimer[playerid] = -1;
modified = true;
2018-10-11 09:37:47 +00:00
}
else
{
2018-10-10 23:40:49 +00:00
p_damageFeedTimer[playerid] = SetTimerEx( "OnPlayerFeedUpdate", HIDE_FEED_DELAY - ( szTick - lowest_tick ) + 10, false, "i", playerid );
}
if (modified)
{
UpdateDamageFeedLabel( playerid );
p_lastFeedUpdate[ playerid ] = szTick;
}
}
2018-10-11 09:37:47 +00:00
return 1;
2018-10-10 23:40:49 +00:00
}
stock UpdateDamageFeedLabel( playerid )
{
2018-10-12 13:49:38 +00:00
new
2018-10-11 09:37:47 +00:00
szLabel[ 64 * MAX_FEED_HEIGHT ] = "";
for( new givenid = 0; givenid < sizeof( g_damageGiven[ ] ) - 1; givenid ++)
{
2018-10-13 12:21:05 +00:00
if ( !g_damageGiven[ playerid ] [ givenid ] [ E_TICK ] )
2018-10-11 09:37:47 +00:00
break;
new szWeapon[ 32 ];
2018-10-10 23:40:49 +00:00
2018-10-13 12:21:05 +00:00
if ( g_damageGiven[ playerid ] [ givenid ] [ E_WEAPON ] == -1 ) {
2018-10-11 09:37:47 +00:00
szWeapon = "Multiple";
}
else {
2018-10-13 12:21:05 +00:00
GetWeaponName( g_damageGiven[ playerid ] [ givenid ] [ E_WEAPON ], szWeapon, sizeof( szWeapon ) );
2018-10-11 09:37:47 +00:00
}
2018-10-13 12:21:05 +00:00
if ( g_damageGiven[ playerid ] [ givenid ] [ E_ISSUER ] == INVALID_PLAYER_ID )
2018-10-11 09:37:47 +00:00
{
2018-10-13 12:21:05 +00:00
format( szLabel, sizeof( szLabel ), "%s%s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ] [ givenid ] [ E_AMOUNT ] );
2018-10-11 09:37:47 +00:00
}
else
{
2018-10-13 12:21:05 +00:00
format( szLabel, sizeof( szLabel ), "%s%s - %s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ] [ givenid ] [ E_NAME ], g_damageGiven[ playerid ] [ givenid ] [ E_AMOUNT ] );
2018-10-11 09:37:47 +00:00
}
}
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 ++)
{
2018-10-13 12:21:05 +00:00
if ( !g_damageTaken[ playerid ] [ takenid ] [ E_TICK ] )
2018-10-11 09:37:47 +00:00
break;
new szWeapon[ 32 ];
2018-10-13 12:21:05 +00:00
if ( g_damageTaken[ playerid ] [ takenid ] [ E_WEAPON ] == -1 ) {
2018-10-11 09:37:47 +00:00
szWeapon = "Multiple";
}
else {
2018-10-13 12:21:05 +00:00
GetWeaponName( g_damageTaken[ playerid ] [ takenid ] [ E_WEAPON ], szWeapon, sizeof( szWeapon ) );
2018-10-11 09:37:47 +00:00
}
2018-10-13 12:21:05 +00:00
if ( g_damageTaken[ playerid ] [ takenid ] [ E_ISSUER ] == INVALID_PLAYER_ID )
2018-10-11 09:37:47 +00:00
{
2018-10-13 12:21:05 +00:00
format( szLabel, sizeof( szLabel ), "%s%s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ] [ takenid ] [ E_AMOUNT ] );
2018-10-11 09:37:47 +00:00
}
else
{
2018-10-13 12:21:05 +00:00
format( szLabel, sizeof( szLabel ), "%s%s - %s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ] [ takenid ] [ E_NAME ], g_damageTaken[ playerid ] [ takenid ] [ E_AMOUNT ] );
2018-10-11 09:37:47 +00:00
}
}
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 ] );
}
}
}
2018-10-13 12:21:05 +00:00
stock RemoveDamageHit( array[ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ], index )
2018-10-11 09:37:47 +00:00
{
for( new i = 0; i < MAX_FEED_HEIGHT; i ++ )
{
if ( i >= index ) {
2018-10-13 12:21:05 +00:00
array[ i ] [ E_TICK ] = 0;
2018-10-11 09:37:47 +00:00
}
}
}
2018-10-13 12:21:05 +00:00
stock AddDamageHit( array[ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ], playerid, issuerid, Float: amount, weapon )
2018-10-11 09:37:47 +00:00
{
if ( ! IsDamageFeedActive( playerid ) ) {
return;
}
new szTick = GetTickCount( );
if ( szTick == 0 ) szTick = 1;
new wID = -1;
for( new i = 0; i < sizeof( array ); i ++ )
{
2018-10-13 12:21:05 +00:00
if ( ! array[ i ] [ E_TICK ] ) {
2018-10-11 09:37:47 +00:00
break;
}
2018-10-13 12:21:05 +00:00
if ( szTick - array[ i ] [ E_TICK ] >= HIDE_FEED_DELAY ) {
2018-10-11 09:37:47 +00:00
RemoveDamageHit( array, i );
break;
}
2018-10-13 12:21:05 +00:00
if ( array[ i ] [ E_ISSUER ] == issuerid )
2018-10-11 09:37:47 +00:00
{
2018-10-13 12:21:05 +00:00
amount += array[ i ] [ E_AMOUNT ];
2018-10-11 09:37:47 +00:00
wID = i;
break;
}
}
if ( wID == -1 )
{
wID = 0;
for( new i = sizeof( array ) - 1; i >= 1; i -- )
{
array[ i ] = array[ i - 1 ];
}
}
2018-10-13 12:21:05 +00:00
array[ wID ] [ E_TICK ] = szTick;
array[ wID ] [ E_AMOUNT ] = amount;
array[ wID ] [ E_ISSUER ] = issuerid;
array[ wID ] [ E_WEAPON ] = weapon;
2018-10-11 09:37:47 +00:00
2018-10-13 12:21:05 +00:00
GetPlayerName( issuerid, array[ wID ] [ E_NAME ] , MAX_PLAYER_NAME );
2018-10-11 09:37:47 +00:00
2018-10-12 14:07:26 +00:00
UpdateDamageFeed( playerid, true );
2018-10-11 09:37:47 +00:00
}
2018-10-11 13:35:21 +00:00
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" );
}
2018-10-14 08:51:07 +00:00
stock SyncPlayer( playerid, bool: message = true )
2018-10-13 14:38:02 +00:00
{
2018-10-14 08:51:07 +00:00
if ( !IsPlayerConnected( playerid ) || GetPlayerWeapon( playerid ) == WEAPON_SNIPER || !IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerInAnyVehicle( playerid ) || IsPlayerAFK( playerid ) )
2018-10-13 14:38:02 +00:00
return 0;
2018-10-14 02:38:34 +00:00
2018-10-13 14:38:02 +00:00
p_SyncingPlayer{ playerid } = true;
2018-10-13 14:44:04 +00:00
// ** Obtaining Information **
2018-10-14 08:51:07 +00:00
GetPlayerHealth( playerid, g_syncData[ playerid ][ E_HEALTH ] );
GetPlayerArmour( playerid, g_syncData[ playerid ][ E_ARMOUR ] );
g_syncData[ playerid ][ E_CURRENT_WEAPON ] = GetPlayerWeapon( playerid );
g_syncData[ playerid ][ E_WORLD ] = GetPlayerVirtualWorld( playerid );
g_syncData[ playerid ][ E_INTERIOR ] = GetPlayerInterior( playerid );
g_syncData[ playerid ][ E_TEAM ] = GetPlayerTeam( playerid );
g_syncData[ playerid ][ E_SKIN ] = GetPlayerSkin( playerid );
2018-10-14 12:02:49 +00:00
g_syncData[ playerid ][ E_WANTED_LEVEL ] = GetPlayerWantedLevel( playerid );
2018-10-13 14:38:02 +00:00
2018-10-14 08:51:07 +00:00
GetPlayerPos( playerid, g_syncData[ playerid ][ E_X ], g_syncData[ playerid ][ E_Y ], g_syncData[ playerid ][ E_Z ] );
GetPlayerFacingAngle( playerid, g_syncData[ playerid ][ E_A ] );
2018-10-13 14:38:02 +00:00
for( new slotid = 0; slotid < 13; slotid ++ ) {
2018-10-14 08:51:07 +00:00
GetPlayerWeaponData( playerid, slotid, g_syncData[ playerid ][ E_WEAPON_ID ][ slotid ], g_syncData[ playerid ][ E_WEAPON_AMMO ][ slotid ] );
2018-10-13 14:38:02 +00:00
}
2018-10-14 08:51:07 +00:00
//ResetPlayerWeapons( playerid );
2018-10-13 14:38:02 +00:00
ClearAnimations( playerid );
2018-10-14 02:38:34 +00:00
2018-10-13 14:44:04 +00:00
// ** Reinstating Information ** *
2018-10-13 14:38:02 +00:00
SpawnPlayer( playerid );
2018-10-14 08:51:07 +00:00
if ( message )
SendServerMessage( playerid, "You are now synced." );
2018-10-13 14:38:02 +00:00
return 1;
2018-10-14 08:51:07 +00:00
}
2018-10-13 14:38:02 +00:00
2018-10-11 09:37:47 +00:00
/* ** Commands ** */
2018-10-11 13:35:21 +00:00
CMD:hitmarker( playerid, params[ ] )
{
ShowSoundsMenu( playerid );
return 1;
2018-10-13 12:21:05 +00:00
}
2018-10-14 08:51:07 +00:00
CMD:s( playerid, params[ ] ) return cmd_sync( playerid, params );
CMD:sync( playerid, params[ ] )
{
SyncPlayer( playerid );
return 1;
}