Textdraw not updating -
milanosie - 28.05.2012
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;
}
Re: Textdraw not updating -
ricardo178 - 28.05.2012
pawn Код:
TextDrawSetString(Deathz[playerid], string2);
TextDrawSetString(Killz[playerid], string);
There you go. You was setting it to the same string as kills.
Re: Textdraw not updating -
milanosie - 28.05.2012
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
Re: Textdraw not updating -
ricardo178 - 28.05.2012
Try adding TextDrawShowForPlayer(playerid, Deathz[playerid]);
Re: Textdraw not updating -
milanosie - 28.05.2012
How would that make sense?
The textdraw is already visable, it just shows 0 instead of the amount of deaths
Re: Textdraw not updating -
ricardo178 - 28.05.2012
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;
}
Re: Textdraw not updating -
Face9000 - 28.05.2012
You need a timer to update the textdraw.
Re: Textdraw not updating -
mickos - 28.05.2012
there is a easy way.
use a ingame textdraw editor..
Re: Textdraw not updating -
milanosie - 28.05.2012
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
Re: Textdraw not updating -
Jonny5 - 28.05.2012
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]++;