OnPlayerTakeDamage
#1

It looks like OnPlayerTakeDamage is failing to work or return any value.

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
		format(gString, sizeof(gString), "{aa0000}- %d HP", amount);
	    PlayerDamage[playerid] = Create3DTextLabel(gString, 0xFFFFFFFF, 0.0, 0.0, 0.0, 7.5, -1);
	    Attach3DTextLabelToPlayer(PlayerDamage[playerid], playerid, 0.0, 0.0, 0.4);
	    SetTimerEx("RemoveDamageLabel", 3000, false, "d", playerid);
    }
    return 1;
}
Reply
#2

Looks like another system is conflicting with it.
Reply
#3

Is any of these includes has something to do with it?
Код:
#include <a_samp>
#include <a_mysql>
#include <sscanf2>
#include <zcmd>
#include <SPC>
#include <streamer>
#include <strlib>
#include <regex>
#include <foreach>
#include <fixes>
#include <timerfix>
Reply
#4

Health is a float not an integer...
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        format(gString, sizeof(gString), "{aa0000}- %f HP", amount); //Hp is a float..
        PlayerDamage[playerid] = Create3DTextLabel(gString, 0xFFFFFFFF, 0.0, 0.0, 0.0, 7.5, -1);
        Attach3DTextLabelToPlayer(PlayerDamage[playerid], playerid, 0.0, 0.0, 0.4);
        SetTimerEx("RemoveDamageLabel", 3000, false, "d", playerid);
    }
    return 1;
}
Reply
#5

This is not my problem here, I have also tried printing whenever a player is taking damage, still doesnt work.
Reply
#6

Quote:
Originally Posted by CriticalRP
Посмотреть сообщение
This is not my problem here, I have also tried printing whenever a player is taking damage, still doesnt work.
Whenever a player is taking damage by another player or self-inflicted?

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    print("OnPlayerTakeDamage is being called..");
    return 1;
}
Reply
#7

Tried them both, both don't work.
Reply
#8

This code wouldn't work anyways, it will create 3dtext with lost reference the timer should be set using the 3dtext ID not the playerid.
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
This code wouldn't work anyways, it will create 3dtext with lost reference the timer should be set using the 3dtext ID not the playerid.
Should - he uses a MAX_PLAYER array so the playerID parameter is enough to destroy or modify it!
OT: You should try a print through OnPlayerGiveDamage too, and try de-including some files as said above! Check if a hook to this callback exists somewhere.
Reply
#10

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Should - he uses a MAX_PLAYER array so the playerID parameter is enough to destroy or modify it!
OT: You should try a print through OnPlayerGiveDamage too, and try de-including some files as said above! Check if a hook to this callback exists somewhere.
What happens when a player is shot twice think about it, the 3dtext id reference would be lost and you'd start getting 3dtext labels that wouldn't be deleted read the code.
Reply
#11

Everything's sorted out but that includes thing, I couldn't find any conflict or something that coalesces with OnPlayerTakeDamage.
Reply
#12

Quote:
pawn Код:
Delete3DTextLabel(PlayerDamage[playerid]);
PlayerDamage[playerid] = Create3DTextLabel(gString, 0xFFFFFFFF, 0.0, 0.0, 0.0, 7.5, -1);
Attach3DTextLabelToPlayer(PlayerDamage[playerid], playerid, 0.0, 0.0, 0.4);
SetTimerEx("RemoveDamageLabel", 3000, false, "d", PlayerDamage[playerid]);
Can you imagine these timers called everytime when callback is called? Also, my suggestion is to kill timer before it's called.
Reply
#13

Optimization is not the actual problem here, I just want the public to be called.
Reply
#14

Yes you need to insert
Fix() in the function

OK
Reply
#15

Why not just use SetPlayerChatBubble ?
Reply
#16

This is not my problem here, the problem is that the callback in not being called.
Reply
#17

Quote:
Originally Posted by Richie©
Посмотреть сообщение
Why not just use SetPlayerChatBubble ?
That is probably a very very good way to do it.
Reply
#18

I can't even use SendClientMessage as the callback is not being called.

Anyone?
Reply
#19

Bump.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)