How to make random messages using textdraws -
Dripac - 22.03.2012
Random Messages - Textdraws
First of all we have to define the following things: Add the codes anywhere at the top of your script
pawn Код:
forward RandomMessage(); // This is the forward for the timer
Then we have to define the textdraw
pawn Код:
new Text:randommsg; // This is to define the textdraw that we are going to use
Now we have to define all the messages which will show for the players
pawn Код:
new RandomMessages[][] =
{
"~y~Community Name: ~w~Your Text ~g~here.",
"~y~Community Name: ~w~Your Text ~r~here.",
"~y~Community Name: ~w~Your Text ~y~here.",
"~y~Community Name: ~w~Your Text ~b~here."
// You can define more messages, but make sure you have , everywhere, except at the last message
};
You can change it to colors you like, look here for the color names
https://sampwiki.blast.hk/wiki/Colors_List
------------------------------------------------------------------------
Now we have to add the timer, you can define for how long time a message will stay
Add the following codes under OnGameModeInit
pawn Код:
SetTimer("RandomMessage",8000,1); // 8000 is for 8 seconds, if you want 50 seconds use 50000
Now we have to add the textdraw, put this also under OnGameModeInit
pawn Код:
randommsg = TextDrawCreate(7.000000, 427.000000, "You don't need to add any text here");
TextDrawBackgroundColor(randommsg, 255);
TextDrawFont(randommsg, 1);
TextDrawLetterSize(randommsg, 0.379999, 1.499999);
TextDrawColor(randommsg, -1);
TextDrawSetOutline(randommsg, 1);
TextDrawSetProportional(randommsg, 1);
If you don't like this textdraw, you can make your own by using a editor
--------------------------------------------------
Now we have to make a public function for the timer, add this anywhere in your gamemode, for example i have it above OnGameModeInit
pawn Код:
public RandomMessage()
{
TextDrawSetString(randommsg, RandomMessages[random(sizeof(RandomMessages))]); // We need this to make the timer working
return 1;
}
Now to show the textdraw for the players add the following under OnPlayerSpawn
pawn Код:
TextDrawShowForPlayer(playerid, randommsg);
You can also add it under OnPlayerConnect
You can see an example how it will looks like on my ******* channel,
http://www.*******.com/user/sunsetcityrp
Thats it, hope i helped
Re: How to make random messages using textdraws -
AlTy - 22.03.2012
nice tutorial!
Re: How to make random messages using textdraws -
Reklez - 22.03.2012
good tutorial but theres mistakes on your code
pawn Код:
new RandomMessages[][] =
{
"~y~Community Name: ~w~Your Text ~g~here.",
"~y~Community Name: ~w~Your Text ~r~here.",
"~y~Community Name: ~w~Your Text ~y~here.",
"~y~Community Name: ~w~Your Text ~b~here."
] //<<<< will cause errors
should be
pawn Код:
new RandomMessages[][] =
{
"~y~Community Name: ~w~Your Text ~g~here.",
"~y~Community Name: ~w~Your Text ~r~here.",
"~y~Community Name: ~w~Your Text ~y~here.",
"~y~Community Name: ~w~Your Text ~b~here."
};
Re: How to make random messages using textdraws -
Dripac - 22.03.2012
Quote:
Originally Posted by Reklez
good tutorial but theres mistakes on your code
pawn Код:
new RandomMessages[][] = { "~y~Community Name: ~w~Your Text ~g~here.", "~y~Community Name: ~w~Your Text ~r~here.", "~y~Community Name: ~w~Your Text ~y~here.", "~y~Community Name: ~w~Your Text ~b~here." ] //<<<< will cause errors
should be
pawn Код:
new RandomMessages[][] = { "~y~Community Name: ~w~Your Text ~g~here.", "~y~Community Name: ~w~Your Text ~r~here.", "~y~Community Name: ~w~Your Text ~y~here.", "~y~Community Name: ~w~Your Text ~b~here." };
|
Thank you, fixed
Re: How to make random messages using textdraws -
Phatomz - 23.03.2012
ty,very helpful
Re: How to make random messages using textdraws -
Dripac - 23.03.2012
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
#if defined FILTERSCRIPT
new Text:randommsg;
new RandomMessages[][] =
{
"~y~Community Name: ~w~Your Text ~g~here.",
"~y~Community Name: ~w~Your Text ~r~here.",
"~y~Community Name: ~w~Your Text ~y~here.",
"~y~Community Name: ~w~Your Text ~b~here."
};
public OnFilterScriptInit()
{
SetTimer("RandomMessage",8000,1);
randommsg = TextDrawCreate(7.000000, 427.000000, "You don't need to add any text here");
TextDrawBackgroundColor(randommsg, 255);
TextDrawFont(randommsg, 1);
TextDrawLetterSize(randommsg, 0.379999, 1.499999);
TextDrawColor(randommsg, -1);
TextDrawSetOutline(randommsg, 1);
TextDrawSetProportional(randommsg, 1);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
forward RandomMessage();
public RandomMessage()
{
TextDrawSetString(randommsg, RandomMessages[random(sizeof(RandomMessages))]);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, randommsg);
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
Re: How to make random messages using textdraws -
$$inSane - 02.05.2012
nice tutorial
Re: How to make random messages using textdraws -
2KY - 02.05.2012
Decent tutorial, some things could be used to explain it a bit more, but nonetheless, it's good.
Re: How to make random messages using textdraws -
qazwsx - 21.07.2013
Thanks mane, your tutorial is very helped me for Newbie scripter like me
Re: How to make random messages using textdraws -
AroseKhanNiazi - 08.02.2014
Bro can u tell me how i add the random mesg on player death like when he dies it says clapped or you are fucked or bla bla bla
Re: How to make random messages using textdraws -
Aerotactics - 09.02.2014
So, it worked the first time I logged into the server, but after changing the messages and the font, it stopped working.
Re: How to make random messages using textdraws -
MBilal - 09.02.2014
Its Awesome man
Re: How to make random messages using textdraws -
AlonzoTorres - 09.02.2014
pawn Code:
TextDrawShowForPlayer(playerid, randommsg);
You might want to explain to the people who are viewing this tutorial how to loop through all of the connected players and that you also have to hide then show the textdraw again if you want the newly set string to show up. Otherwise an OK tutorial.
Re: How to make random messages using textdraws -
newbie scripter - 14.04.2014
Quote:
Originally Posted by qazwsx
Thanks mane, your tutorial is very helped me for Newbie scripter like me
|
0.o how did my name go there?