Death Evaders - 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: Death Evaders (
/showthread.php?tid=361586)
Death Evaders -
CoDeZ - 21.07.2012
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
Re: Death Evaders -
[KHK]Khalid - 21.07.2012
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;
}
Re: Death Evaders -
CoDeZ - 21.07.2012
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?
Re: Death Evaders -
[KHK]Khalid - 21.07.2012
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?
Re: Death Evaders -
CoDeZ - 21.07.2012
Sorry my bad , just saw a note on samp wiki , nvm , thanks