Jump to content

[ Tutorial ] SendClientMessage pe TextDraw!


khain.dev

Recommended Posts

Va salut, astazi o sa va arat o metoda care ar moderniza functia SendClientMessage.

Diferenta fata de SendClientMessage simplu? Acesta e pe TextDraw

Sa incepem!

/* avem nevoie de un textdraw simplu pt a arata jucatorului acest mesaj pe ecran nu in chat. */
new 
	Text:SCMT[ MAX_PLAYERS ]; // numele textraw-ului pe care il avem

/* mergem in OnPlayerConnect */

public OnPlayerConnect( playerid )
{
  /* textdraw-ul nostru, cu numele SCMT care a fost definit prin variabila globala la inceput */
  SCMT[playerid] = TextDrawCreate(36.000000, 144.000000, "_");
  TextDrawBackgroundColor(SCMT[playerid], 255);
  TextDrawFont(SCMT[playerid], 2);
  TextDrawLetterSize(SCMT[playerid], 0.250000, 1.099999);
  TextDrawColor(SCMT[playerid], -1);
  TextDrawSetOutline(SCMT[playerid], 0);
  TextDrawSetProportional(SCMT[playerid], 1);
  TextDrawSetShadow(SCMT[playerid], 1);
  TextDrawUseBox(SCMT[playerid], 1);
  TextDrawBoxColor(SCMT[playerid], 118);
  TextDrawTextSize(SCMT[playerid], 220.000000, 5.000000);
  return 1;
}

/* in orice loc al GM-ului */

stock SendTD(playerid, text[], time)
{
    TextDrawSetString(SCMT[playerid], text); // modifica textdraw-ul cu textul introdus in functia dvs.
    SetTimerEx("TimeHideForPlayer", time, 1, "i", playerid); // ascunde textdraw-ul cu textul dvs. dupa timpul introdus in functie
    return TextDrawShowForPlayer(playerid, SCMT[playerid]); // arata textdraw-ul cu textul din functia dvs.
}
forward TimeHideForPlayer(playerid);
public TimeHideForPlayer(playerid) TextDrawHideForPlayer(playerid, SCMT[playerid]);


/* exemplu cum poti folosi in gm aceasta functie */
CMD:test(playerid) {

  SendTD(playerid, " Testarea acestei functii", 500);
  return 1;
}

 

 

Edited by khain
  • Upvote 1
Link to comment
Share on other sites

  • 2 weeks later...
1 oră în urmă, IosifR a spus:

+1 arata bine :) dar nu mai diapare textul de pe ecran ce fac

Faci un timer sa il faca sa dispara dupa 3 secunde, de exemplu:

SetTimerEx("SCMT[playerid]", 3000, false, "i", playerid);

Pe care il adaugi in comanda, sub afisarea textdraw-ului.

  • Like 1

35012l1.png.aee1a3398b9bd9f8eec50574d2cd

Link to comment
Share on other sites

La 01.04.2021 la 22:29, kellerman21 a spus:

nu dispare textdraw-ul din cauza ca a gresit aici, in loc de playerid a pus 8, 


public TimeHideForPlayer(playerid) TextDrawHideForPlayer(playerid, SCMT[8]);

SCMT[8] = SCMT[playerid]

Mersi, am rezolvat. 

nici nu observasem ca am pus 8

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.