SA-MP Forums Archive
Textdraw logic help - 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)
+--- Thread: Textdraw logic help (/showthread.php?tid=577807)



Textdraw logic help - lukewid - 14.06.2015

Hello, I've got these 7 textdraw's.

What is the logic, of when I add one to the 6th line (last line), all the text moves up? (the direction of the arrow)

I've got this but it aint working
pawn Код:
function addLogLine(text[])
{
    new oldInfo[70];
    //
    for(new i = 6; i >= 0; i--)
    {
        if(i != 0)
        {
            format(oldInfo, 70, "%s", Logs[i-1]);
            TextDrawSetString(Logs[i-1], LogsInfo[i]);
            format(LogsInfo[i-1], 70, "%s", LogsInfo[i]);
        }
    }
   
    TextDrawSetString(Logs[6], text);
    format(LogsInfo[6], 70, "%s", text);
    return 1;
}



Re: Textdraw logic help - [XST]O_x - 14.06.2015

This should work, untested though.
Код:
#include <a_samp>

new tdStrings[ 7 ][ 64 ];

public OnFilterScriptInit()
{
	for(new i = 0; i < 7; i++)
	{
		format(tdStrings[i], 64, "-");
                TextDrawSetString(Logs[i], tdStrings[i]);
	}
	return 1;
}

addLogLine(text[])
{
	for(new i = 0; i < 6; i++)
	{
		format(tdStrings[i], 64, "%s", tdStrings[i+1]);
		TextDrawSetString(Logs[i], tdStrings[i]);
	}

	format(tdStrings[6], 64, "%s", text);
	TextDrawSetString(Logs[6], tdStrings[6]);

	return 1;
}



Re: Textdraw logic help - lukewid - 14.06.2015

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
This should work, untested though.
Код:
#include <a_samp>

new tdStrings[ 7 ][ 64 ];

public OnFilterScriptInit()
{
	for(new i = 0; i < 7; i++)
	{
		format(tdStrings[i], 64, "-");
                TextDrawSetString(Logs[i], tdStrings[i]);
	}
	return 1;
}

addLogLine(text[])
{
	for(new i = 0; i < 6; i++)
	{
		format(tdStrings[i], 64, "%s", tdStrings[i+1]);
		TextDrawSetString(Logs[i], tdStrings[i]);
	}

	format(tdStrings[6], 64, "%s", text);
	TextDrawSetString(Logs[6], tdStrings[6]);

	return 1;
}
But mine starts from bottom (index: 6) and goes to the top (index:0), or should I say, a descending order D:


Re: Textdraw logic help - [XST]O_x - 14.06.2015

Quote:
Originally Posted by lukewid
Посмотреть сообщение
But mine starts from bottom (index: 6) and goes to the top (index:0), or should I say, a descending order D:
It does not matter. Did you try the code? It should work.


Re: Textdraw logic help - lukewid - 14.06.2015

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
It does not matter. Did you try the code? It should work.
Well, yea, now that i swapped the order of it, it worked

Solution:
Original --- New one



Re: Textdraw logic help - bgedition - 14.06.2015

Dude try this:
Код:
addLogLine(text[])
{
	for(new i = 7; i => 1; i--)
	{
		format(tdStrings[i], 64, "%s", tdStrings[i+1]);
		TextDrawSetString(Logs[i], tdStrings[i]);
	}

	format(tdStrings[6], 64, "%s", text);
	TextDrawSetString(Logs[6], tdStrings[6]);

	return 1;
}
This is changing the counting from 1 to 6