Switching Textdraws with Timer -
Dancsika - 08.05.2018
Hello there!
So I'd need some help because I don't know how to create a textdraws with timer.
I mean there would be 2 options textd1 and textd2. (These are the textdraws.)
And I need a timer what would delete textd1 and create textd2 then vice versa in every 3 mins.
Thank you in advance for your help.
Re: Switching Textdraws with Timer -
FaLLenGirL - 08.05.2018
Frist way: (
here the messages will not mix each others and can't be repeated more than 1 time at 3 minutes)
PHP код:
new
TEXT_STEP,
TD_AGAIN_X,
TD_AGAIN,
Text:your_TD[ MAX_PLAYERS ]
;
public OnGameModeInit( )
{
TD_AGAIN_X = SetTimer( "TDAgainX", 60 * 3, true );
return 1;
}
public OnPlayrSpawn( playerid )
{
TextDrawShowForPlayer( playerid, your_TD[ playerid ] );
return 1;
}
stock RandomTextDraw( )
{
foreach(new i: Player)
{
if( TEXT_STEP == 1 )
{
TextDrawSetString( your_TD[ i ], "Your first message here" );
}
if( TEXT_STEP == 0 )
{
TextDrawSetString( your_TD[ i ], "Your second message here" );
}
TextDrawShowForPlayer( playerid, your_TD[ i ] );
}
return 1;
}
function TDAgainX( )
{
TEXT_STEP = 1;
RandomTextDraw( );
KillTimer( TD_AGAIN_X );
TD_AGAIN = SetTimer( "TDAgain", 60 * 3, true );
}
function TDAgain( )
{
TEXT_STEP = 0;
RandomTextDraw( );
KillTimer( TD_AGAIN );
TD_AGAIN_X = SetTimer( "TDAgainX", 60 * 3, true );
}
Another way: (
here one message can be repeated more than 1 time at 3 minutes)
PHP код:
new Text:your_TD[ MAX_PLAYERS ];
new RandomTextdraw[ ][ ] =
{
"Your first message",
"Your second message"
};
public OnGameModeInit( )
{
SetTimer( "RandomTextDrawTimer", 60 * 3, 1 );
return 1;
}
public OnPlayrSpawn( playerid )
{
TextDrawShowForPlayer( playerid, your_TD[ playerid ] );
return 1;
}
function RandomTextDrawTimer( )
{
foreach(new i: Player)
{
TextDrawSetString( your_TD[ i ], RandomTextdraw[ random( sizeof( RandomTextdraw ) ) ] );
}
return 1;
}
I literally think that you will use the first way that i gave you here.
I don't think that you want messages to repeat. So use first. It is ofc your choice.
Re: Switching Textdraws with Timer -
TadePoleMG - 08.05.2018
nice
Re: Switching Textdraws with Timer -
Lokii - 08.05.2018
I guess you want random tips or messages??
PHP код:
#include <a_samp>
static Text:TD;
static timer;
static const RandM[][] =
{
"Message 1",
"Message 2",
"Message 3"
};
public OnFilterScriptInit()
{
TD = TextDrawCreate(315.0, 5.0, " ");
timer = SetTimer("RandMSG", 1000*60*3, true);
return 1;
}
public OnFilterScriptExit()
{
TextDrawDestroy(TD);
KillTimer(timer);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, TD);
return 1;
}
forward RandMSG();
public RandMSG()
{
TextDrawSetString(TD, RandM[random(sizeof(RandM))]);
return 1;
}
Re: Switching Textdraws with Timer -
ItsRobinson - 08.05.2018
I'm not sure why FallenGirl made such a complicated snippet
You could simply:
PHP код:
new Text:textdraw[MAX_PLAYERS];
forward TextDrawDisplay(playerid, step);
public TextDrawDisplay(playerid, step)
{
new nextstep = step;
TextDrawDestroy(textdraw[playerid]);
if(step == 2)
{
SendClientMessage(playerid, -1, "That's the last of the textdraws");
return 1;
}
else if(step == 0)
{
textdraw[playerid] = TextDrawCreate(240.0,580.0,"Welcome to my SA-MP server");
}
else if(step == 1)
{
textdraw[playerid] = TextDrawCreate(240.0,580.0,"I hope you enjoy your stay");
}
nextstep++;
SetTimerEx("TextDrawDisplay", 1000, false, "ii", playerid, nextstep);
}
If you're having many textdraws, just make it a switch rather than an else if, else if, etc...
(Should work in theory, not tested :P)
Re: Switching Textdraws with Timer -
CrystalGamer - 08.05.2018
Quote:
Originally Posted by TadePoleMG
nice 
|
dude, this is scripting help section here all helps each other their is no need to say "nice

" because here in scripting help all do well r u gonna say to all nice huh.
Re: Switching Textdraws with Timer -
Dancsika - 08.05.2018
Ohh thank you so much guys. You helped me a lot

Nah i dont want random messages. I've already created some pop-up textdraws. I just want to make them to appier and disappier in a certain time. Just didnt know how to make it.