* adds onplayerdamageplayer

* max weapons redefined
* hook onplayerdeathex appropriately
This commit is contained in:
Lorenc 2018-03-30 18:36:07 +11:00
parent a3935e578d
commit ae2a648520
4 changed files with 42 additions and 26 deletions

View File

@ -36,8 +36,8 @@
#define MAX_CLASSES ( 300 ) #define MAX_CLASSES ( 300 )
#endif #endif
#if !defined MAX_WEAPONS #if !defined AC_MAX_WEAPONS
#define MAX_WEAPONS ( 55 ) #define AC_MAX_WEAPONS ( 55 )
#endif #endif
// Variables (Global) // Variables (Global)
@ -239,6 +239,7 @@ stock
// Forwards (Global) // Forwards (Global)
public OnPlayerCheatDetected( playerid, detection ); public OnPlayerCheatDetected( playerid, detection );
public OnPlayerDamagePlayer( playerid, damagedid, Float: amount, weaponid, bodypart );
// Functions (Global) // Functions (Global)
@ -266,3 +267,14 @@ stock ac_IsPointInArea( Float: X, Float: Y, Float: minx, Float: maxx, Float: min
stock Float: ac_PointDistance( Float: X, Float: Y, Float: dstX, Float: dstY ) stock Float: ac_PointDistance( Float: X, Float: Y, Float: dstX, Float: dstY )
return ( ( X - dstX ) * ( X - dstX ) ) + ( ( Y - dstY ) * ( Y - dstY ) ); return ( ( X - dstX ) * ( X - dstX ) ) + ( ( Y - dstY ) * ( Y - dstY ) );
stock Float: ac_GetDistanceBetweenPlayers( iPlayer1, iPlayer2, &Float: fDistance = Float: 0x7F800000 )
{
static
Float: fX, Float: fY, Float: fZ;
if( GetPlayerVirtualWorld( iPlayer1 ) == GetPlayerVirtualWorld( iPlayer2 ) && GetPlayerPos( iPlayer2, fX, fY, fZ ) )
fDistance = GetPlayerDistanceFromPoint( iPlayer1, fX, fY, fZ );
return fDistance;
}

View File

@ -71,7 +71,7 @@
p_FlyHacksWarns { playerid } = 3; p_FlyHacksWarns { playerid } = 3;
p_cbugWarns { playerid } = 0; p_cbugWarns { playerid } = 0;
for ( new i = 0; i < MAX_WEAPONS; i++ ) for ( new i = 0; i < AC_MAX_WEAPONS; i++ )
p_PlayerHasWeapon [ playerid ] { i } = false; p_PlayerHasWeapon [ playerid ] { i } = false;
} }
@ -114,7 +114,7 @@
new new
weaponid = mAvailableSpawns[ p_SelectedClassID[ playerid ] ] [ E_WEAPONS ] [ i ]; weaponid = mAvailableSpawns[ p_SelectedClassID[ playerid ] ] [ E_WEAPONS ] [ i ];
if( weaponid != -1 && weaponid < MAX_WEAPONS ) if( weaponid != -1 && weaponid < AC_MAX_WEAPONS )
p_PlayerHasWeapon[ playerid ] { weaponid } = true; p_PlayerHasWeapon[ playerid ] { weaponid } = true;
} }
@ -151,7 +151,7 @@
new new
customKiller = GetPVarInt( playerid, "KillerID" ); customKiller = GetPVarInt( playerid, "KillerID" );
OnPlayerDeathEx( playerid, customKiller != playerid ? customKiller : INVALID_PLAYER_ID, GetPVarInt( playerid, "WeaponID" ), 3.3, 3 ); CallRemoteFunction( "OnPlayerDeathEx", "ddfd", playerid, customKiller != playerid ? customKiller : INVALID_PLAYER_ID, GetPVarInt( playerid, "WeaponID" ), 3.3, 3 );
DeletePVar( playerid, "KillerID" ); DeletePVar( playerid, "KillerID" );
DeletePVar( playerid, "WeaponID" ); DeletePVar( playerid, "WeaponID" );
@ -164,7 +164,7 @@
p_LastDamageIssuer[ playerid ] = INVALID_PLAYER_ID, p_LastWeaponIssuer[ playerid ] = 51; p_LastDamageIssuer[ playerid ] = INVALID_PLAYER_ID, p_LastWeaponIssuer[ playerid ] = 51;
p_acSpawned{ playerid } = false; // They're dead! p_acSpawned{ playerid } = false; // They're dead!
OnPlayerDeathEx( playerid, p_LastDamageIssuer[ playerid ], p_LastWeaponIssuer[ playerid ], 3.3, 3 ); CallRemoteFunction( "OnPlayerDeathEx", "ddfd", playerid, p_LastDamageIssuer[ playerid ], p_LastWeaponIssuer[ playerid ], 3.3, 3 );
} }
// General // General
@ -235,11 +235,13 @@
if( ( p_PlayerHealth[ playerid ] [ E_POINTS ] -= tmp_amount ) < 0.0 ) { if( ( p_PlayerHealth[ playerid ] [ E_POINTS ] -= tmp_amount ) < 0.0 ) {
p_acSpawned{ playerid } = false; // They're dead! p_acSpawned{ playerid } = false; // They're dead!
OnPlayerDeathEx( playerid, issuerid, weaponid, amount, bodypart ); CallRemoteFunction( "OnPlayerDeathEx", "ddfd", playerid, issuerid, weaponid, amount, bodypart );
} }
SetPlayerArmour( playerid, p_PlayerArmour[ playerid ] [ E_POINTS ] ); SetPlayerArmour( playerid, p_PlayerArmour[ playerid ] [ E_POINTS ] );
SetPlayerHealth( playerid, p_PlayerHealth[ playerid ] [ E_POINTS ] ); SetPlayerHealth( playerid, p_PlayerHealth[ playerid ] [ E_POINTS ] );
CallRemoteFunction( "OnPlayerDamagePlayer", "ddfdd", issuerid, playerid, amount, weaponid, bodypart );
} }
} }
else else
@ -261,7 +263,7 @@
if( ( p_PlayerHealth[ playerid ] [ E_POINTS ] -= tmp_amount ) <= ( weaponid == 37 ? 0.99999 : 0.0 ) ) { if( ( p_PlayerHealth[ playerid ] [ E_POINTS ] -= tmp_amount ) <= ( weaponid == 37 ? 0.99999 : 0.0 ) ) {
p_acSpawned{ playerid } = false; // They're dead! p_acSpawned{ playerid } = false; // They're dead!
if ( weaponid == 37 ) SetPlayerHealth( playerid, -1 ); if ( weaponid == 37 ) SetPlayerHealth( playerid, -1 );
OnPlayerDeathEx( playerid, issuerid, weaponid, amount, bodypart ); CallRemoteFunction( "OnPlayerDeathEx", "ddfd", playerid, issuerid, weaponid, amount, bodypart );
} }
} }
} }
@ -319,7 +321,7 @@
{ {
new new
Float: tmp, Float: tmp,
Float: distance = GetDistanceBetweenPlayers( playerid, damagedid ), // Calc distance between players Float: distance = ac_GetDistanceBetweenPlayers( playerid, damagedid ), // Calc distance between players
Float: tmp_amount = amount // this amount is extremely unreliable Float: tmp_amount = amount // this amount is extremely unreliable
; ;
//printf("Proposed dmg %f kinda %f (min: %f, max: %f, rng: %f)", amount, tmp_amount, GetWeaponMinRange( weaponid ), GetWeaponMaxRange( weaponid ), distance ); //printf("Proposed dmg %f kinda %f (min: %f, max: %f, rng: %f)", amount, tmp_amount, GetWeaponMinRange( weaponid ), GetWeaponMaxRange( weaponid ), distance );
@ -340,11 +342,13 @@
if( ( p_PlayerHealth[ damagedid ] [ E_POINTS ] -= tmp_amount ) < 0.0 ) { if( ( p_PlayerHealth[ damagedid ] [ E_POINTS ] -= tmp_amount ) < 0.0 ) {
p_acSpawned{ damagedid } = false; // They're dead! p_acSpawned{ damagedid } = false; // They're dead!
OnPlayerDeathEx( damagedid, playerid, weaponid, amount, bodypart ); CallRemoteFunction( "OnPlayerDeathEx", "ddfd", damagedid, playerid, weaponid, amount, bodypart );
} }
SetPlayerArmour( damagedid, p_PlayerArmour[ damagedid ] [ E_POINTS ] ); SetPlayerArmour( damagedid, p_PlayerArmour[ damagedid ] [ E_POINTS ] );
SetPlayerHealth( damagedid, p_PlayerHealth[ damagedid ] [ E_POINTS ] ); SetPlayerHealth( damagedid, p_PlayerHealth[ damagedid ] [ E_POINTS ] );
CallRemoteFunction( "OnPlayerDamagePlayer", "ddfdd", playerid, damagedid, amount, weaponid, bodypart );
} }
} }

View File

@ -57,7 +57,7 @@ new
p_LastWeaponIssuer [ MAX_PLAYERS ], p_LastWeaponIssuer [ MAX_PLAYERS ],
// Weapon Hacks // Weapon Hacks
bool: p_PlayerHasWeapon [ MAX_PLAYERS ] [ MAX_WEAPONS char ], bool: p_PlayerHasWeapon [ MAX_PLAYERS ] [ AC_MAX_WEAPONS char ],
//p_PlayerWeaponUpdateTime [ MAX_PLAYERS ], //p_PlayerWeaponUpdateTime [ MAX_PLAYERS ],
p_SelectedClassID [ MAX_PLAYERS ], p_SelectedClassID [ MAX_PLAYERS ],

View File

@ -34,7 +34,7 @@ stock AC_GivePlayerWeapon( playerid, weaponid, ammo )
{ {
//p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000; //p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000;
if( weaponid < MAX_WEAPONS ) if( weaponid < AC_MAX_WEAPONS )
p_PlayerHasWeapon[ playerid ] { weaponid } = true; p_PlayerHasWeapon[ playerid ] { weaponid } = true;
return GivePlayerWeapon( playerid, weaponid, ammo ); return GivePlayerWeapon( playerid, weaponid, ammo );
@ -56,7 +56,7 @@ stock AC_ResetPlayerWeapons( playerid )
//p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000; //p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000;
for ( new i = 0; i < MAX_WEAPONS; i++ ) for ( new i = 0; i < AC_MAX_WEAPONS; i++ )
p_PlayerHasWeapon[ playerid ] { i } = false; p_PlayerHasWeapon[ playerid ] { i } = false;
return bReset; return bReset;
@ -73,9 +73,9 @@ stock AC_ResetPlayerWeapons( playerid )
stock AC_SetSpawnInfo( playerid, team, skin, Float: x, Float: y, Float: z, Float: Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo ) stock AC_SetSpawnInfo( playerid, team, skin, Float: x, Float: y, Float: z, Float: Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo )
{ {
if ( weapon1 != -1 && weapon1 < MAX_WEAPONS ) p_PlayerHasWeapon[ playerid ] { weapon1 } = true; if ( weapon1 != -1 && weapon1 < AC_MAX_WEAPONS ) p_PlayerHasWeapon[ playerid ] { weapon1 } = true;
if ( weapon2 != -1 && weapon2 < MAX_WEAPONS ) p_PlayerHasWeapon[ playerid ] { weapon2 } = true; if ( weapon2 != -1 && weapon2 < AC_MAX_WEAPONS ) p_PlayerHasWeapon[ playerid ] { weapon2 } = true;
if ( weapon3 != -1 && weapon3 < MAX_WEAPONS ) p_PlayerHasWeapon[ playerid ] { weapon3 } = true; if ( weapon3 != -1 && weapon3 < AC_MAX_WEAPONS ) p_PlayerHasWeapon[ playerid ] { weapon3 } = true;
return SetSpawnInfo( playerid, team, skin, x, y, z, Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo ); return SetSpawnInfo( playerid, team, skin, x, y, z, Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo );
} }
@ -156,7 +156,7 @@ stock AC_CreateDynamicPickup( modelid, type, Float: x, Float: y, Float: z, world
if( type == 2 || type == 3 || type == 15 || type == 22 ) if( type == 2 || type == 3 || type == 15 || type == 22 )
{ {
for( new i = 0; i < MAX_WEAPONS; i ++ ) for( new i = 0; i < AC_MAX_WEAPONS; i ++ )
if( GetWeaponModel( i ) == modelid ) if( GetWeaponModel( i ) == modelid )
SetGVarInt( "ac_WeaponPickup", i, id ); SetGVarInt( "ac_WeaponPickup", i, id );
} }
@ -178,7 +178,7 @@ stock vWeaponHackCheck( playerid, keys )
new new
iWeapon = GetPlayerWeapon( playerid ); iWeapon = GetPlayerWeapon( playerid );
if( iWeapon > -1 && iWeapon < MAX_WEAPONS ) if( iWeapon > -1 && iWeapon < AC_MAX_WEAPONS )
{ {
if( !p_PlayerHasWeapon[ playerid ] { iWeapon } && ( iWeapon != 0 && iWeapon != 40 ) ) { if( !p_PlayerHasWeapon[ playerid ] { iWeapon } && ( iWeapon != 0 && iWeapon != 40 ) ) {
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_WEAPON ); CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_WEAPON );