SA-MP Forums Archive
Clickable Textdraw 'hitbox' not exactly working. - 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: Clickable Textdraw 'hitbox' not exactly working. (/showthread.php?tid=543063)



Clickable Textdraw 'hitbox' not exactly working. - Kyance - 24.10.2014

It's my first time I try something with the clickable textdraws, but the "hitbox" seems to be messing up.
Like, the light(bright over hover) isn't working as it should, and it gets super-buggy on the 2nd spawn;
[ame]http://www.youtube.com/watch?v=Fbjh0h36Rh4[/ame]

The code;
pawn Код:
//OnPlayerConnect
SelectionBox1[ playerid ] = TextDrawCreate(220.000000, 143.000000, "~r~Warfare~n~~n~~n~_");
        TextDrawAlignment(SelectionBox1[ playerid ], 2);
        TextDrawBackgroundColor(SelectionBox1[ playerid ], 255);
        TextDrawFont(SelectionBox1[ playerid ], 2);
        TextDrawLetterSize(SelectionBox1[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionBox1[ playerid ], -1);
        TextDrawSetOutline(SelectionBox1[ playerid ], 0);
        TextDrawSetProportional(SelectionBox1[ playerid ], 1);
        TextDrawSetShadow(SelectionBox1[ playerid ], 1);
        TextDrawUseBox(SelectionBox1[ playerid ], 1);
        TextDrawBoxColor(SelectionBox1[ playerid ], 117);
        TextDrawTextSize(SelectionBox1[ playerid ], 153, 220);
       
        SelectionBox2[ playerid ] = TextDrawCreate(420.000000, 143.000000, "~g~Stuntzone~n~~n~~n~_");
        TextDrawAlignment(SelectionBox2[ playerid ], 2);
        TextDrawBackgroundColor(SelectionBox2[ playerid ], 255);
        TextDrawFont(SelectionBox2[ playerid ], 2);
        TextDrawLetterSize(SelectionBox2[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionBox2[ playerid ], -1);
        TextDrawSetOutline(SelectionBox2[ playerid ], 0);
        TextDrawSetProportional(SelectionBox2[ playerid ], 1);
        TextDrawSetShadow(SelectionBox2[ playerid ], 1);
        TextDrawUseBox(SelectionBox2[ playerid ], 1);
        TextDrawBoxColor(SelectionBox2[ playerid ], 117);
        TextDrawTextSize(SelectionBox2[ playerid ], 153, 420);
   
        SelectionWar[ playerid ] = TextDrawCreate(220.000000, 143.000000, "~n~~n~Players: 0/150");
        TextDrawAlignment(SelectionWar[ playerid ], 2);
        TextDrawBackgroundColor(SelectionWar[ playerid ], 255);
        TextDrawFont(SelectionWar[ playerid ], 2);
        TextDrawLetterSize(SelectionWar[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionWar[ playerid ], -1);
        TextDrawSetOutline(SelectionWar[ playerid ], 0);
        TextDrawSetProportional(SelectionWar[ playerid ], 1);
        TextDrawSetShadow(SelectionWar[ playerid ], 1);

        SelectionStunt[ playerid ] = TextDrawCreate(420.000000, 143.000000, "~n~~n~Players: 0/150");
        TextDrawAlignment(SelectionStunt[ playerid ], 2);
        TextDrawBackgroundColor(SelectionStunt[ playerid ], 255);
        TextDrawFont(SelectionStunt[ playerid ], 2);
        TextDrawLetterSize(SelectionStunt[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionStunt[ playerid ], -1);
        TextDrawSetOutline(SelectionStunt[ playerid ], 0);
        TextDrawSetProportional(SelectionStunt[ playerid ], 1);
        TextDrawSetShadow(SelectionStunt[ playerid ], 1);
       
        TextDrawSetSelectable(SelectionBox1[ playerid ], false);
        TextDrawSetSelectable(SelectionBox2[ playerid ], false);
        TextDrawSetSelectable(SelectionWar[ playerid ], true);
        TextDrawSetSelectable(SelectionStunt[ playerid ], true);
//OnPlayerRequestSpawn
TextDrawShowForPlayer(playerid, SelectionBox[ playerid ]), TextDrawShowForPlayer(playerid, SelectionWar[ playerid ]), TextDrawShowForPlayer(playerid, SelectionStunt[ playerid ]);
        SelectTextDraw(playerid, 0xA3B4C5FF);
        return 0;
//OnPlayerClickTextDraw
if(clickedid == SelectionWar[ playerid ])
    {
        HasChosenSpawn{ playerid } = true, SpawnType[ playerid ] = SPAWNMODE_DEFAULT;
        SendClientMessage(playerid, COLOR_RADIO, "* You've chosen the 'warfare'(aka 'default') spawn type - to change it again, press 'F4'.");
    }
    else if(clickedid == SelectionStunt[ playerid ])
    {
        HasChosenSpawn{ playerid } = true, SpawnType[ playerid ] = SPAWNMODE_STUNT;
        SendClientMessage(playerid, COLOR_RADIO, "* You've chosen the 'stunt' spawn type - to change it again, press 'F4'.");
    }
    TextDrawHideForPlayer(playerid, SelectionBox[ playerid ]), TextDrawHideForPlayer(playerid, SelectionStunt[ playerid ]), TextDrawHideForPlayer(playerid, SelectionWar[ playerid ]);
    CancelSelectTextDraw(playerid);
Do I have to set special/other coordinates for the 'hitbox'( click zone, call it w.e you want D: )


Re: Clickable Textdraw 'hitbox' not exactly working. - Sawalha - 24.10.2014

didn't understand the hitbox part, what's it?
Anyways, if it dosen't hover on the clickable textdraws you have set, Use TextDrawTextSize for them so you can create a hidden "box" which when you hover on it , the text will change it's color (SelectTextDraw color)
set a TextDrawTextSize of each one of them as their size


Re: Clickable Textdraw 'hitbox' not exactly working. - Kyance - 24.10.2014

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
didn't understand the hitbox part, what's it?
Anyways, if it dosen't hover on the clickable textdraws you have set, Use TextDrawTextSize for them so you can create a hidden "box" which when you hover on it , the text will change it's color (SelectTextDraw color)
set a TextDrawTextSize of each one of them as their size
There's TextDrawTextSize on the SelectionBox .. I guess I should 'drop' it on the real Selection..
Anyways, here's a video.. and It shows another bug I just found out about ;_;

[ame]http://www.youtube.com/watch?v=Fbjh0h36Rh4[/ame]


Re: Clickable Textdraw 'hitbox' not exactly working. - zaibaslr2 - 24.10.2014

Actually these two clickable textraws doesn't have TextDrawTextSize as they should.


Re: Clickable Textdraw 'hitbox' not exactly working. - Kyance - 24.10.2014

Quote:
Originally Posted by zaibaslr2
Посмотреть сообщение
Actually these two clickable textraws doesn't have TextDrawTextSize as they should.
I tried setting up the "TextDrawTextSize", but then It got messed up, example:
(before change)
Teleport Menu
Selection1
Selection2
(after change)
Te
lep Select
ort Ion1Me
NuSelection2


Re: Clickable Textdraw 'hitbox' not exactly working. - Tamer - 24.10.2014

As far as I know this is a SA-MP related bug.


Re: Clickable Textdraw 'hitbox' not exactly working. - gurmani11 - 24.10.2014

i think its alignment problem you have set it centered


Re: Clickable Textdraw 'hitbox' not exactly working. - Kyance - 24.10.2014

Quote:
Originally Posted by gurmani11
Посмотреть сообщение
i think its alignment problem you have set it centered
Yeah, read the wiki.
But I'm still confused about the coordinates.

(i changed some stuff, so i will post the coords here & edit the post)
pawn Код:
SelectionBox1[ playerid ] = TextDrawCreate(220.000000, 143.000000, "~r~Warfare~n~~n~~n~_");
        TextDrawAlignment(SelectionBox1[ playerid ], 2);
        TextDrawBackgroundColor(SelectionBox1[ playerid ], 255);
        TextDrawFont(SelectionBox1[ playerid ], 2);
        TextDrawLetterSize(SelectionBox1[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionBox1[ playerid ], -1);
        TextDrawSetOutline(SelectionBox1[ playerid ], 0);
        TextDrawSetProportional(SelectionBox1[ playerid ], 1);
        TextDrawSetShadow(SelectionBox1[ playerid ], 1);
        TextDrawUseBox(SelectionBox1[ playerid ], 1);
        TextDrawBoxColor(SelectionBox1[ playerid ], 117);
        TextDrawTextSize(SelectionBox1[ playerid ], 153, 220);
       
        SelectionBox2[ playerid ] = TextDrawCreate(420.000000, 143.000000, "~g~Stuntzone~n~~n~~n~_");
        TextDrawAlignment(SelectionBox2[ playerid ], 2);
        TextDrawBackgroundColor(SelectionBox2[ playerid ], 255);
        TextDrawFont(SelectionBox2[ playerid ], 2);
        TextDrawLetterSize(SelectionBox2[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionBox2[ playerid ], -1);
        TextDrawSetOutline(SelectionBox2[ playerid ], 0);
        TextDrawSetProportional(SelectionBox2[ playerid ], 1);
        TextDrawSetShadow(SelectionBox2[ playerid ], 1);
        TextDrawUseBox(SelectionBox2[ playerid ], 1);
        TextDrawBoxColor(SelectionBox2[ playerid ], 117);
        TextDrawTextSize(SelectionBox2[ playerid ], 153, 420);
   
        SelectionWar[ playerid ] = TextDrawCreate(220.000000, 143.000000, "~n~~n~Players: 0/150");
        TextDrawAlignment(SelectionWar[ playerid ], 2);
        TextDrawBackgroundColor(SelectionWar[ playerid ], 255);
        TextDrawFont(SelectionWar[ playerid ], 2);
        TextDrawLetterSize(SelectionWar[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionWar[ playerid ], -1);
        TextDrawSetOutline(SelectionWar[ playerid ], 0);
        TextDrawSetProportional(SelectionWar[ playerid ], 1);
        TextDrawSetShadow(SelectionWar[ playerid ], 1);

        SelectionStunt[ playerid ] = TextDrawCreate(420.000000, 143.000000, "~n~~n~Players: 0/150");
        TextDrawAlignment(SelectionStunt[ playerid ], 2);
        TextDrawBackgroundColor(SelectionStunt[ playerid ], 255);
        TextDrawFont(SelectionStunt[ playerid ], 2);
        TextDrawLetterSize(SelectionStunt[ playerid ], 0.199999,1.100000);
        TextDrawColor(SelectionStunt[ playerid ], -1);
        TextDrawSetOutline(SelectionStunt[ playerid ], 0);
        TextDrawSetProportional(SelectionStunt[ playerid ], 1);
        TextDrawSetShadow(SelectionStunt[ playerid ], 1);
I tried setting the coords the boxes have, but added/removed the new line (~n~) stuff.. still didn't work.

All I get is the "stunt spawn" now :l


Re: Clickable Textdraw 'hitbox' not exactly working. - Pottus - 24.10.2014

Your TextDrawTextSize() is incorrect TextDrawTextSize(SelectionBox2[ playerid ], 153, 420); that is a huge clickable area....

Also you really need to use Player textdraws.


Re: Clickable Textdraw 'hitbox' not exactly working. - Kyance - 24.10.2014

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Your TextDrawTextSize() is incorrect TextDrawTextSize(SelectionBox2[ playerid ], 153, 420); that is a huge clickable area....

Also you really need to use Player textdraws.
Yeah, I don't really understand the click positions, are they automatically set to the textdraw position and then its like a "range check"? d:

And, why so?