OnPlayerClickTextDraw
From SA-MP Wiki
(Difference between revisions)
Revision as of 18:52, 26 April 2015 MP2 (Talk | contribs) ← Previous diff |
Revision as of 21:12, 7 June 2016 Vince (Talk | contribs) Next diff → |
||
Line 10: | Line 10: | ||
{{Returns|Returning '''1/true''' in this callback will prevent it being called in other scripts. This should be used to signal that the textdraw on which they clicked was 'found' and no further processing is needed. You should return '''0/false''' if the textdraw on which they clicked wasn't found, just like in [[OnPlayerCommandText]].}} | {{Returns|Returning '''1/true''' in this callback will prevent it being called in other scripts. This should be used to signal that the textdraw on which they clicked was 'found' and no further processing is needed. You should return '''0/false''' if the textdraw on which they clicked wasn't found, just like in [[OnPlayerCommandText]].}} | ||
- | {{Note2|The clickable area is defined by [[TextDrawTextSize]]. The x and y parameters passed to that function must not be zero or negative.}} | + | {{Note2| |
+ | *The clickable area is defined by [[TextDrawTextSize]]. The x and y parameters passed to that function must not be zero or negative. | ||
+ | *Do not use [[CancelSelectTextDraw]] unconditionally within this callback. This results in an infinite loop.}} | ||
<pawn> | <pawn> |
Revision as of 21:12, 7 June 2016
Description:
This callback is called when a player clicks on a textdraw or cancels the select mode with the Escape key.
(playerid, Text:clickedid)
playerid | The ID of the player that clicked on the textdraw. |
clickedid | The ID of the clicked textdraw. INVALID_TEXT_DRAW if selection was cancelled. |
Return Values:
Returning 1/true in this callback will prevent it being called in other scripts. This should be used to signal that the textdraw on which they clicked was 'found' and no further processing is needed. You should return 0/false if the textdraw on which they clicked wasn't found, just like in OnPlayerCommandText.
Important |
|
new Text:gTextDraw; public OnGameModeInit() { gTextDraw = TextDrawCreate(10.000000, 141.000000, "MyTextDraw"); TextDrawTextSize(gTextDraw,60.000000, 20.000000); TextDrawAlignment(gTextDraw,0); TextDrawBackgroundColor(gTextDraw,0x000000ff); TextDrawFont(gTextDraw,1); TextDrawLetterSize(gTextDraw,0.250000, 1.000000); TextDrawColor(gTextDraw,0xffffffff); TextDrawSetProportional(gTextDraw,1); TextDrawSetShadow(gTextDraw,1); TextDrawSetSelectable(gTextDraw, 1); return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys == KEY_SUBMISSION) { TextDrawShowForPlayer(playerid, gTextDraw); SelectTextDraw(playerid, 0xFF4040AA); } return 1; } public OnPlayerClickTextDraw(playerid, Text:clickedid) { if(clickedid == gTextDraw) { SendClientMessage(playerid, 0xFFFFFFAA, "You clicked on a textdraw."); CancelSelectTextDraw(playerid); } return 1; }
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- OnPlayerClickPlayerTextDraw: Called when a player clicks on a player-textdraw.
- OnPlayerClickPlayer: Called when a player click on another.