TextDraw problem
#1

hi,

im counting the deaths on my server:

pawn Код:
new DeathsCount;

public OnPlayerDeath(playerid, killerid, reason)
{

DeathsCount++;
if(DeathsCount == 30)
{
SetCheckpointForAll(cp1,681.3374,-463.3429,22.5705,2.0);
}
}
return 1;
After there are 30 people killed there appears a checkpoint on the map
But ive got a problem with my texdraw.
I want a textdraw that is somewhere on the screen all the time and that shows how many deaths there are already.
(So every player knows when the next cp will appear).

pawn Код:
new Text:DeathCounter;

//OnGameModeInit:

DeathCounter = TextDrawCreate(10.0, 130.0, "Victims so far: ~n~Needed for next bombsmuggle: 30");
TextDrawUseBox(DeathCounter, 0);
TextDrawColor(DeathCounter, 0x008040FF );
TextDrawSetOutline(DeathCounter, 1);
TextDrawAlignment(DeathCounter, 1);
TextDrawLetterSize(DeathCounter, 0.850, 2.000);

//OnPlayerSpawn:

    new newtext[41], DeathsCount;
    format(newtext, sizeof(newtext), "Victims so far: %s\nNeeded for next bombsmuggle: 30", DeathsCount);
    TextDrawSetString(DeathCounter, newtext);
    TextDrawShowForPlayer(playerid, DeathCounter);
I also dont know how to do a new line in a texdraw(tried it with ~n~ and \n)
The texdraw itself appears but it doesnt show any deaths.

regards.
Reply
#2

Give this a try
pawn Код:
new DeathsCount = 30;

public OnGameModeInit()
{
    DeathCounter = TextDrawCreate(10.0, 130.0, "Victims so far: ~n~Needed for next bombsmuggle: 30");
    TextDrawUseBox(DeathCounter, 0);
    TextDrawColor(DeathCounter, 0x008040FF );
    TextDrawSetOutline(DeathCounter, 1);
    TextDrawAlignment(DeathCounter, 1);
    TextDrawLetterSize(DeathCounter, 0.850, 2.000);
    return 1;
}

public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, DeathCounter);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    static
        killstr[52];
       
    DeathsCount--;
    format(killstr, 4, "Victims so far: ~n~Needed for next bombsmuggle:%d", DeathsCount);
    TextDrawSetString(DeathCounter, killstr);//set the string here
    if(DeathsCount == 0)
    {
        SetCheckpointForAll(cp1,681.3374,-463.3429,22.5705,2.0);
    }
    return 1;
}
That should be better.
Reply
#3

hi,
im so happy about ur answer
it looks pretty good but only 1 thing
After the first counted kill the writing: victims so far: (here doesnt appear nothing but at the beginning here should be a 0) disappears and only a single number on the screen counts the kills.
But the writing should also stay there and the counted victims shall appear with the writing.

thx alot for ur answer, itd be great if u could help me with this (now only small problem).

Reply
#4

I edited it so it shows it.
Reply
#5

pawn Код:
format(killstr, 4, "Victims so far: ~n~Needed for next bombsmuggle:%d", DeathsCount);
Change for:
pawn Код:
format(killstr, 52, "Victims so far: ~n~Needed for next bombsmuggle:%d", DeathsCount);
Reply
#6

everything works now as it should thx soo much

a noob question:

how to reset the counted kills. The needet victims back to 30?
Reply
#7

DeathsCount = 0;
Reply
#8

hi,
after the the counter reaches (victims needed) 0 i want that the code disappears, so i wrote:
TextDrawHideForAll(DeathCounter);

the next time i want to use it i show it again with TextDrawShowForAll(DeathCounter);
but first i have to reset it(cause it counted all the time so it is under zero -1,-2,-3 and so on)
how to reset the counter/texdraw?
With DeathsCount = 30 ?

pls help me.
Reply
#9

You will have to set it to 30, becouse that's the default variable size that iggy1 made it.

pawn Код:
DeathsCount = 30;
Reply
#10

ok thx

and after that i just can show the textdraw again with TextDrawShowForAll(DeathCounter); right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)