[Include] leEx - Leadaim Extension
#1

I am currently writing a series of extensions, adding functions and callbacks to various subjects like vehicles, objects, skins, and so on.

This is my leadaim extension. (Removes the need to leadaim)

pawn Код:
/******************************************************************************/

new leEx_Killer [MAX_PLAYERS],
    leEx_Reason [MAX_PLAYERS];

/******************************************************************************/

forward OnPlayerTakeSyncDamage(playerid, issuerid, Float:amount, reason);
public OnPlayerTakeSyncDamage(playerid, issuerid, Float:amount, reason)
{
    new Float:health, Float:armour;
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    if(armour > 0)
    {
        if(amount > armour)
            SetPlayerArmour(playerid, 0.0);
        else
            SetPlayerArmour(playerid, armour - amount);
        amount -= armour;
    }
    if(health > 0 && amount > 0)
    {
        if(amount > health)
        {
            leEx_Killer [playerid] = issuerid;
            leEx_Reason [playerid] = reason;
            SetPlayerHealth(playerid, 0.0);
        }
        else
            SetPlayerHealth(playerid, health - amount);
    }
    return 1;
}

/******************************************************************************/

public OnPlayerSpawn(playerid)
{
    SetPlayerTeam(playerid, 0);
    leEx_Killer[playerid] = INVALID_PLAYER_ID;
    leEx_Reason[playerid] = 0;

    #if defined leEx_OnPlayerSpawn
        return leEx_OnPlayerSpawn(playerid);
    #else
        return 1;
    #endif
}
#if defined leEx_OnPlayerSpawn
    forward leEx_OnPlayerSpawn(playerid);
#endif
#if defined _ALS_OnPlayerSpawn
    #undef OnPlayerSpawn
#else
    #define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn leEx_OnPlayerSpawn

/******************************************************************************/

public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerConnected(leEx_Killer[playerid]))
    {
        killerid = leEx_Killer[playerid];
        reason = leEx_Reason[playerid];
    }

    #if defined leEx_OnPlayerDeath
        return leEx_OnPlayerDeath(playerid, killerid, reason);
    #else
        return 1;
    #endif
}
#if defined leEx_OnPlayerDeath
    forward leEx_OnPlayerDeath(playerid, killerid, reason);
#endif
#if defined _ALS_OnPlayerDeath
    #undef OnPlayerDeath
#else
    #define _ALS_OnPlayerDeath
#endif
#define OnPlayerDeath leEx_OnPlayerDeath

/******************************************************************************/

public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
    if(IsPlayerStreamedIn(playerid, damagedid) && IsPlayerStreamedIn(damagedid, playerid))
        OnPlayerTakeSyncDamage(damagedid, playerid, amount, weaponid);

    #if defined leEx_OnPlayerGiveDamage
        return leEx_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid);
    #else
        return 1;
    #endif
}
#if defined leEx_OnPlayerGiveDamage
    forward leEx_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid);
#endif
#if defined _ALS_OnPlayerGiveDamage
    #undef OnPlayerGiveDamage
#else
    #define _ALS_OnPlayerGiveDamage
#endif
#define OnPlayerGiveDamage leEx_OnPlayerGiveDamage

/******************************************************************************/

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(IsPlayerConnected(issuerid) && (weaponid == 37 || weaponid == 49 || weaponid == 50 || weaponid == 51 || (GetPlayerState(issuerid) == PLAYER_STATE_DRIVER && (weaponid == 31 || weaponid == 38))))
        OnPlayerTakeSyncDamage(playerid, issuerid, amount, weaponid);

    #if defined leEx_OnPlayerTakeDamage
        return leEx_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid);
    #else
        return 1;
    #endif
}
#if defined leEx_OnPlayerTakeDamage
    forward leEx_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid);
#endif
#if defined _ALS_OnPlayerTakeDamage
    #undef OnPlayerTakeDamage
#else
    #define _ALS_OnPlayerTakeDamage
#endif
#define OnPlayerTakeDamage leEx_OnPlayerTakeDamage

/******************************************************************************/
Just include it in your script like so:
pawn Код:
#include <leEx>
[ame]http://www.youtube.com/watch?v=b0LfuBgvA6U[/ame]

Enjoy.
Reply


Messages In This Thread
leEx - Leadaim Extension - by RedFusion - 23.01.2014, 05:02
Re: leEx - Leadaim Extension - by [FSaF]Jarno - 23.01.2014, 05:25
Re: leEx - Leadaim Extension - by RedFusion - 23.01.2014, 05:32
Re: leEx - Leadaim Extension - by PinkFloydLover - 23.01.2014, 07:46
Re: leEx - Leadaim Extension - by RedFusion - 24.01.2014, 17:24
Re: leEx - Leadaim Extension - by Pottus - 24.01.2014, 19:41
Re: leEx - Leadaim Extension - by RedFusion - 24.01.2014, 20:51
Re: leEx - Leadaim Extension - by Pottus - 24.01.2014, 22:35
Re: leEx - Leadaim Extension - by RedFusion - 24.01.2014, 22:49
Re: leEx - Leadaim Extension - by Pottus - 24.01.2014, 23:55

Forum Jump:


Users browsing this thread: 1 Guest(s)