10.02.2012, 10:03
Hello, well I've got a pretty weird bug here. Or 2 actually... My script:
Here are the two issues: 1st - With some weapons, like the desert eagle, OnPlayerGiveDamage gets called 2 times (That's what the variable "test" is used for, but it looks like it doesn't fix it). And 2nd - Some low-damage weapons (like fists, dual UZIs, flowers etc.) are actually GIVING the attacked player HP, not taking it from him... Please help if you've got any ideas on how to fix this script.
pawn Code:
new Float:pHP[MAX_PLAYERS], bool:test, KillerID[MAX_PLAYERS], WeapID[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
pHP[playerid] = 100;
test = true;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(KillerID[playerid], playerid, WeapID[playerid]);
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if (test == true)
{
pHP[damagedid]-=amount;
if (pHP[damagedid] < 1)
{
KillerID[damagedid] = playerid;
WeapID[damagedid] = weaponid;
SetPlayerHealth(damagedid, 0);
}
else
{
SetPlayerHealth(damagedid, pHP[damagedid]);
}
test = false;
}
else
{
test = true;
}
return 1;
}