Anti-lag shoot KILL - 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: Anti-lag shoot KILL (
/showthread.php?tid=366747)
Anti-lag shoot KILL -
Dan. - 07.08.2012
I have this code, that really works it's awesome, but I have a problem with it. It uses SetPlayerHealth, so sometimes when a player kills a player, in the death message it's saying that he commited a suicide (because when you set a players health to 0 with SetPlayerHealth, that message comes up).
Code:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if(damagedid != INVALID_PLAYER_ID)
{
if(gTeam[playerid] != gTeam[damagedid])
{
new Float:HEALTH;
new Float:ARMOR;
new Float:DAMAGE;
GetPlayerArmour(damagedid, ARMOR);
GetPlayerHealth(damagedid, HEALTH);
if(ARMOR > 0)
{
if(amount > ARMOR)
{
ARMOR = 0;
SetPlayerArmour(damagedid, 0.0);
SetPlayerHealth(damagedid, HEALTH);
return 1;
}
else
{
DAMAGE = ARMOR-amount;
SetPlayerArmour(damagedid, DAMAGE);
SetPlayerHealth(damagedid, HEALTH);
}
}
if(ARMOR < 1)
{
HEALTH = HEALTH - amount;
SetPlayerHealth(damagedid, HEALTH);
}
}
}
return 1;
}
So how to edit that code, when a player kills a player, it will send a death message that the player killed him, not the SetPlayerHealth (suicide) message.
AW: Anti-lag shoot KILL -
Nero_3D - 07.08.2012
I would probably write it like that
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) {
if(damagedid != INVALID_PLAYER_ID) {
if(gTeam[playerid] != gTeam[damagedid]) {
new
Float: health,
Float: armour
;
GetPlayerArmour(damagedid, armour);
GetPlayerHealth(damagedid, health);
if((armour -= amount) < 0.0) {
health += armour;
}
if(0.0 < health) {
SetPlayerArmour(damagedid, armour);
SetPlayerHealth(damagedid, health);
}
}
}
return 1;
}
Re: Anti-lag shoot KILL -
Dan. - 08.08.2012
I cant understand your code very well, I mean, what do these "-=", "+=" signs mean? If someone could give me a link to a wiki of these or something I'd be grateful.
Re: Anti-lag shoot KILL -
Vince - 08.08.2012
a += b is the same as a = a + b. Same for -=, *=, /=, etc.
Re: Anti-lag shoot KILL -
IceMeteor - 08.08.2012
Actually what is the purpose of that script?