SA-MP Forums Archive
OnPlayerClickTextDraw malfunctioning - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerClickTextDraw malfunctioning (/showthread.php?tid=367087)



OnPlayerClickTextDraw malfunctioning - Sinner - 08.08.2012

I'm trying to create 2 buttons with textdraws but it seems like I'm unable to click them. I got everything set up like it's supposed to but somehow I can't seem to click them.

I created my textdraws correctly;

pawn Код:
// On top of script
    enum some_enum {
        Text:TD_gametype,
        Text:TD_leftbutton,
        Text:TD_rightbutton,
        Text:TD_bottomline,
        Text:TD_topline,
        Text:TD_leftline,
        Text:TD_rightline,
    };
    new GT[MAX_PLAYERS][some_enum];
   

    // Under ongamemodeinit (this works)
    GT[playerid][TD_leftbutton] = TextDrawCreate(204.000000, 365.000000, "<");
    TextDrawAlignment(GT[playerid][TD_leftbutton], 2);
    TextDrawBackgroundColor(GT[playerid][TD_leftbutton], 255);
    TextDrawFont(GT[playerid][TD_leftbutton], 1);
    TextDrawLetterSize(GT[playerid][TD_leftbutton], 0.469999, 3.699998);
    TextDrawColor(GT[playerid][TD_leftbutton], -1);
    TextDrawSetOutline(GT[playerid][TD_leftbutton], 1);
    TextDrawSetProportional(GT[playerid][TD_leftbutton], 1);
    TextDrawUseBox(GT[playerid][TD_leftbutton], 1);
    TextDrawBoxColor(GT[playerid][TD_leftbutton], 255);
    TextDrawTextSize(GT[playerid][TD_leftbutton], 0.000000, 34.000000);
    TextDrawSetSelectable(GT[playerid][TD_leftbutton], 1);

    GT[playerid][TD_rightbutton] = TextDrawCreate(434.000000, 365.000000, ">");
    TextDrawAlignment(GT[playerid][TD_rightbutton], 2);
    TextDrawBackgroundColor(GT[playerid][TD_rightbutton], 255);
    TextDrawFont(GT[playerid][TD_rightbutton], 1);
    TextDrawLetterSize(GT[playerid][TD_rightbutton], 0.469999, 3.699998);
    TextDrawColor(GT[playerid][TD_rightbutton], -1);
    TextDrawSetOutline(GT[playerid][TD_rightbutton], 1);
    TextDrawSetProportional(GT[playerid][TD_rightbutton], 1);
    TextDrawUseBox(GT[playerid][TD_rightbutton], 1);
    TextDrawBoxColor(GT[playerid][TD_rightbutton], 255);
    TextDrawTextSize(GT[playerid][TD_rightbutton], 0.000000, 34.000000);
    TextDrawSetSelectable(GT[playerid][TD_rightbutton], 1);
AS you can see I did set "TextDrawSetSelectable" to "1". I also enable "SelectTextDraw(playerid, color)" The following callback gets called when I press exit (so I assume thats working) but it won't work for either of my textdraws.

pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid) {
        // This DOES get called when I press exit (as it's supposed to)
        if(clickedid == GT[playerid][TD_leftbutton]) {
            // This isnt working
        }
        else if(clickedid == GT[playerid][TD_rightbutton]) {
            // this isnt working either
        }
    }
Could anyone see what I'm doing wrong?


Re: OnPlayerClickTextDraw malfunctioning - Dragony92 - 08.08.2012

https://sampwiki.blast.hk/wiki/SelectTextdraw
Everything else is fine, you just need to enable text draw selecting...


Re: OnPlayerClickTextDraw malfunctioning - Sinner - 08.08.2012

Quote:
Originally Posted by Dragony92
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SelectTextdraw
Everything else is fine, you just need to enable text draw selecting...
I did that

Quote:

I also enable "SelectTextDraw(playerid, color)" The following callback gets called when I press exit (so I assume thats working) but it won't work for either of my textdraws.




Re: OnPlayerClickTextDraw malfunctioning - Nicholas. - 08.08.2012

This problem is probably coming from your TextDrawTextSize. Try tweaking with the coordinates a little see what happens.

I tweaked with them a little bit for you.

pawn Код:
TextDrawTextSize(GT[playerid][TD_leftbutton], 260.000000, 365.000000);

TextDrawTextSize(GT[playerid][TD_rightbutton], 500.000000, 365.000000);



Re: OnPlayerClickTextDraw malfunctioning - Sinner - 08.08.2012

Quote:
Originally Posted by Nicholas.
Посмотреть сообщение
This problem is probably coming from your TextDrawTextSize. Try tweaking with the coordinates a little see what happens.

I tweaked with them a little bit for you.

pawn Код:
TextDrawTextSize(GT[playerid][TD_leftbutton], 260.000000, 365.000000);

TextDrawTextSize(GT[playerid][TD_rightbutton], 500.000000, 365.000000);
Worked like a charm, thank you so much.


Re: OnPlayerClickTextDraw malfunctioning - Nicholas. - 08.08.2012

Glad to help

It is like your TextSize X coordinate should be higher than your TextDraw X coordinate.


Re: OnPlayerClickTextDraw malfunctioning - Sinner - 09.08.2012

Quote:
Originally Posted by Nicholas.
Посмотреть сообщение
Glad to help

It is like your TextSize X coordinate should be higher than your TextDraw X coordinate.
Yup I found that my height coordinate was 0.00000 so obviously there was nothing to click.