TextDraw Update
#1

Alright, I am having trouble with setting a string in two textdraws!

Here is what I have:
pawn Код:
//Under OnGamemodeInit
Textdraw0 = TextDrawCreate(4.000000,287.000000,"_");
TextDrawAlignment(Textdraw0,0);
TextDrawBackgroundColor(Textdraw0,0x000000ff);
TextDrawFont(Textdraw0,3);
TextDrawLetterSize(Textdraw0,0.399999,1.300000);
TextDrawColor(Textdraw0,0x0000ffff);
TextDrawSetProportional(Textdraw0,1);
TextDrawSetShadow(Textdraw0,2);

Textdraw1 = TextDrawCreate(4.000000,304.000000,"_");
TextDrawAlignment(Textdraw1,0);
TextDrawBackgroundColor(Textdraw1,0x000000ff);
TextDrawFont(Textdraw1,3);
TextDrawLetterSize(Textdraw1,0.399999,1.300000);
TextDrawColor(Textdraw1,0x0000ffff);
TextDrawSetProportional(Textdraw1,1);
TextDrawSetShadow(Textdraw1,2);
So each time the player does something good in the team, the whole team will get cash that can't be accessed yet.
But the Textdraws will show how much both team have earnt.
pawn Код:
public UpdateTeamCash()
{
new string1[60];
new string2[60];
format(string1, sizeof(string1), "Team 1 Cash: %s", T1Cash);
format(string2, sizeof(string2), "Team 2 Cash: %s", T2Cash);
TextDrawSetString(Textdraw0,string1);
TextDrawSetString(Textdraw1,string2);
return 1;
}
That is being called on each time they player does something for the team.
Updates the textdraws I thought!

T1Cash and T2Cash are like
pawn Код:
//On Top of Script
new T1Cash = 0;
new T2Cash = 0;
Now this is the bit which sets the teams cash!
pawn Код:
if(gTeam[playerid] == 0)
    {
    T1Cash = T1Cash+1000;
    }
    else if(gTeam[playerid] == 1)
    {
    T2Cash = T2Cash+1000;
    }
    SendClientMessage(playerid, COLOR_YELLOW, "$1000 has been added to your teams cash!.");
    }
Anyone got any ideas on how I can fix this?
Reply
#2

pawn Код:
stock TextDrawUpdate(Text:TextID) {
     TextDrawHideForAll(TextID);
     TextDrawShowForAll(TextID);
}
pawn Код:
public UpdateTeamCash()
{
new string1[60];
new string2[60];
format(string1, sizeof(string1), "Team 1 Cash: %s", T1Cash);
format(string2, sizeof(string2), "Team 2 Cash: %s", T2Cash);
TextDrawSetString(Textdraw0,string1);
TextDrawSetString(Textdraw1,string2);
TextDrawUpdate(TextDraw0);
TextDrawUpdate(TextDraw1);
return 1;
}
Reply
#3

Now it will be refresh every update for every player
pawn Код:
public UpdateTeamCash()
{
   new string1[60];
   new string2[60];
   format(string1, sizeof(string1), "Team 1 Cash: %s", T1Cash);
   format(string2, sizeof(string2), "Team 2 Cash: %s", T2Cash);
   for(new i; i<MAX_PLAYERS; i++)
   {
      TextDrawHideForPlayer(i, Textdraw0);
      TextDrawHideForPlayer(i, Textdraw1);
      TextDrawSetString(Textdraw0,string1);
      TextDrawSetString(Textdraw1,string2);
      TextDrawShowForPlayer(i, Textdraw0);
      TextDrawShowForPlayer(i, Textdraw1);
   }
   return 1;
}
Edit: There was already a reply ^^
Reply
#4

Quote:
Originally Posted by CAR
Посмотреть сообщение
Now it will be refresh every update for every player
pawn Код:
public UpdateTeamCash()
{
   new string1[60];
   new string2[60];
   format(string1, sizeof(string1), "Team 1 Cash: %s", T1Cash);
   format(string2, sizeof(string2), "Team 2 Cash: %s", T2Cash);
   for(new i; i<MAX_PLAYERS; i++)
   {
      TextDrawHideForPlayer(i, Textdraw0);
      TextDrawHideForPlayer(i, Textdraw1);
      TextDrawSetString(Textdraw0,string1);
      TextDrawSetString(Textdraw1,string2);
      TextDrawShowForPlayer(i, Textdraw0);
      TextDrawShowForPlayer(i, Textdraw1);
   }
   return 1;
}
Edit: There was already a reply ^^
There's no point of looping TextDrawHideForPlayer and TextDrawShowForPlayer when you can just use TextDrawShowForAll and TextDrawHideForAll, and you basically did exactly what I just did.
Reply
#5

Yes, I know, yours is better... And I was creating it while you gave a reply :P
Reply
#6

One Problem I had forgotten to mention, when it updates it shows random stuff.

Like just then it showed something that looked like a G
Before when I tried myself, it came up with some T.
But it doesnt show 4 of these letters or numbers.
It only shows 1.

Any possible reason for this?
Reply
#7

Usage:
pawn Код:
format(string1, sizeof(string1), "Team 1 Cash: %d", T1Cash);
format(string2, sizeof(string2), "Team 2 Cash: %d", T2Cash);
Reply
#8

Nice thankyou, Fast Reply.

Excellent Service, thankyou.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)