SA-MP Forums Archive
Problem with OnPlayerGiveDamage - 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: Problem with OnPlayerGiveDamage (/showthread.php?tid=640450)



Problem with OnPlayerGiveDamage - None1337 - 02.09.2017

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?


Re: Problem with OnPlayerGiveDamage - Jefff - 02.09.2017

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


Re: Problem with OnPlayerGiveDamage - RedGun2015 - 03.09.2017

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?


Re: Problem with OnPlayerGiveDamage - Astralis - 03.09.2017

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


Re: Problem with OnPlayerGiveDamage - None1337 - 03.09.2017

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.


Re: Problem with OnPlayerGiveDamage - 10MIN - 03.09.2017

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.


Re: Problem with OnPlayerGiveDamage - UberEverywhere - 03.09.2017

Код:
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


Re: Problem with OnPlayerGiveDamage - kAn3 - 03.09.2017

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;
}