OnPlayerTakeDamage doesn't work? -
Mado - 08.02.2013
Hello,
At my OnPlayerTakeDamage I have got this:
pawn Код:
if(weaponid == 24) //deagle
{
if(armour > 0)
{
pDamage[playerid] += 15;
}
else
{
pDamage[playerid] += 30;
}
}
and below that:
pawn Код:
if(pDamage[playerid] > 0)
{
pDamageTimer[playerid] = 120;
GameTextForPlayer(playerid, "~r~You've been hit!", 1500, 1);
if(pDamage[playerid] >= 100)
{
format(string, sizeof(string), "* %s falls to the ground due to the bullet injuries.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
}
}
But the effect (the messages, etc) isn't triggered. Is there anything I do wrong in here?
Re: OnPlayerTakeDamage doesn't work? -
Alternative112 - 08.02.2013
I think the problem is with the variable armor....how are you getting this? If it wasn't already fetched before the code block you posted, it will always be equal to 0.
Код:
if(weaponid == 24) //deagle
{
new Float:a;
GetPlayerArmour(playerid, a);
if(a > 0.0)
{
pDamage[playerid] += 15;
}
else
{
pDamage[playerid] += 30;
}
}
Re: OnPlayerTakeDamage doesn't work? -
Mado - 08.02.2013
The armour is checked in a part before this code, right under OnPlayerTakeDamage.
Re: OnPlayerTakeDamage doesn't work? -
Mado - 10.02.2013
Okay now I added a "print" below OnPlayerTakeDamage to see if it's triggered or not, and that is the issue; OnPlayerTakeDamage doesn't seem to be triggered.
What's this? :P
Re: OnPlayerTakeDamage doesn't work? -
Mado - 11.02.2013
2nd page bump
Re: OnPlayerTakeDamage doesn't work? -
MP2 - 11.02.2013
Is it used in any scripts/includes?
Re: OnPlayerTakeDamage doesn't work? -
Mado - 11.02.2013
Nope, only in the main gamemode.
Re: OnPlayerTakeDamage doesn't work? -
DaRk_RaiN - 11.02.2013
I can't see anything wrong, maybe you returned before this?if the call
Re: OnPlayerTakeDamage doesn't work? -
Mado - 12.02.2013
What do you mean?
Re: OnPlayerTakeDamage doesn't work? -
Mado - 13.02.2013
This is the whole callback:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
new points;
new string[128];
new Float:armour;
GetPlayerArmour(playerid, armour);
if(issuerid == INVALID_PLAYER_ID)
{
return 1;
}
if(GetPVarInt(playerid, "IsInArena") == 0)
{
if(GetPVarInt(playerid, "EventToken") == 0)
{
if(weaponid == 24) //deagle
{
if(armour > 0)
{
pDamage[playerid] += 15;
}
else
{
pDamage[playerid] += 30;
}
}
else if(weaponid == 23) //sdpistol
{
if(armour > 0)
{
pDamage[playerid] += 5;
}
else
{
pDamage[playerid] += 10;
}
}
else if(weaponid == 29) //MP5
{
if(armour > 0)
{
pDamage[playerid] += 10;
}
else
{
pDamage[playerid] += 15;
}
}
else if(weaponid == 30 || weaponid == 31) //M4 - AK47
{
if(armour > 0)
{
pDamage[playerid] += 10;
}
else
{
pDamage[playerid] += 20;
}
}
else if(weaponid == 25 || weaponid == 27) //Shotgun + SPAS12
{
if(armour > 0)
{
if(ProxDetectorS(12.0, playerid, issuerid))
{
pDamage[playerid] += 25;
}
else
{
pDamage[playerid] += 15;
}
}
else
{
if(ProxDetectorS(12.0, playerid, issuerid))
{
pDamage[playerid] += 35;
}
else
{
pDamage[playerid] += 20;
}
}
}
else if(weaponid == 34) //Sniper
{
if(ProxDetectorS(60.0, playerid, issuerid))
{
pDamage[playerid] += 50;
}
else
{
pDamage[playerid] += 0;
}
}
else if(weaponid == 33) //Rifle
{
pDamage[playerid] += 15;
}
if(pDamage[playerid] > 0)
{
pDamageTimer[playerid] = 120;
GameTextForPlayer(playerid, "~r~You've been hit!", 1500, 1);
if(pDamage[playerid] >= 100)
{
format(string, sizeof(string), "* %s falls to the ground due to the bullet injuries.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
}
}
}
}
return 1;
}