Textdraw isnt updating
#1

I tried abselously everything but nothing helps,whenever someone gets killed the score increases but the textdraw doesnt change.Can anyone please help me before I lose my mind?
pawn Код:
new SeaScore = 0,SfoScore = 0,ScoreTextLeo[24],ScoreTextSin[24];
new Text:SeaScoreTD,Text:SfoScoreTD;

public OnGameModeInit()
{
    format(ScoreTextSin,128,"Seals: %i",SeaScore);
    SeaScoreTD = TextDrawCreate(425,348,ScoreTextSin);
    TextDrawFont(SeaScoreTD,1);
    TextDrawLetterSize(SeaScoreTD,0.7,2);
    TextDrawColor(SeaScoreTD,0xff0000FF);
    TextDrawSetOutline(SeaScoreTD,false);
    TextDrawSetProportional(SeaScoreTD,true);
    TextDrawSetShadow(SeaScoreTD,1);
    format(ScoreTextLeo,128,"Speical Forces: %i",SfoScore);
    SfoScoreTD = TextDrawCreate(425,367,ScoreTextLeo);
    TextDrawFont(SfoScoreTD,1);
    TextDrawLetterSize(SfoScoreTD,0.7,2);
    TextDrawColor(SfoScoreTD,0x0000FFFF);
    TextDrawSetOutline(SfoScoreTD,false);
    TextDrawSetProportional(SfoScoreTD,true);
    TextDrawSetShadow(SfoScoreTD,1);
return 1; }

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,Text:SeaScoreTD);
    TextDrawShowForPlayer(playerid,Text:SfoScoreTD);
return 1; }

public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid,playerid,reason);
     
    if(GetPlayerTeam(killerid) == Team_Seals) {
        SeaScore++;
        TextDrawSetString(Text:SeaScoreTD,ScoreTextSin);
        for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { PlayerTextDrawShow(i,PlayerText:SeaScoreTD); } } }

    if(GetPlayerTeam(killerid) == Team_SpeicalForces) {
        SfoScore++;
        TextDrawSetString(Text:SfoScoreTD,ScoreTextLeo);
        for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { PlayerTextDrawShow(i,PlayerText:SfoScoreTD); } } }
   
    return 1;
}
Reply
#2

Use a timer and update the textdraw text every x seconds. It should work.
Reply
#3

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Use a timer and update the textdraw text every x seconds. It should work.
still doesnt work
Reply
#4

It does, if inside that callback, you display in a formated string the SeaScore.
Reply
#5

Quote:
Originally Posted by Dwane
Посмотреть сообщение
It does, if inside that callback, you display in a formated string the SeaScore.
I did this:
pawn Код:
public ScoreUpdate() {
    TextDrawDestroy(Text:SeaScoreTD);
    TextDrawDestroy(Text:SfoScoreTD);
    format(ScoreTextSin,128,"Seals: %i",SeaScore);
    SeaScoreTD = TextDrawCreate(425,348,ScoreTextSin);
    TextDrawFont(SeaScoreTD,1);
    TextDrawLetterSize(SeaScoreTD,0.7,2);
    TextDrawColor(SeaScoreTD,0xff0000FF);
    TextDrawSetOutline(SeaScoreTD,false);
    TextDrawSetProportional(SeaScoreTD,true);
    TextDrawSetShadow(SeaScoreTD,1);
    format(ScoreTextSfo,128,"Speical Forces: %i",SfoScore);
    SfoScoreTD = TextDrawCreate(425,367,ScoreTextSfo);
    TextDrawFont(SfoScoreTD,1);
    TextDrawLetterSize(SfoScoreTD,0.7,2);
    TextDrawColor(SfoScoreTD,0x0000FFFF);
    TextDrawSetOutline(SfoScoreTD,false);
    TextDrawSetProportional(SfoScoreTD,true);
    TextDrawSetShadow(SfoScoreTD,1);
    TextDrawShowForAll(Text:SfoScoreTD);
    TextDrawShowForAll(Text:SeaScoreTD);  }
And its working.. but isnt it a total waste of RAM usage? and its stupid to re-create the textdraw all the time isnt it?
Reply
#6

It depends. If you're using too many timers, then it is, but a timer isn't a problem!
You don't need to re-create this, but just update it by using;
pawn Код:
TextDrawSetString
Reply
#7

Quote:
Originally Posted by Dwane
Посмотреть сообщение
It depends. If you're using too many timers, then it is, but a timer isn't a problem!
You don't need to re-create this, but just update it by using;
pawn Код:
TextDrawSetString
I tried this but it didnt work,can you help me with that?
(And btw I have only 1 timer so it shouldnt affect the RAM usage so much,right?)
Reply
#8

Sure. This should work
pawn Код:
public ScoreUpdate()
{
    format(ScoreTextSin,128,"Seals: %i",SeaScore);
    TextDrawSetString(SeaScoreTD,ScoreTextSin);
    TextDrawFont(SeaScoreTD,1);
    TextDrawLetterSize(SeaScoreTD,0.7,2);
    TextDrawColor(SeaScoreTD,0xff0000FF);
    TextDrawSetOutline(SeaScoreTD,false);
    TextDrawSetProportional(SeaScoreTD,true);
    TextDrawSetShadow(SeaScoreTD,1);
    format(ScoreTextSfo,128,"Speical Forces: %i",SfoScore);
    TextDrawSetString(SfoScoreTD,ScoreTextSfo);
    TextDrawFont(SfoScoreTD,1);
    TextDrawLetterSize(SfoScoreTD,0.7,2);
    TextDrawColor(SfoScoreTD,0x0000FFFF);
    TextDrawSetOutline(SfoScoreTD,false);
    TextDrawSetProportional(SfoScoreTD,true);
    TextDrawSetShadow(SfoScoreTD,1);
    TextDrawShowForAll(Text:SfoScoreTD);
    TextDrawShowForAll(Text:SeaScoreTD);
    return 1;
}
No, it doesn't affect the RAM usage!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)