SA-MP Forums Archive
OnPlayerTakeDamage - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerTakeDamage (/showthread.php?tid=481615)



OnPlayerTakeDamage - ReD_HunTeR - 16.12.2013

i need code if someone give damage to anyone it get store in new checkdamage
and when someone kill him, any player gives him damage will get money can you tell how to do that, if yes so tell me please


Re: OnPlayerTakeDamage - $Marco$ - 16.12.2013

I'm not going to write that for you but basicly you set the amount of damage you want in and add the cash to the shooter.

OnPlayerTakeDamage, for example

pawn Код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 24) // Checks that the user is using a Desert Eagle and he is really logged in.
{

        Float: fHealth;
        GetPlayerArmour( playerid, fHealth ); //Checks for player health.
        SetPlayerArmour( playerid, fHealth - 55 ); //Decreases 55 health.
        GiveMoney(issuerid, +55) // Gives the shooter 55 dollar.

}



Re: OnPlayerTakeDamage - ReD_HunTeR - 17.12.2013

no dude, thats not the right thing, that i need.
please read my post again.
ill found this in one server (91.121.6.5:8888 ) give damage to player and after that player died will the player who given damages will get 1 point..


Re: OnPlayerTakeDamage - Threshold - 17.12.2013

pawn Код:
//At the top of your script under your includes:
new LastDamager[MAX_PLAYERS];

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) LastDamager[playerid] = issuerid;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    //Underneath will give the damager $10,000. Change this however you like.
    if(LastDamager[playerid] != INVALID_PLAYER_ID) GivePlayerMoney(LastDamager[playerid], 10000);
    LastDamager[playerid] = INVALID_PLAYER_ID;
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++) //'foreach' is the better option here.
    {
        if(!IsPlayerConnected(i)) continue;
        if(LastDamager[i] == playerid) LastDamager[i] = INVALID_PLAYER_ID;
    }
    return 1;
}



Re: OnPlayerTakeDamage - ReD_HunTeR - 17.12.2013

ty BENZOAMGE