OnPlayerClickPlayerTextDraw

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:16, 9 December 2016
OstGot (Talk | contribs)

← Previous diff
Revision as of 12:51, 9 August 2017
OstGot (Talk | contribs)

Next diff →
Line 9: Line 9:
{{Param|playertextid|The ID of the player-textdraw that the player selected.}} {{Param|playertextid|The ID of the player-textdraw that the player selected.}}
-{{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]].
 +* It is always called first in filterscripts so returning 1 there also blocks other scripts from seeing it.}}
{{Example}} {{Example}}

Revision as of 12:51, 9 August 2017



OnPlayerClickPlayerTextDraw was added in SA-MP 0.3e This callback was added in SA-MP 0.3e and will not work in earlier versions!


Description:

This callback is called when a player clicks on a player-textdraw. It is not called when player cancels the select mode (ESC) - however, OnPlayerClickTextDraw is.


Parameters:
(playerid, PlayerText:playertextid)
playeridThe ID of the player that selected a textdraw
playertextidThe ID of the player-textdraw that the player selected.


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.
  • It is always called first in filterscripts so returning 1 there also blocks other scripts from seeing it.


Example Usage:

new PlayerText:gPlayerTextDraw[MAX_PLAYERS];
 
public OnPlayerConnect(playerid)
{
    // Create the textdraw
    gPlayerTextDraw[playerid] = CreatePlayerTextDraw(playerid, 10.000000, 141.000000, "MyTextDraw");
    PlayerTextDrawTextSize(playerid, gPlayerTextDraw[playerid], 60.000000, 20.000000);
    PlayerTextDrawAlignment(playerid, gPlayerTextDraw[playerid],0);
    PlayerTextDrawBackgroundColor(playerid, gPlayerTextDraw[playerid],0x000000ff);
    PlayerTextDrawFont(playerid, gPlayerTextDraw[playerid], 1);
    PlayerTextDrawLetterSize(playerid, gPlayerTextDraw[playerid], 0.250000, 1.000000);
    PlayerTextDrawColor(playerid, gPlayerTextDraw[playerid], 0xffffffff);
    PlayerTextDrawSetProportional(playerid, gPlayerTextDraw[playerid], 1);
    PlayerTextDrawSetShadow(playerid, gPlayerTextDraw[playerid], 1);
 
    // Make it selectable
    PlayerTextDrawSetSelectable(playerid, gPlayerTextDraw[playerid], 1);  
 
    // Show it to the player
    PlayerTextDrawShow(playerid, gPlayerTextDraw[playerid]);
    return 1;
}
 
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SUBMISSION)
    {
        SelectTextDraw(playerid, 0xFF4040AA);
    }
    return 1;
}
 
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if(playertextid == gPlayerTextDraw[playerid])
    {
         SendClientMessage(playerid, 0xFFFFFFAA, "You clicked on a textdraw.");
         CancelSelectTextDraw(playerid);
    }
    return 1;
}
Image:32px-Circle-style-warning.png

Important
Note

When a player presses ESC to cancel selecting a textdraw, OnPlayerClickTextDraw is called with a textdraw ID of 'INVALID_TEXT_DRAW'. OnPlayerClickPlayerTextDraw won't be called also.


Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

Personal tools
In other languages