24.07.2014, 05:23
(
Last edited by Battlezone; 29/07/2014 at 11:19 AM.
)
This simple tutorial that will show you how to easily make a 3 lines Joins/Leaves Box .
Steps:
1-We create the necessary global Texts and Strings :
2-Then we create the textdraws under OnGameModeInit :
3-Once we created the textdraws, we can now use format to change the Message strings under each one of the above callbacks (you can use strins too, but since this tutorial is for beginners I prefer to use format here):
That's all, and of course you can extand your box and add more lines if you want!
Screenshot:
Steps:
1-We create the necessary global Texts and Strings :
pawn Code:
new Text:mbox; //the box
new Text:Message; //the messages textdraw
new MessageStr[170]; //string line 3
new MessageStrl2[170]; //string line 2
new MessageStrl3[170]; //string line 1
pawn Code:
public OnGameModeInit()
{
//box textdraw
mbox = TextDrawCreate(683.000000, 365.000000, "~n~~n~~n~");
TextDrawBackgroundColor( mbox, 255);
TextDrawFont(mbox, 1);
TextDrawLetterSize(mbox, 0.969999, 1.600000);
TextDrawColor(mbox, -1347440726);
TextDrawSetOutline(mbox, 0);
TextDrawSetProportional(mbox, 1);
TextDrawSetShadow(mbox, 1);
TextDrawUseBox(mbox, 1);
TextDrawBoxColor(mbox, 24);
TextDrawTextSize(mbox, 470.000000, 99.000000);
TextDrawShowForAll(mbox);
//strings textdraw
Message = TextDrawCreate(473.000000, 368.000000, "");
TextDrawBackgroundColor(Message, 255);
TextDrawFont(Message, 1);
TextDrawLetterSize(Message, 0.190000, 1.300001);
TextDrawColor(Message, -1);
TextDrawSetOutline(Message, 0);
TextDrawSetProportional(Message, 1);
TextDrawSetShadow(Message, 1);
TextDrawShowForAll(Message);
return 1;
}
pawn Code:
public OnPlayerConnect(playerid)
{
format(MessageStrl3, 170, MessageStrl2); // move the line 2 text to line 1
format(MessageStrl2, 170, MessageStr); // move the line 3 text to line 2
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name)); // getting the player name
format(MessageStr,sizeof MessageStr,"~>~~b~%s ~w~has ~g~connected.", name); //formatting line 3 text
new STR[510]; //creating a new string to merge the 3 strings into a one 3 lines string
format(STR, sizeof(STR), "%s~n~%s~n~%s", MessageStrl3, MessageStrl2, MessageStr); //formatting the newly created string
TextDrawSetString(Message, STR); //showing it on the screen
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
format(MessageStrl3, 170, MessageStrl2); // move the line 2 text to line 1
format(MessageStrl2, 170, MessageStr); // move the line 3 text to line 2
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name)); // getting the player name
switch(reason) //switching reasons
{
case 0: format(MessageStr,sizeof MessageStr,"~<~~b~%s ~w~has ~y~lost connection", name);
case 1: format(MessageStr,sizeof MessageStr,"~<~~b~%s ~w~has ~r~disconnected", name);
case 2: format(MessageStr,sizeof MessageStr,"~<~~b~%s ~w~was~y~ kicked/banned", name);
}
new STR[510]; //creating a new string to merge the 3 strings into a one 3 lines string
format(STR, sizeof(STR), "%s~n~%s~n~%s", MessageStrl3, MessageStrl2, MessageStr); //formatting the newly created string
TextDrawSetString(Message, STR); //showing it on the screen
Screenshot: