Textdraw not updating
#1

Hello, I'v got a problem that I am like staying awake from.
I do not know what is going on because I am 90 percent sure I do everything right,

At OnPlayerDeath the textdraw Deathz doesnt update, but at /setdeath it does,

What is wrong?

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    lastkiller[playerid] = killerid;
    PlayerInfo[playerid][Deaths] = PlayerInfo[playerid][Deaths] + 1;
    PlayerInfo[killerid][Kills] = PlayerInfo[killerid][Kills] + 1;
    new string[128];
    new string2[128];
    format(string, sizeof(string), "Kills: %i", PlayerInfo[killerid][Kills]);
    TextDrawSetString(Killz[killerid], string);
    format(string2, sizeof(string2), "Deaths: %i", PlayerInfo[playerid][Deaths]);
    TextDrawSetString(Deathz[playerid], string2);
    TextDrawSetString(Killz[playerid], string2);
    SetTimerEx("update_texts", 50, false,"i", playerid);
    return 1;
}

CMD:setdeath(playerid, params[])
{
    new string2[128];
    format(string2, sizeof(string2), "Deaths: %i", PlayerInfo[playerid][Deaths]);
    TextDrawSetString(Deathz[playerid], string2);
    return 1;
}
CMD:deaths(playerid, params[])
{
    new str[128];
    format(str, sizeof(str), "Deaths: %d", PlayerInfo[playerid][Deaths]);
    SendClientMessage(playerid, COLOR_GREEN, str);
    return 1;
}
Reply
#2

pawn Код:
TextDrawSetString(Deathz[playerid], string2);
TextDrawSetString(Killz[playerid], string);
There you go. You was setting it to the same string as kills.
Reply
#3

Wouldnt change anything,
Because they are both not updating.

pawn Код:
format(string2, sizeof(string2), "Deaths: %i", PlayerInfo[playerid][Deaths]);
In the case I made Killz should also update to deaths


I did Killz for debuging
Reply
#4

Try adding TextDrawShowForPlayer(playerid, Deathz[playerid]);
Reply
#5

How would that make sense?

The textdraw is already visable, it just shows 0 instead of the amount of deaths
Reply
#6

Make this command and than type it IG before and after akill yourself, and see if the variable PlayerInfo is actualy updating..

pawn Код:
CMD:deaths(playerid, params[])
{
    new string[64];
    format(string, sizeof(string), "Deaths: %d", PlayerInfo[playerid][Deaths]):
    SendClientMessage(playerid, 0xFFFFFFFF, string):
    return 1;
}
Reply
#7

You need a timer to update the textdraw.
Reply
#8

there is a easy way.
use a ingame textdraw editor..
Reply
#9

Quote:
Originally Posted by BEER-samp
Посмотреть сообщение
there is a easy way.
use a ingame textdraw editor..
That makes no sense.
That doesnt change anything.

@Logitech

Already tried, didnt work
Reply
#10

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
You need a timer to update the textdraw.
why?

that makes no sense!



@OP

add some print statements
to ensure your vars are being updated and the callback is being called.

pawn Код:
print("onplayerdeath");
printf("string1=%s",string);
printf("string2=%s",string2);
and as a side note(not that it matters)
you can increment the vars like this
pawn Код:
PlayerInfo[playerid][Deaths]++;
    PlayerInfo[killerid][Kills]++;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)