Death Evaders
#1

Hello guys , i have this code

pawn Код:
OnPlayerDeath(playerid,killerid,reason)
{
 SendDeathMessage(killerid , playerid , reason);
 //rest of my code
return 1;
}
Now my problem is like this :
Player A Attacks Player B
Player B got 5 HP , player B jumps from high way , he death evaded , and now , on death list it appeared like Player B is wasted , i want the death list to Assign the kill to Player A , and the reason would be the last weapons player A used on player B before his death
Sound complicated i know , but any help would be appreciated
Reply
#2

Hmm you can use OnPlayerTakeDamage to get around this, code:

pawn Код:
new LastAttacker[MAX_PLAYERS]; // a variable to store the last player who gives damage
new LastAttackerWeapon[MAX_PLAYERS]; // a variable to store the weapon of the last player who gives damage

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(IsPlayerConnected(issuerid)) // if the issuer connected
    {
        LastAttacker[playerid] = issuerid; // now the last one who attacked our victim is issuerid
        LastAttackerWeapon[playerid] = weaponid; // the weapon of the issuerid which was used to damage the victim
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(reason == 54) // Splat. You can change that if you want
    {
        if(IsPlayerConnected(LastAttacker[playerid])) // if the last player who gave damage is connected
        {
            SendDeathMessage(LastAttacker[playerid], playerid, LastAttackerWeapon[playerid]);
            // Other stuff
        }
        else // not connected
        {
            SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
            // Other stuff
        }
    }
    return 1;
}
Edit:

Or (for the OnPlayerDeath part)

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid == INVALID_PLAYER_ID)
    {
        if(IsPlayerConnected(LastAttacker[playerid])) // if the last player who gave damage is connected
        {
            SendDeathMessage(LastAttacker[playerid], playerid, LastAttackerWeapon[playerid]);
            // Other stuff
        }
        else // not connected
        {
            SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
            // Other stuff
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
Hmm you can use OnPlayerTakeDamage to get around this, code:

pawn Код:
new LastAttacker[MAX_PLAYERS]; // a variable to store the last player who gives damage
new LastAttackerWeapon[MAX_PLAYERS]; // a variable to store the weapon of the last player who gives damage

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(IsPlayerConnected(issuerid)) // if the issuer connected
    {
        LastAttacker[playerid] = issuerid; // now the last one who attacked our victim is issuerid
        LastAttackerWeapon[playerid] = weaponid; // the weapon of the issuerid which was used to damage the victim
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(reason == 54) // Splat. You can change that if you want
    {
        if(IsPlayerConnected(LastAttacker[playerid])) // if the last player who gave damage is connected
        {
            SendDeathMessage(LastAttacker[playerid], playerid, LastAttackerWeapon[playerid]);
            // Other stuff
        }
        else // not connected
        {
            SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
            // Other stuff
        }
    }
    return 1;
}
Edit:

Or (for the OnPlayerDeath part)

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid == INVALID_PLAYER_ID)
    {
        if(IsPlayerConnected(LastAttacker[playerid])) // if the last player who gave damage is connected
        {
            SendDeathMessage(LastAttacker[playerid], playerid, LastAttackerWeapon[playerid]);
            // Other stuff
        }
        else // not connected
        {
            SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
            // Other stuff
        }
    }
    return 1;
}
Excuse me , but wouldn't OnPlayerTakeDamage remove lag shooting from the server?
Reply
#4

No, it wouldn't. I explained everything I did in comments. All I did in the OnPlayerTakeDamage callback was setting some variables. So, how would that affect lag shooting?
Reply
#5

Sorry my bad , just saw a note on samp wiki , nvm , thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)