Guest User

GIFTBOX

a guest
Feb 17th, 2016
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3. #include <sscanf2>
  4. #include <zcmd>
  5. #define COLOR_YELLOW 0xFFFF00AA
  6. #define COLOR_RED 0xAA3333AA
  7.  
  8. #define MAX_RANDOM_GIFTS 3
  9.  
  10. public OnFilterScriptInit()
  11. {
  12. print("\n--------------------------------------");
  13. print("S-AFK system by simo0000 is loaded.");
  14. print("--------------------------------------\n");
  15. return 1;
  16. }
  17.  
  18. #pragma tabsize 0
  19.  
  20.  
  21. stock RandomGift(playerid)
  22. {
  23. new randomgift = random(MAX_RANDOM_GIFTS) + 1;
  24. switch (randomgift)
  25. {
  26. case 1:
  27. {
  28. GivePlayerMoney(playerid, 50000);
  29. SendClientMessage(playerid, COLOR_YELLOW, "You have won 50000$ enjoy!.");
  30. }
  31. case 2:
  32. {
  33. GivePlayerMoney(playerid, 10000);
  34. SendClientMessage(playerid, COLOR_YELLOW, "You have won 10000$ enjoy!.");
  35. }
  36. case 3:
  37. {
  38. SetPlayerArmour(playerid, 100);
  39. SendClientMessage(playerid, COLOR_YELLOW, "You have a vest enjoy!.");
  40. }
  41. }
  42. return 1;
  43. }
  44.  
  45.  
  46. new Float:giftPos[4];
  47. new giftboxobject;
  48. new giftboxcreated = 0;
  49. new Text3D:giftbox3DText;
  50.  
  51.  
  52. CMD:giftbox(playerid, params[])
  53. {
  54. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an admin!");
  55. if (isnull(params))
  56. {
  57. SendClientMessage(playerid, -1, "/giftbox [Option]");
  58. SendClientMessage(playerid, COLOR_YELLOW, "[OPTIONS]: place, destroy");
  59. return 1;
  60. }
  61. static
  62. Float:X,
  63. Float:Y,
  64. Float:Z,
  65. Float:A;
  66.  
  67. GetPlayerPos(playerid, X, Y, Z);
  68. GetPlayerFacingAngle(playerid, A);
  69.  
  70. if (!strcmp(params, "place", true))
  71. {
  72. if (IsPlayerInAnyVehicle(playerid))
  73. return SendClientMessage(playerid, COLOR_RED, "You must be outside vehicle first.");
  74. if(giftboxcreated == 1) return SendClientMessage(playerid, COLOR_RED, "Giftbox is already placed.");
  75. giftPos[0] = X;
  76. giftPos[1] = Y;
  77. giftPos[2] = Z;
  78. giftboxcreated = 1;
  79. giftboxobject = CreateDynamicObject(19054, X, Y, Z - 0.4, 0.0, 0.0, A);
  80. giftbox3DText = CreateDynamic3DTextLabel("/getgift\nTo get your gift.",0x10F441AA,X, Y, Z+0.25,8.0);
  81. SendClientMessage(playerid, -1, "You have placed a giftbox");
  82. return 1;
  83. }
  84.  
  85. if (!strcmp(params, "destroy", true))
  86. {
  87. if(giftboxcreated == 0) return SendClientMessage(playerid, COLOR_RED, "Giftbox is not placed yet.");
  88. DestroyDynamicObject(giftboxobject);
  89. DestroyDynamic3DTextLabel(giftbox3DText);
  90. giftboxcreated = 0;
  91. SendClientMessage(playerid, -1, "You have destoryed the giftbox");
  92. return 1;
  93. }
  94. return 1;
  95. }
  96.  
  97. CMD:getgift(playerid)
  98. {
  99. if(!IsPlayerConnected(playerid))
  100. return SendClientMessage(playerid, -1, "You must be logged in to do this.");
  101.  
  102. GetObjectPos(giftboxobject, giftPos[0], giftPos[1], giftPos[2]);
  103.  
  104. if(IsPlayerInRangeOfPoint(playerid, 5.0, giftPos[0], giftPos[1], giftPos[2]) && giftboxcreated == 1)
  105. {
  106. RandomGift(playerid);
  107. }
  108. return 1;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment