Problem with OnPlayerGiveDamage
#1

Hello, i have scripting something in OnPlayerGiveDamage, something like this:

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if(damagedid != INVALID_PLAYER_ID)
    {
      	if(PlayerInfo[damagedid][pFreezeTime] != 0)
        {
            SendClientMessage(playerid, -1, "This player is frozen, you can't shoot him.");
            amount = 0;
            return 0;
        }
    }
    return 1;
}
The text appears, but the damageid still take damage, why?
Reply
#2

https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
you need take player health GetPlayerHealth then set HP + amount
Reply
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
you need take player health GetPlayerHealth then set HP + amount
can you give an example pls?
Reply
#4

change damagedid to playerid. Because issuerid = damagedid. And SendClientMsg is damagedid not playerid.
Reply
#5

Quote:
Originally Posted by Astralis
Посмотреть сообщение
change damagedid to playerid. Because issuerid = damagedid. And SendClientMsg is damagedid not playerid.
I'm not interested for the message. I'm interested in the action.

The damagedid = is the player that take damage, no the player that shoot. And i need when some player is freeze (frozen) to not lose any hp.

And the message is sent to playerid (= player that shoot) to warnning him.
Reply
#6

PHP код:
          if(PlayerInfo[damagedid][pFreezeTime] != 0)
        {
            
SendClientMessage(playerid, -1"This player is frozen, you can't shoot him.");
            
SetPlayerHealth(damagedid, (GetPlayerHealth(damagedid) + amount) );
            return 
0;
        } 
I think this would work.
Reply
#7

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new float:health;
    GetPlayerHealth(damagedid, health);
    if(damagedid != INVALID_PLAYER_ID)
    {
      	if(PlayerInfo[damagedid][pFreezeTime] != 0)
        {
            SendClientMessage(playerid, -1, "This player is frozen, you can't shoot him.");
            SetPlayerHealth(damagedid, health);
            amount = 0;
            return 0;
        }
    }
    return 1;
}
untested, not sure if it's even correct lol
just try, if it didn't work just let me know
Reply
#8

Why not use OnPlayerTakeDamage?
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    new Float:health, Float:armor;
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armor);

    if(playerid != INVALID_PLAYER_ID)
    {
      	if(PlayerInfo[playerid][pFreezeTime] != 0)
        {
            SetPlayerHealth(playerid, health);
            SetPlayerArmor(playerid, armor);
            return SendClientMessage(issuerid, -1, "This player is frozen, you can't shoot him.");
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)