PDA

View Full Version : GameTextForPlayer


danish007
13/02/2015, 06:10 PM
Hello how can i make if i've send one gametext to player and if i send another again the first one should go down and new one should be on first line.
i mean to make 2 lines. old msg and new msg line any example?

example: first msg: "Hello World" if i send only one. it will be like this and if i send again an other gametextmsg
it should be

"Holla World"
"Hello World"

ZaBraNjeNi
13/02/2015, 07:36 PM
Hmmm, see here: (You need just to change something (coordinates))
- http://forum.sa-mp.com/showthread.php?t=425372 (Include)
- http://forum.sa-mp.com/showthread.php?t=425372 (FS)
- http://forum.sa-mp.com/showthread.php?t=425372 (FS)

danish007
13/02/2015, 07:50 PM
but i want to make it with GameTextForPlayer(playerid, "something", 5000, 3);

Nero_3D
13/02/2015, 11:30 PM
Well you need to save the text into a variable and store the time of each line

And if you want to leave the natives as they are than you need to hook them

danish007
14/02/2015, 06:27 AM
please tell me how? im not much expert in pawn!

danish007
14/02/2015, 09:10 AM
please? anyone?

ReshiramZekrom
14/02/2015, 09:48 AM
I don't know if I have understand what you mean.. But I think that you wanna do something like this:


//create a new variable such us:
new gamertexted[MAX_PLAYERS];

//then in the command
if(gamertexted[playerid] == 0) GameTextForPlayer(playerid,"Hello World",5000,3),gamertexted[playerid]++;
else GameTextForPlayer(playerid,"HollaWorld\nHello World",5000,3);

//then in connect or in disconnect or in both you should put:
gamertexted[playerid] = 0;

HY
14/02/2015, 09:50 AM
Use ~n~ to make a new line:
Example:

CMD:text(playerid, params[])
{
GameTextForPlayer(playerid, "First Line~n~Second Line~n~Third Line~n~Fourth Line", 5000, 5);
return 1;
}

danish007
14/02/2015, 12:18 PM
i dont want like this!
im asking about making new function or stock!
stock GameTextForPlayerEx(playerid, msg[], time, type)
{
//code here!
}
but the code i want!

danish007
14/02/2015, 12:57 PM
yea, its my code! won't make new line if i send 2 messages!

command!
COMMAND:test(playerid, params[])
{
SendGameText(playerid, "~p~Pink", 3000, 3);
SendGameText(playerid, "~b~Blue", 3000, 3);
return 1;
}

stock SendGameText(playerid, message[], time, type)
{
new string[512];
format(string, sizeof(string),"%s %s\n", string, message);
GameTextForPlayer(playerid, string, time, type);
}

HY
14/02/2015, 01:02 PM
Can't make 2 texts...

You can use, how I said you with ~n~, new line.
Or, use Textdraws. Set a timer to show, and set a timer to hide.

Nero_3D
14/02/2015, 05:07 PM
You need to store the text globally like that and add up the string like you want it

new
gGameTextData[MAX_PLAYERS][128]
;
stock SendGameText(playerid, string[], time, style) {
format(gGameTextData[playerid], sizeof gGameTextData[], "%s~n~%s", string, gGameTextData[playerid]);

GameTextForPlayer(playerid, gGameTextData[playerid], time, style);
}
Now you need to think about the part where you set the data to "empty" again (that should be after the text has vanished)

danish007
14/02/2015, 07:32 PM
Now im somehow using like this, but im still looking for some imporvements! if it can be more better and simple!

new GameTextData[MAX_PLAYERS][512];
new GameTextLine[MAX_PLAYERS];
stock SendGameText(playerid, string[], time, style)
{
if (style == 3 || style == 4 || style == 5)
{
if (GameTextLine[playerid] == 1)
{
format(GameTextData[playerid], sizeof GameTextData[], "%s~n~%s", string, GameTextData[playerid]);

GameTextLine[playerid] = 0;
SetTimerEx("GameTextTimer", time, 0, "d", playerid);

GameTextForPlayer(playerid, GameTextData[playerid], time, style);
}
else
{
strcpy(GameTextData[playerid], string, sizeof GameTextData[]);

GameTextLine[playerid] = 1;
SetTimerEx("GameTextTimer", time, 0, "d", playerid);

GameTextForPlayer(playerid, string, time, style);
}
}
else
{
GameTextForPlayer(playerid, string, time, style);
}
}
forward GameTextTimer(playerid);

public GameTextTimer(playerid)
{
GameTextData[playerid] = " ";
}

Nero_3D
14/02/2015, 08:06 PM
If you clear the data right after it will never add up, you need to delay it by "time"

new GameTextData[MAX_PLAYERS][256];
new GameTextTimer[MAX_PLAYERS] = {-1, ...};

stock SendGameText(playerid, string[], time, style)
{
if(style == 3 || style == 4 || style == 5)
{
if(GameTextData[playerid][0])
{
format(GameTextData[playerid], sizeof GameTextData[], "%s~n~%s", string, GameTextData[playerid]);

GameTextForPlayer(playerid, GameTextData[playerid], time, style);

KillTimer(GameTextTimer[playerid]);
GameTextTimer[playerid] = SetTimerEx("GameTextTimer", time, false, "i", playerid);
return ;
}
else
{
strcpy(GameTextData[playerid], string, sizeof GameTextData[]);

GameTextTimer[playerid] = SetTimerEx("GameTextTimer", time, false, "i", playerid);
}
}
GameTextForPlayer(playerid, string, time, style);
}
forward GameTextTimer(playerid);
public GameTextTimer(playerid)
{
GameTextData[playerid][0] = EOS;
GameTextTimer[playerid] = -1;
}
That code will add up all the messages and they will disappear together after the last time has passed

danish007
14/02/2015, 08:49 PM
ahh right! but it keep making lines if i send message again and again, i want to make MAX two lines!

Nero_3D
14/02/2015, 11:14 PM
Than reset the variable right after the second message

stock SendGameText(playerid, string[], time, style)
{
if(style == 3 || style == 4 || style == 5)
{
if(GameTextData[playerid][0])
{
format(GameTextData[playerid], sizeof GameTextData[], "%s~n~%s", string, GameTextData[playerid]);

GameTextForPlayer(playerid, GameTextData[playerid], time, style);

KillTimer(GameTextTimer[playerid]);
GameTextTimer(playerid);
return ;
}
else
{
strcpy(GameTextData[playerid], string, sizeof GameTextData[]);

GameTextTimer[playerid] = SetTimerEx("GameTextTimer", time, false, "i", playerid);
}
}
GameTextForPlayer(playerid, string, time, style);
}

danish007
15/02/2015, 09:06 AM
yea it works thanks!