Clickable textdraw
#1

Hello, i just made a clickable textdraw but seems to not work.

Here is:

pawn Код:
new Text:ShopTxd1;
pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(_:clickedid != INVALID_TEXT_DRAW)
{
if(clickedid == ShopTxd1)
{
SendClientMessage(playerid,COLOR_GREY,"You clicked textdraw 1");
}
CancelSelectTextDraw(playerid);
TextDrawHideForPlayer(playerid, ShopTxd1);
}
return 1;
}
OnGameModeInit

pawn Код:
TextDrawSetSelectable(ShopTxd1, true);
And this is where i make show the ShopTxd1:

pawn Код:
stock Shop(playerid)
{
     if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using the shop.");
     if(pInfo[playerid][Jailed] == 1) return SCM(playerid,0xFF0000FF,"You can't use the shop in jail.");
     if(GetPVarInt(playerid, "spawned") == 0) return SCM(playerid, COLOR_LIGHTBLUE, "Please spawn before doing any action.");
     if(pAlive[playerid] == 0) return SCM(playerid, COLOR_LIGHTBLUE, "You can't use the shop if you are dead.");
     if(EnemyNear(playerid)) return SendClientMessage(playerid, red, "** You can't use the shop if enemies are near!");
     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
     {
     SCM(playerid,red,"You can't access the shop if you are in a vehicle.");
     return 1;
     }
    TextDrawShowForPlayer(playerid, ShopTxd1);
    SelectTextDraw(playerid, 0xA3B4C5FF);
     return 1;
}
This stock is called when you enter a checkpoint.

The problem is: The textdraw are showing but i can't click on them. Also the textdraw doesnt dissapear if i press ESC. What i did wrong?
Reply
#2

Bump.
Reply
#3

Try to replace if(_:clickedid != INVALID_TEXT_DRAW) with if(clickedid != INVALID_TEXT_DRAW)
Reply
#4

Tag mismatch.
Reply
#5

Humm,

this is the method I use

pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == Text:INVALID_TEXT_DRAW)
    {
        TextDrawHideForPlayer(playerid, ShopTxd1);
    }
    else if(clickedid == ShopTxd1)
    {
        SendClientMessage(playerid,COLOR_GREY,"You clicked textdraw named ShopTxd1");
    }
    return 1;
}
Reply
#6

What if i have multiple textdraws like:

ShopTxd1
ShopTxd2
ShopTxd3

and so on?

Code will be like this?

pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == Text:INVALID_TEXT_DRAW)
    {
        TextDrawHideForPlayer(playerid, ShopTxd1);
        TextDrawHideForPlayer(playerid, ShopTxd2);
    }
    else if(clickedid == ShopTxd1)
    {
        SendClientMessage(playerid,COLOR_GREY,"You clicked textdraw named ShopTxd1");
    }
    else if(clickedid == ShopTxd2)
    {
        SendClientMessage(playerid,COLOR_GREY,"You clicked textdraw named ShopTxd2");
    }
    return 1;
}
Reply
#7

Use array

new ShopTxd[Number of shop txds];


pawn Код:
new ShopTxd[10];
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == Text:INVALID_TEXT_DRAW)
    {
        for(new i; i < sizeof(ShopTxd); i++)
        {
            TextDrawHideForPlayer(playerid, ShopTxd[i]);
        }
    }
    for(new i; i < sizeof(ShopTxd); i++)
    {
        if(clickedid == ShopTxd[i])
        {
            SendClientMessage(playerid,COLOR_GREY,"You clicked textdraw named ShopTxd");
            return 1;
        }
    }
    return 1;
}
Tho it really depends on what effect you want when player click on the TDs
Reply
#8

Well, i made an ingame shop, where you can buy weapons just selecting the textdraw. (One txd per weapon), i'll test the first code you gave me.
Reply
#9

Nothing, same problem. I can't select textdraws.
Reply
#10

Show me your Textdraw code.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)