Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
1,739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.19 KB | None | 0 0
  1. #define DIALOG_DRUGHELP 1069
  2. #define COLOR_GREY 0xAFAFAFAA
  3.  
  4. #include <a_samp>
  5. #include <zcmd>
  6. #include <sscanf2>
  7.  
  8. new DrugTimer[MAX_PLAYERS];
  9. new StonedTimer[MAX_PLAYERS];
  10. new UsedDrug[MAX_PLAYERS];
  11.  
  12. enum pInfo{
  13. pCannabis,
  14. pCocaine
  15. }
  16. new PlayerInfo[MAX_PLAYERS][pInfo];
  17. forward RemoveDrugEffect(playerid);
  18. public RemoveDrugEffect(playerid)
  19. {
  20. SetPlayerWeather(playerid, 0);
  21. SetPlayerDrunkLevel(playerid, 0);
  22. SendClientMessage(playerid, COLOR_GREY, "Your drug effect has been removed, you may /usedrug again.");
  23. return 1;
  24. }
  25.  
  26. stock pName(playerid)
  27. {
  28. new name[MAX_PLAYER_NAME];
  29. GetPlayerName(playerid, name, sizeof(name));
  30. return name;
  31. }
  32.  
  33. public OnFilterScriptInit()
  34. {
  35. print("\n--------------------------------------");
  36. print(" Simple Drug System by: Shadow");
  37. print(" If you like this system, +rep would be appreciated.");
  38. print("--------------------------------------\n");
  39. return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44. return 1;
  45. }
  46.  
  47. public OnPlayerConnect(playerid)
  48. {
  49. DrugTimer[playerid] = 0;
  50. StonedTimer[playerid] = 0;
  51. UsedDrug[playerid] = 0;
  52. return 1;
  53. }
  54.  
  55. public OnPlayerDisconnect(playerid, reason)
  56. {
  57. DrugTimer[playerid] = 0;
  58. StonedTimer[playerid] = 0;
  59. UsedDrug[playerid] = 0;
  60. return 1;
  61. }
  62.  
  63. CMD:drughelp(playerid, params[])
  64. {
  65. if(IsPlayerAdmin(playerid)) ShowPlayerDialog(playerid, DIALOG_DRUGHELP, DIALOG_STYLE_MSGBOX, "Drug Help", "/mydrugs - Check your drugs.\n/usedrug - Use a drug.\n/givedrugs - Give someone X amount of drug", "Close", "");
  66. else ShowPlayerDialog(playerid, DIALOG_DRUGHELP, DIALOG_STYLE_MSGBOX, "Drug Help", "/mydrugs - Check your drugs.\n/usedrug - Use a drug.", "Close", "");
  67. return 1;
  68. }
  69.  
  70. CMD:mydrugs(playerid, params[])
  71. {
  72. new str[150];
  73. format(str, sizeof(str), "{FFFFFF}%s drugs", pName(playerid));
  74. SendClientMessage(playerid, COLOR_GREY, str);
  75. format(str, sizeof(str), "{42C5F4}Cannabis: {FFFFFF}(%d grams) {42C5F4}Cocaine: {FFFFFF}(%d grams)", PlayerInfo[playerid][pCannabis], PlayerInfo[playerid][pCocaine]);
  76. SendClientMessage(playerid, COLOR_GREY, str);
  77. return 1;
  78. }
  79.  
  80. CMD:usedrug(playerid, params[])
  81. {
  82. new option[200], Float:HP, str[250], Float:AHP;
  83. if(sscanf(params, "s[200] ", option))
  84. {
  85. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/usedrug [Drug]");
  86. SendClientMessage(playerid, COLOR_GREY, "Drugs: Cannabis, Cocaine");
  87. return 1;
  88. }
  89. if(strcmp(option, "cannabis", true) == 0)
  90. {
  91. if(gettime() < (DrugTimer[playerid] + 5))
  92. {
  93. format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (DrugTimer[playerid] + 5) - gettime());
  94. SendClientMessage(playerid, COLOR_GREY, str);
  95. return 1;
  96. }
  97. if(gettime() < (StonedTimer[playerid] + 120))
  98. {
  99. format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (StonedTimer[playerid] + 120) - gettime());
  100. SendClientMessage(playerid, COLOR_GREY, str);
  101. return 1;
  102. }
  103. GetPlayerHealth(playerid, Float:HP);
  104. if(PlayerInfo[playerid][pCannabis] < 1) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much of Cannabis.");
  105. if(HP >= 100) return SendClientMessage(playerid, COLOR_GREY, "Your HP is already full!");
  106. if(HP >= 90)
  107. {
  108. SetPlayerHealth(playerid, 100);
  109. }
  110. else if(HP < 90)
  111. {
  112. SetPlayerHealth(playerid, HP+15);
  113. }
  114. SendClientMessage(playerid, COLOR_GREY, "You've used 2 grams of cannabis and recived +15 health");
  115. SetPlayerWeather(playerid, 2009);
  116. SetPlayerDrunkLevel(playerid, 9000);
  117. PlayerInfo[playerid][pCannabis] -=1;
  118. DrugTimer[playerid] = gettime();
  119. UsedDrug[playerid] ++;
  120. if(UsedDrug[playerid] >= 3)
  121. {
  122. SetTimerEx("RemoveDrugEffect", 60000*2, false, "i", playerid);
  123. UsedDrug[playerid] = 0;
  124. StonedTimer[playerid] = gettime();
  125. }
  126. return 1;
  127. }
  128. if(strcmp(option, "cocaine", true) == 0)
  129. {
  130. if(gettime() < (DrugTimer[playerid] + 5))
  131. {
  132. format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cocaine again!", (DrugTimer[playerid] + 5) - gettime());
  133. SendClientMessage(playerid, COLOR_GREY, str);
  134. return 1;
  135. }
  136. if(gettime() < (StonedTimer[playerid] + 120))
  137. {
  138. format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cocaine again!", (StonedTimer[playerid] + 120) - gettime());
  139. SendClientMessage(playerid, COLOR_GREY, str);
  140. return 1;
  141. }
  142. GetPlayerArmour(playerid, Float:AHP);
  143. if(PlayerInfo[playerid][pCocaine] < 1) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much of Cocaine.");
  144. if(AHP >= 100) return SendClientMessage(playerid, COLOR_GREY, "Your Armor is already full!");
  145. if(AHP >= 90)
  146. {
  147. SetPlayerArmour(playerid, 100);
  148. }
  149. else if(AHP < 90)
  150. {
  151. SetPlayerArmour(playerid, AHP+15);
  152. }
  153. SendClientMessage(playerid, COLOR_GREY, "You've used 2 grams of cocaine and recived +15 armour");
  154. SetPlayerWeather(playerid, 250);
  155. SetPlayerDrunkLevel(playerid, 9000);
  156. PlayerInfo[playerid][pCocaine] -=1;
  157. DrugTimer[playerid] = gettime();
  158. UsedDrug[playerid] ++;
  159. if(UsedDrug[playerid] >= 3)
  160. {
  161. SetTimerEx("RemoveDrugEffect", 60000*2, false, "i", playerid);
  162. UsedDrug[playerid] = 0;
  163. StonedTimer[playerid] = gettime();
  164. }
  165. return 1;
  166. }
  167. return 1;
  168. }
  169.  
  170. CMD:givedrugs(playerid, params[])
  171. {
  172. new option[200], id, amount, str[100], Float:x, Float:y, Float:z;
  173. GetPlayerPos(id, Float:x, Float:y, Float:z);
  174. if(sscanf(params, "s[200] ", option))
  175. {
  176. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/givedrugs [drug]");
  177. SendClientMessage(playerid, COLOR_GREY, "Drugs: Cannabis, Cocaine");
  178. return 1;
  179. }
  180. if(strcmp(option, "cannabis", true) == 0)
  181. {
  182. if(sscanf(params, "s[200]dd", option, id, amount))
  183. {
  184. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/givedrugs cannabis [playerid] [amount]");
  185. return 1;
  186. }
  187. if(!(IsPlayerInRangeOfPoint(playerid, 3.0, Float:x, Float:y, Float:z))) return SendClientMessage(playerid, COLOR_GREY, "You're not in range of that player!");
  188. format(str, sizeof(str), "You've given %s %d of cannabis!",pName(id), amount);
  189. SendClientMessage(playerid, COLOR_GREY, str);
  190. PlayerInfo[id][pCannabis] += amount;
  191. PlayerInfo[playerid][pCannabis] -= amount;
  192. return 1;
  193. }
  194. if(strcmp(option, "cocaine", true) == 0)
  195. {
  196. if(sscanf(params, "s[200]dd", option, id, amount))
  197. {
  198. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/givedrugs cocaine [playerid] [amount]");
  199. return 1;
  200. }
  201. if(!(IsPlayerInRangeOfPoint(playerid, 3.0, Float:x, Float:y, Float:z))) return SendClientMessage(playerid, COLOR_GREY, "You're not in range of that player!");
  202. format(str, sizeof(str), "You've given %s %d of cocaine!",pName(id), amount);
  203. SendClientMessage(playerid, COLOR_GREY, str);
  204. PlayerInfo[id][pCocaine] += amount;
  205. PlayerInfo[playerid][pCocaine] -= amount;
  206. return 1;
  207. }
  208. return 1;
  209. }
  210.  
  211. CMD:agivedrugs(playerid, params[])
  212. {
  213. new option[200], id, amount, str[100];
  214. if(!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COLOR_GREY, "Not authorized!");
  215. if(sscanf(params, "s[200] ", option))
  216. {
  217. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/agivedrugs [drug]");
  218. SendClientMessage(playerid, COLOR_GREY, "Drugs: Cannabis, Cocaine");
  219. return 1;
  220. }
  221. if(strcmp(option, "cannabis", true) == 0)
  222. {
  223. if(sscanf(params, "s[200]dd", option, id, amount))
  224. {
  225. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/agivedrugs cannabis [playerid] [amount]");
  226. return 1;
  227. }
  228. format(str, sizeof(str), "You've given %s %d of cannabis!",pName(id), amount);
  229. SendClientMessage(playerid, COLOR_GREY, str);
  230. PlayerInfo[id][pCannabis] += amount;
  231. return 1;
  232. }
  233. if(strcmp(option, "cocaine", true) == 0)
  234. {
  235. if(sscanf(params, "s[200]dd", option, id, amount))
  236. {
  237. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/agivedrugs cocaine [playerid] [amount]");
  238. return 1;
  239. }
  240. format(str, sizeof(str), "You've given %s %d of cocaine!",pName(id), amount);
  241. SendClientMessage(playerid, COLOR_GREY, str);
  242. PlayerInfo[id][pCocaine] += amount;
  243. return 1;
  244. }
  245. return 1;
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement