[Include] dth_tdselect.inc
#1

dth_tdselect.inc v0.1
This include allows you to better organize your code, if you use a lot of selectable TextDraws.
Contents : 2 functions

dth_TextDrawSetSelectable :
  • Textdraw ID
  • Boolean selection
  • Name of the called function
Return : This function does not return a specific value.

Use :
pawn Код:
#include <a_samp>
#include <dth_tdselect>

new
    Text:Bouton;
   
public OnGameModeInit()
{
    Bouton = TextDrawCreate(545.0, 410.0, "Button Yolooo");
    TextDrawTextSize(Bouton, 635.000000, 30.000000);
    TextDrawBackgroundColor(Bouton, -1);
    TextDrawColor(Bouton, 0xFF0000FF);
    TextDrawSetShadow(Bouton, 5);
    TextDrawSetOutline(Bouton, 1);
    TextDrawFont(Bouton, 1);
    TextDrawSetProportional(Bouton, 1);
    TextDrawLetterSize(Bouton, 0.340001, 2.999999);
    dth_TextDrawSetSelectable(Bouton, true, Test1); // <--------

    return 1;
}
dth_PlayerTextDrawSetSelectable :
  • Player ID
  • Textdraw ID
  • Boolean selection
  • Name of the called function
Return : This function does not return a specific value.

Use :
pawn Код:
#include <a_samp>
#include <dth_tdselect>

new
    PlayerText:Bouton;
   
public OnPlayerConnect(playerid)
{
    Bouton2 = CreatePlayerTextDraw(playerid, 557.0, 360.0, "Button aha");
    PlayerTextDrawTextSize(playerid, Bouton2, 637.0, 30.0);
    PlayerTextDrawBackgroundColor(playerid, Bouton2, -1);
    PlayerTextDrawColor(playerid, Bouton2, 0x228301FF);
    PlayerTextDrawSetShadow(playerid, Bouton2, 5);
    PlayerTextDrawSetOutline(playerid, Bouton2, 1);
    PlayerTextDrawFont(playerid, Bouton2, 1);
    PlayerTextDrawSetProportional(playerid, Bouton2, 1);
    PlayerTextDrawLetterSize(playerid, Bouton2, 0.340001, 2.999999);
    dth_PlayerTextDrawSetSelectable(playerid, Bouton2, true, Test2); // <--------

    return 1;
}
Calling the function works as zcmd / easydialog.
I show you an example, you'll understand :

pawn Код:
#include <a_samp>
#include <dth_tdselect>

main(){}

new
    Text:Bouton1,
    PlayerText:Bouton2;

public OnGameModeInit()
{
    Bouton1 = TextDrawCreate(545.0, 410.0, "Button 1");
    TextDrawTextSize(Bouton1, 635.000000, 30.000000);
    TextDrawBackgroundColor(Bouton1, -1);
    TextDrawColor(Bouton1, 0xFF0000FF);
    TextDrawSetShadow(Bouton1, 5);
    TextDrawSetOutline(Bouton1, 1);
    TextDrawFont(Bouton1, 1);
    TextDrawSetProportional(Bouton1, 1);
    TextDrawLetterSize(Bouton1, 0.340001, 2.999999);
    dth_TextDrawSetSelectable(Bouton1, true, Test1);

    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/select", true) == 0)
        return SelectTextDraw(playerid, 0xFF4040AA);
       
    if(strcmp(cmdtext, "/deselect", true) == 0)
        return CancelSelectTextDraw(playerid);

    return SendClientMessage(playerid, -1, "Unknown command.");
}

public OnPlayerConnect(playerid)
{
    Bouton2 = CreatePlayerTextDraw(playerid, 557.0, 360.0, "Button 2");
    PlayerTextDrawTextSize(playerid, Bouton2, 637.0, 30.0);
    PlayerTextDrawBackgroundColor(playerid, Bouton2, -1);
    PlayerTextDrawColor(playerid, Bouton2, 0x228301FF);
    PlayerTextDrawSetShadow(playerid, Bouton2, 5);
    PlayerTextDrawSetOutline(playerid, Bouton2, 1);
    PlayerTextDrawFont(playerid, Bouton2, 1);
    PlayerTextDrawSetProportional(playerid, Bouton2, 1);
    PlayerTextDrawLetterSize(playerid, Bouton2, 0.340001, 2.999999);
    dth_PlayerTextDrawSetSelectable(playerid, Bouton2, true, Test2);   

    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Bouton1);
    PlayerTextDrawShow(playerid, Bouton2);
    return 1;
}

TDS:Test1(playerid)
{
    return SendClientMessage(playerid, -1, "You click on the button 1");
}

PTDS:Test2(playerid)
{
    return SendClientMessage(playerid, -1, "You click on the button 2");
}
WARNING : You can't use OnPlayerClickTextDraw and OnPlayerClickPlayerTextDraw witch that include.

I'm thinking actually if I add it a callback(s).
In any case it is complete, easy to use in my opinion.
Download :



Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)