SA-MP Forums Archive
Textdraws only shows damage when player stands still - 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: Textdraws only shows damage when player stands still (/showthread.php?tid=513483)



Textdraws only shows damage when player stands still - GwENiko - 16.05.2014

I have scripted a textdraw that shows the player damage whenever he takes or give damage, although i have noticed it only works when the player is standing still, if he is actually moving and during lag shooting, whenever he gets hits, the textdraw won't show up displaying whether he took damage, or caused.


pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
 // Damage System
    new string[128];
    new Pname[MAX_PLAYER_NAME];
    DamageGiven[playerid] = GetPVarFloat(damagedid, "DamageTaken");
    TextDrawBackgroundColor(Textdraw4[playerid], 255);
    TextDrawFont(Textdraw4[playerid], 1);
    TextDrawLetterSize(Textdraw4[playerid], 0.360000, 1.100000);
    TextDrawColor(Textdraw4[playerid], 16711935);
    TextDrawSetOutline(Textdraw4[playerid], 1);
    TextDrawSetProportional(Textdraw4[playerid], 1);
    GetPlayerName(damagedid, Pname, sizeof(Pname));
    SetPVarFloat(damagedid, "DamageGiven", DamageGiven[damagedid] + amount);
    format(string, sizeof(string), "%s +(%.0f)", Pname, DamageGiven[damagedid] + amount);
    TextDrawSetString(Textdraw4[playerid], string);
    TextDrawShowForPlayer(playerid, Textdraw4[playerid]);
    SetTimerEx("DamageGivenTextdraw", 7500, true, "f", damagedid);

        return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{

        // Ding System
    PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
        // Damage System
    new cstring[128];
    new Pname[MAX_PLAYER_NAME];
    DamageTaken[issuerid] = GetPVarFloat(issuerid, "DamageTaken");
    TextDrawBackgroundColor(Textdraw11[playerid], 255);
    TextDrawFont(Textdraw11[playerid], 1);
    TextDrawLetterSize(Textdraw11[playerid], 0.350000, 1.300000);
    TextDrawColor(Textdraw11[playerid], -16776961);
    TextDrawSetOutline(Textdraw11[playerid], 1);
    TextDrawSetProportional(Textdraw11[playerid], 1);
    GetPlayerName(issuerid, Pname, sizeof(Pname));
    GetPVarFloat(issuerid, "DamageTaken");
    SetPVarFloat(issuerid, "DamageTaken", DamageTaken[issuerid]+amount);
    format(cstring, sizeof(cstring), "%s -(%.0f)", Pname, DamageTaken[issuerid] + amount);
    TextDrawSetString(Textdraw11[playerid], cstring);
    TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
    SetTimerEx("DamageTakenTextdraw", 7500, false,"f", issuerid);
    if(issuerid == INVALID_PLAYER_ID)
    {
    TextDrawBackgroundColor(Textdraw11[playerid], 255);
    TextDrawFont(Textdraw11[playerid], 1);
    TextDrawLetterSize(Textdraw11[playerid], 0.350000, 1.300000);
    TextDrawColor(Textdraw11[playerid], -16776961);
    TextDrawSetOutline(Textdraw11[playerid], 1);
    TextDrawSetProportional(Textdraw11[playerid], 1);
    format(cstring, sizeof(cstring), "Collision -(%.0f)",amount);
    TextDrawSetString(Textdraw11[playerid], cstring);
    TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
    }
        return 1;



Re: Textdraws only shows damage when player stands still - GwENiko - 16.05.2014

I made a few slight changes on the script, sorry for double post, the edit button didn't seem to work, anyways does anyone knows why? If i actually hit the player skin, it detects the amount of damage, but no health lost ( lag shoot being used), but if we hit him on his lag spot, the textdraw won't shoot up.


Re : Textdraws only shows damage when player stands still - Ramoboss - 16.05.2014

pawn Код:
if(issuerid == INVALID_PLAYER_ID)
    {
    TextDrawBackgroundColor(Textdraw11[playerid], 255);
    TextDrawFont(Textdraw11[playerid], 1);
    TextDrawLetterSize(Textdraw11[playerid], 0.350000, 1.300000);
    TextDrawColor(Textdraw11[playerid], -16776961);
    TextDrawSetOutline(Textdraw11[playerid], 1);
    TextDrawSetProportional(Textdraw11[playerid], 1);
    format(cstring, sizeof(cstring), "Collision -(%.0f)",amount);
    TextDrawSetString(Textdraw11[playerid], cstring);
    TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
    }
WTF IS THAT !!!

try like this :

pawn Код:
if(issuerid != INVALID_PLAYER_ID)
    {
    TextDrawBackgroundColor(Textdraw11[playerid], 255);
    TextDrawFont(Textdraw11[playerid], 1);
    TextDrawLetterSize(Textdraw11[playerid], 0.350000, 1.300000);
    TextDrawColor(Textdraw11[playerid], -16776961);
    TextDrawSetOutline(Textdraw11[playerid], 1);
    TextDrawSetProportional(Textdraw11[playerid], 1);
    format(cstring, sizeof(cstring), "Collision -(%.0f)",amount);
    TextDrawSetString(Textdraw11[playerid], cstring);
    TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
    }



Re: Re : Textdraws only shows damage when player stands still - GwENiko - 16.05.2014

Quote:
Originally Posted by Ramoboss
Посмотреть сообщение
pawn Код:
if(issuerid == INVALID_PLAYER_ID)
    {
    TextDrawBackgroundColor(Textdraw11[playerid], 255);
    TextDrawFont(Textdraw11[playerid], 1);
    TextDrawLetterSize(Textdraw11[playerid], 0.350000, 1.300000);
    TextDrawColor(Textdraw11[playerid], -16776961);
    TextDrawSetOutline(Textdraw11[playerid], 1);
    TextDrawSetProportional(Textdraw11[playerid], 1);
    format(cstring, sizeof(cstring), "Collision -(%.0f)",amount);
    TextDrawSetString(Textdraw11[playerid], cstring);
    TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
    }
WTF IS THAT !!!

try like this :

pawn Код:
if(issuerid != INVALID_PLAYER_ID)
    {
    TextDrawBackgroundColor(Textdraw11[playerid], 255);
    TextDrawFont(Textdraw11[playerid], 1);
    TextDrawLetterSize(Textdraw11[playerid], 0.350000, 1.300000);
    TextDrawColor(Textdraw11[playerid], -16776961);
    TextDrawSetOutline(Textdraw11[playerid], 1);
    TextDrawSetProportional(Textdraw11[playerid], 1);
    format(cstring, sizeof(cstring), "Collision -(%.0f)",amount);
    TextDrawSetString(Textdraw11[playerid], cstring);
    TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
    }
That is meant to tell the player he lost damage due to collision, if you use if(issuerid != INVALID_PLAYER_ID), correct me if i am wrong, wouldn't that be the same as saying that issuerid is valid, therefore doing what the code above that one, does?


Re: Textdraws only shows damage when player stands still - GwENiko - 17.05.2014

bump


Re: Textdraws only shows damage when player stands still - GwENiko - 24.05.2014

sorry, its been a while bump


Re: Textdraws only shows damage when player stands still - GwENiko - 25.05.2014

bump i still have this problem :/ the whole code works fine, except "OnPlayerGiveDamage" seems to work only when the player body is hit, and not only lag shoot.