#include <a_samp>
new Text:teleportBox;
new Text:teleportLS;
new Text:teleportSF;
new Text:teleportLV;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Textdraw teleporting - tut for showing\n how textdraw selecting works");
print("--------------------------------------\n");
teleportBox = TextDrawCreate(320.000000, 143.000000, "~n~Teleport menu~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~_");
TextDrawAlignment(teleportBox, 2);
TextDrawBackgroundColor(teleportBox, 255);
TextDrawFont(teleportBox, 2);
TextDrawLetterSize(teleportBox, 0.500000, 1.000000);
TextDrawColor(teleportBox, -1);
TextDrawSetOutline(teleportBox, 0);
TextDrawSetProportional(teleportBox, 1);
TextDrawSetShadow(teleportBox, 1);
TextDrawUseBox(teleportBox, 1);
TextDrawBoxColor(teleportBox, 255);
TextDrawTextSize(teleportBox, 45.000000, 115.000000);
teleportLS = TextDrawCreate(320.000000, 180.000000, "Los Santos~n~Airport");
TextDrawAlignment(teleportLS, 2);
TextDrawBackgroundColor(teleportLS, 255);
TextDrawFont(teleportLS, 2);
TextDrawLetterSize(teleportLS, 0.260000, 0.799999);
TextDrawColor(teleportLS, -1);
TextDrawSetOutline(teleportLS, 0);
TextDrawSetProportional(teleportLS, 1);
TextDrawSetShadow(teleportLS, 1);
teleportSF = TextDrawCreate(320.000000, 205.000000, "San Fierro~n~Airport");
TextDrawAlignment(teleportSF, 2);
TextDrawBackgroundColor(teleportSF, 255);
TextDrawFont(teleportSF, 2);
TextDrawLetterSize(teleportSF, 0.260000, 0.799999);
TextDrawColor(teleportSF, -1);
TextDrawSetOutline(teleportSF, 0);
TextDrawSetProportional(teleportSF, 1);
TextDrawSetShadow(teleportSF, 1);
teleportLV = TextDrawCreate(320.000000, 230.000000, "Las Venturas~n~Airport");
TextDrawAlignment(teleportLV, 2);
TextDrawBackgroundColor(teleportLV, 255);
TextDrawFont(teleportLV, 2);
TextDrawLetterSize(teleportLV, 0.260000, 0.799999);
TextDrawColor(teleportLV, -1);
TextDrawSetOutline(teleportLV, 0);
TextDrawSetProportional(teleportLV, 1);
TextDrawSetShadow(teleportLV, 1);
return 1;
}
TextDrawSetSelectable(teleportBox, false);
TextDrawSetSelectable(teleportLS, true);
TextDrawSetSelectable(teleportSF, true);
TextDrawSetSelectable(teleportLV, true);
public OnFilterScriptExit()
{
TextDrawDestroy(teleportBox);
TextDrawDestroy(teleportLS);
TextDrawDestroy(teleportSF);
TextDrawDestroy(teleportLV);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp("/teleport", cmdtext, true))
{
TextDrawShowForPlayer(playerid, teleportBox); // Show the box
TextDrawShowForPlayer(playerid, teleportLS); // Show the LS option
TextDrawShowForPlayer(playerid, teleportSF); // Show the SF option
TextDrawShowForPlayer(playerid, teleportLV); // Show the LV option
SelectTextDraw(playerid, 0xA3B4C5FF); // Allow the player to select textdraws.
// The second parameter is the colour to which the textdraw turns when you hover over it.
// You can use stuff like COLOR_RED as well, that's your choice.
return 1;
}
return 0;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(clickedid == teleportLS) // If the player clicked on the teleportLS textdraw, teleport him there!
{
SetPlayerPos(playerid, 1630.2030,-2328.9673,13.5469);
SetPlayerFacingAngle(playerid, 0.9392);
}
else if(clickedid == teleportSF) // Same as above, but for SF
{
SetPlayerPos(playerid, -1424.6083, -290.9622, 14.1484);
SetPlayerFacingAngle(playerid, 134.9570);
}
else if(clickedid == teleportLV) // Same, but for LV
{
SetPlayerPos(playerid, 1688.7990, 1447.7753, 10.7675);
SetPlayerFacingAngle(playerid, 267.3902);
}
// Hide the textdraws after the player has teleport himself.
TextDrawHideForPlayer(playerid, teleportBox);
TextDrawHideForPlayer(playerid, teleportLS);
TextDrawHideForPlayer(playerid, teleportSF);
TextDrawHideForPlayer(playerid, teleportLV);
CancelSelectTextDraw(playerid); // Everything worked out perfectly, now stop the player to be able to select shizzle.
return 1;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(_:clickedid != INVALID_TEXT_DRAW) // If the player clicked a valid textdraw, continue with the coding. (_:var removes the Text: tag, to avoid tag mismatch)
{
if(clickedid == teleportLS)
{
SetPlayerPos(playerid, 1630.2030,-2328.9673,13.5469);
SetPlayerFacingAngle(playerid, 0.9392);
}
else if(clickedid == teleportSF)
{
SetPlayerPos(playerid, -1424.6083, -290.9622, 14.1484);
SetPlayerFacingAngle(playerid, 134.9570);
}
else if(clickedid == teleportLV)
{
SetPlayerPos(playerid, 1688.7990, 1447.7753, 10.7675);
SetPlayerFacingAngle(playerid, 267.3902);
}
TextDrawHideForPlayer(playerid, teleportBox);
TextDrawHideForPlayer(playerid, teleportLS);
TextDrawHideForPlayer(playerid, teleportSF);
TextDrawHideForPlayer(playerid, teleportLV);
CancelSelectTextDraw(playerid); // This will indeed call OnPlayerClickTextDraw again, but with an ID of 65535. The code above stops it from resulting in an eternal loop.
}
return 1;
}
. I can see a ton of features using this system.
|
Thanks folks, good luck working out your own ideas
. I can see a ton of features using this system. |
|
Got some issue on the hover as stated on the video. You mind explaining how to fix that?
|


..
)