Advertisement
ZulRocky

yom_buttons.inc

May 17th, 2013
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.14 KB | None | 0 0
  1. /*##############################################################################
  2.  
  3.  
  4.                     #########################################
  5.                     #                                       #
  6.                     #     BUTTONS - INCLUDE FILE BY YOM     #
  7.                     #       Steal my work and die >:D       #
  8.                     #                                       #
  9.                     #########################################
  10.  
  11.  
  12. - Informations about this file:
  13. ===============================
  14.  
  15.     -   A set of more or less useful functions related to buttons.
  16.     -   You must run the Button FS or these function will not work.
  17.     -   See in the filterscript for more informations
  18.  
  19.  
  20. ##############################################################################*/
  21.  
  22.  
  23.  
  24.  
  25. /*----------------------------------------------------------------------------*/
  26. #define INVALID_BUTTON_ID   -1
  27. /*----------------------------------------------------------------------------*/
  28.  
  29.  
  30.  
  31.  
  32. /*----------------------------------------------------------------------------*/
  33. forward OnPlayerPressButton(playerid, buttonid);
  34. forward OnButtonMoved(buttonid);
  35. /*----------------------------------------------------------------------------*/
  36.  
  37.  
  38.  
  39.  
  40. /*------------------------------------------------------------------------------
  41. native CreateButton(Float:X, Float:Y, Float:Z, Float:Angle = 0.0);
  42. native DestroyButton(buttonid);
  43.  
  44. native GetButtonPos(buttonid, &Float:X, &Float:Y, &Float:Z, &Float:Angle = 0.0);
  45. native SetButtonPos(buttonid, Float:X, Float:Y, Float:Z, Float:Angle = 0.0);
  46.  
  47. native MoveButton(buttonid, Float:X, Float:Y, Float:Z, Float:Speed);
  48. native StopButton(buttonid);
  49.  
  50. native PrintButtonsInfos();
  51. native bool:IsValidButton(buttonid);
  52. native GetHighestButtonID();
  53. native GetButtonObjectID(buttonid);
  54. native GetObjectButtonID(objectid);
  55.  
  56. native Float:GetDistanceToButton(buttonid, Float:X, Float:Y, Float:Z);
  57. native Float:GetPlayerDistanceToButton(playerid, buttonid);
  58. native GetClosestButton(Float:X, Float:Y, Float:Z, &Float:Distance = 0.0);
  59. native GetPlayerClosestButton(playerid, &Float:Distance = 0.0);
  60. native ToggleButtonEnabled(buttonid, bool:enabled);
  61. native ToggleButtonEnabledForPlayer(playerid, buttonid, bool:enabled);
  62. native TeleportPlayerToButton(playerid, buttonid);
  63. ------------------------------------------------------------------------------*/
  64.  
  65.  
  66.  
  67.  
  68. /*----------------------------------------------------------------------------*/
  69. stock CreateButton(Float:X, Float:Y, Float:Z, Float:Angle = 0.0)
  70.     return CallRemoteFunction("FS_CreateButton", "ffff", X, Y, Z, Angle);
  71.  
  72.  
  73.  
  74. stock DestroyButton(buttonid)
  75.     return CallRemoteFunction("FS_DestroyButton", "i", buttonid);
  76. /*----------------------------------------------------------------------------*/
  77.  
  78.  
  79.  
  80.  
  81. /*----------------------------------------------------------------------------*/
  82. stock GetButtonPos(buttonid, &Float:X, &Float:Y, &Float:Z, &Float:Angle = 0.0)
  83. {
  84.     new objectid = GetButtonObjectID(buttonid);
  85.     GetObjectPos(objectid, X, Y, Z);
  86.     GetObjectRot(objectid, Angle, Angle, Angle);
  87. }
  88.  
  89.  
  90.  
  91. stock SetButtonPos(buttonid, Float:X, Float:Y, Float:Z, Float:Angle = 0.0)
  92.     return CallRemoteFunction("FS_SetButtonPos", "iffff", buttonid, X, Y, Z, Angle);
  93. /*----------------------------------------------------------------------------*/
  94.  
  95.  
  96.  
  97.  
  98. /*----------------------------------------------------------------------------*/
  99. stock MoveButton(buttonid, Float:X, Float:Y, Float:Z, Float:Speed)
  100.     return CallRemoteFunction("FS_MoveButton", "iffff", buttonid, X, Y, Z, Speed);
  101.  
  102.  
  103.  
  104. stock StopButton(buttonid)
  105.     return CallRemoteFunction("FS_StopButton", "i", buttonid);
  106. /*----------------------------------------------------------------------------*/
  107.  
  108.  
  109.  
  110.  
  111. /*----------------------------------------------------------------------------*/
  112. stock PrintButtonsInfos()
  113.     return CallRemoteFunction("FS_PrintButtonsInfos", "");
  114.  
  115. stock bool:IsValidButton(buttonid)
  116.     return bool:CallRemoteFunction("FS_IsValidButton", "i", buttonid);
  117.  
  118.  
  119.  
  120. stock GetHighestButtonID()
  121.     return CallRemoteFunction("FS_GetHighestButtonID", "");
  122.  
  123.  
  124.  
  125. stock GetButtonObjectID(buttonid)
  126.     return CallRemoteFunction("FS_GetButtonObjectID", "i", buttonid);
  127.  
  128.  
  129.  
  130. stock GetObjectButtonID(objectid)
  131.     return CallRemoteFunction("FS_GetObjectButtonID", "i", objectid);
  132. /*----------------------------------------------------------------------------*/
  133.  
  134.  
  135.  
  136.  
  137. /*----------------------------------------------------------------------------*/
  138. stock Float:GetDistanceToButton(buttonid, Float:X, Float:Y, Float:Z)
  139.     return Float:CallRemoteFunction("FS_GetDistanceToButton", "ifff", buttonid, X, Y, Z);
  140.  
  141.  
  142.  
  143. stock GetClosestButton(Float:X, Float:Y, Float:Z, &Float:Distance = 0.0)
  144. {
  145.     new Closest = INVALID_BUTTON_ID, Float:Distance2 = 100000.0;
  146.  
  147.     for (new buttonid = 1, highest = GetHighestButtonID(); buttonid <= highest; buttonid ++)
  148.     {
  149.         if (IsValidButton(buttonid))
  150.         {
  151.             Distance = GetDistanceToButton(buttonid, X, Y, Z);
  152.  
  153.             if (Distance < Distance2)
  154.             {
  155.                 Distance2 = Distance;
  156.                 Closest = buttonid;
  157.             }
  158.         }
  159.     }
  160.  
  161.     Distance = Distance2;
  162.  
  163.     return Closest;
  164. }
  165.  
  166. stock ToggleButtonEnabled(buttonid, bool:enabled)
  167.     return CallRemoteFunction("FS_ToggleButtonEnabled", "ii", buttonid, enabled);
  168. /*----------------------------------------------------------------------------*/
  169.  
  170.  
  171.  
  172.  
  173. /*----------------------------------------------------------------------------*/
  174. stock Float:GetPlayerDistanceToButton(playerid, buttonid)
  175. {
  176.     new Float:PlayerPos[3];
  177.     GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  178.     return GetDistanceToButton(buttonid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  179. }
  180.  
  181.  
  182.  
  183. stock GetPlayerClosestButton(playerid, &Float:Distance = 0.0)
  184. {
  185.     new Float:PlayerPos[3];
  186.     GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  187.     return GetClosestButton(PlayerPos[0], PlayerPos[1], PlayerPos[2], Distance);
  188. }
  189.  
  190.  
  191.  
  192. stock TeleportPlayerToButton(playerid, buttonid)
  193.     return CallRemoteFunction("FS_TeleportPlayerToButton", "ii", playerid, buttonid);
  194.  
  195.  
  196.  
  197. stock ToggleButtonEnabledForPlayer(playerid, buttonid, bool:enabled)
  198.     return CallRemoteFunction("FS_ToggleButtonEnabledForPlayer", "iii", playerid, buttonid, enabled);
  199. /*----------------------------------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement