Clickable textdraw -
Face9000 - 26.12.2013
Hello, i just made a clickable textdraw but seems to not work.
Here is:
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?
Re: Clickable textdraw -
Face9000 - 26.12.2013
Bump.
Re: Clickable textdraw -
ikey07 - 26.12.2013
Try to replace if(_:clickedid != INVALID_TEXT_DRAW) with if(clickedid != INVALID_TEXT_DRAW)
Re: Clickable textdraw -
Face9000 - 26.12.2013
Tag mismatch.
Re: Clickable textdraw -
ikey07 - 26.12.2013
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;
}
Re: Clickable textdraw -
Face9000 - 26.12.2013
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;
}
Re: Clickable textdraw -
ikey07 - 26.12.2013
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
Re: Clickable textdraw -
Face9000 - 26.12.2013
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.
Re: Clickable textdraw -
Face9000 - 26.12.2013
Nothing, same problem. I can't select textdraws.
Re: Clickable textdraw -
HardRock - 26.12.2013
Show me your Textdraw code.