SA-MP Forums Archive
TextDraw problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: TextDraw problem (/showthread.php?tid=197598)



TextDraw problem - BlackWolf120 - 09.12.2010

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.


Re: TextDraw problem - iggy1 - 09.12.2010

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.


Re: TextDraw problem - BlackWolf120 - 09.12.2010

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).




Re: TextDraw problem - iggy1 - 09.12.2010

I edited it so it shows it.


Re: TextDraw problem - CyNiC - 09.12.2010

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);



Re: TextDraw problem - BlackWolf120 - 09.12.2010

everything works now as it should thx soo much

a noob question:

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


Re: TextDraw problem - admantis - 09.12.2010

DeathsCount = 0;


Re: TextDraw problem - BlackWolf120 - 12.12.2010

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.


Re: TextDraw problem - The_Moddler - 12.12.2010

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

pawn Код:
DeathsCount = 30;



Re: TextDraw problem - BlackWolf120 - 12.12.2010

ok thx

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