Advertisement
Guest User

Drugger job [UPDATED

a guest
Oct 25th, 2013
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <YSI\y_ini>
  4.  
  5.  
  6. // Defining the path where the user accounts will go
  7.  
  8. #define PATH "/Drugger/%s.ini"
  9.  
  10.  
  11. // Some configurations for the script to work
  12.  
  13. new HasMaterials[MAX_PLAYERS];
  14. new IsDrunk[MAX_PLAYERS];
  15. new lightblue = 0xADD8E6FF;
  16. new red = 0xFF0000AA;
  17.  
  18. // Defining the user Information script-related
  19. enum pInfo
  20. {
  21. pJob,
  22. pDrugs
  23. }
  24.  
  25. new PlayerInfo[MAX_PLAYERS][pInfo];
  26.  
  27. forward LoadUser_data(playerid,name[],value[]);
  28. public LoadUser_data(playerid,name[],value[])
  29. {
  30. INI_Int("IsDrugger",PlayerInfo[playerid][pJob]);
  31. INI_Int("AmountOfDrugs",PlayerInfo[playerid][pDrugs]);
  32. return 1;
  33. }
  34.  
  35. stock UserPath(playerid)
  36. {
  37. new string[128],playername[MAX_PLAYER_NAME];
  38. GetPlayerName(playerid, playername, sizeof(playername));
  39. format(string, sizeof(string), PATH, playername);
  40. return string;
  41. }
  42.  
  43. /*Credits to Dracoblue*/
  44. stock udb_hash(buf[]) {
  45. new length=strlen(buf);
  46. new s1 = 1;
  47. new s2 = 0;
  48. new n;
  49. for (n=0; n<length; n++)
  50. {
  51. s1 = (s1 + buf[n]) % 65521;
  52. s2 = (s2 + s1) % 65521;
  53. }
  54. return (s2 << 16) + s1;
  55. }
  56.  
  57.  
  58. public OnFilterScriptInit()
  59. {
  60. // Takejob configurations
  61.  
  62. CreatePickup(1239, 1, 2065.2837,-1558.5857,13.4369, -1);
  63. Create3DTextLabel("Drugger job\n/takedruggerjob | /quitdruggerjob", 0xFF0000AA, 2065.2837,-1558.5857,13.4369, 5.0, 0, 0);
  64.  
  65. // pickupmaterials configurations
  66.  
  67. CreatePickup(1254, 1, 2067.4619, -1561.9774, 13.4270, -1);
  68. Create3DTextLabel("Drugger job\n/pickupmaterials", 0xFF0000AA, 2067.4619,-1561.9774,13.4270, 5.0, 0, 0);
  69.  
  70. // createdrugs configurations
  71.  
  72. CreatePickup(1279, 1, 2355.3733, -648.4775, 128.0547, -1);
  73. Create3DTextLabel("Drugger job\n/createdrugs", 0xFF0000AA, 2355.3733, -648.4775, 128.0547, 5.0, 0, 0);
  74.  
  75. return 1;
  76. }
  77.  
  78. public OnPlayerSpawn(playerid)
  79. {
  80. return 1;
  81. }
  82.  
  83. COMMAND:takedruggerjob(playerid, params[])
  84. {
  85. if(PlayerInfo[playerid][pJob] == 0)
  86. {
  87. if(IsPlayerInRangeOfPoint(playerid, 1.0, 2065.2837, -1558.5857, 13.4369))
  88. {
  89. PlayerInfo[playerid][pJob] = 1;
  90. SendClientMessage(playerid, lightblue, "Congratulations. You're now an Drugger. For more help about your job please use '/druggerhelp'.");
  91. }
  92. else
  93. SendClientMessage(playerid, red, "[ERROR] You're not at the place to take the Drugger job.");
  94. }
  95. else
  96. SendClientMessage(playerid, red, "[ERROR] You're already an Drugger.");
  97. return 1;
  98. }
  99.  
  100. COMMAND:quitdruggerjob(playerid, params[])
  101. {
  102. if(PlayerInfo[playerid][pJob] == 1)
  103. {
  104. SendClientMessage(playerid, lightblue, "You left your drugger job.");
  105. PlayerInfo[playerid][pJob] = 0;
  106. }
  107. else
  108. SendClientMessage(playerid, red, "[ERROR] You're not an drugger.");
  109.  
  110. return 1;
  111. }
  112.  
  113. COMMAND:druggerhelp(playerid, params[])
  114. {
  115. new msg[2000];
  116.  
  117. format(msg, 2000, "%s{FFFFFF}Hello Drugger,\n\n\n", msg);
  118. format(msg, 2000, "%s{FFFFFF}These are the commands of your job:\n\n", msg);
  119. format(msg, 2000, "%s{FF0000}1. {FFFFFF}/takedruggerjob -> Takes the Drugger job\n", msg);
  120. format(msg, 2000, "%s{FF0000}2. {FFFFFF}/pickupmaterials -> Picks up the required materials for creating drugs\n", msg);
  121. format(msg, 2000, "%s{FF0000}3. {FFFFFF}/quitdruggerjob -> Quits the Drugger job\n", msg);
  122. format(msg, 2000, "%s{FF0000}4. {FFFFFF}/createdrugs -> Creates drugs\n", msg);
  123. format(msg, 2000, "%s{FF0000}5. {FFFFFF}/givedrugs -> You can trade drugs for cash with other players near you\n", msg);
  124. format(msg, 2000, "%s{FF0000}6. {FFFFFF}/usedrugs -> You can use the drugs you got\n", msg);
  125. format(msg, 2000, "%s{FF0000}7. {FFFFFF}/mydrugs -> Checks if you got drugs or not\n\n", msg);
  126. format(msg, 2000, "%s{FFFFFF}Thank you for reading the help menu", msg);
  127.  
  128. if(PlayerInfo[playerid][pJob] == 1)
  129. {
  130. ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_MSGBOX, "{FFFFFF}Drugger Help", msg, "Okay", "");
  131. return 1;
  132. }
  133. else
  134. SendClientMessage(playerid, red, "[ERROR] You're not an Drugger.");
  135.  
  136. return 1;
  137. }
  138. COMMAND:pickupmaterials(playerid, params[])
  139. {
  140. if(PlayerInfo[playerid][pJob] == 1)
  141. {
  142. if(HasMaterials[playerid] == 0)
  143. {
  144. if(IsPlayerInRangeOfPoint(playerid, 1.0, 2067.4619,-1561.9774,13.4270))
  145. {
  146. HasMaterials[playerid] = 1;
  147. SendClientMessage(playerid, lightblue, "You have loaded the materials successfully. Take care of police.");
  148.  
  149. SetPlayerCheckpoint(playerid, 2355.3733, -648.4775, 128.0547, 1.0);
  150. }
  151. else
  152. SendClientMessage(playerid, red, "[ERROR] You're not at the materials pickup position.");
  153. }
  154. else
  155. SendClientMessage(playerid, red, "[ERROR] You can only load 1 pack of materials at one time.");
  156. }
  157. else
  158. SendClientMessage(playerid, red, "[ERROR] You're not a Drugger.");
  159. }
  160.  
  161. COMMAND:createdrugs(playerid, params[])
  162. {
  163. if(PlayerInfo[playerid][pJob] == 1)
  164. {
  165. if(IsPlayerInRangeOfPoint(playerid, 1.0, 2355.3733, -648.4775, 128.0547))
  166. {
  167. PlayerInfo[playerid][pDrugs]++;
  168. SendClientMessage(playerid, lightblue, "Congratulations. You've created drugs.");
  169. }
  170. else
  171. SendClientMessage(playerid, red, "[ERROR] You're not at the drugs creation place.");
  172. }
  173. else
  174. SendClientMessage(playerid, red, "[ERROR] You're not an Drugger.");
  175. }
  176.  
  177. COMMAND:usedrugs(playerid, params[])
  178. {
  179. if(PlayerInfo[playerid][pDrugs] >= 1)
  180. {
  181. PlayerInfo[playerid][pDrugs]--;
  182. IsDrunk[playerid] = 1;
  183. SetPlayerDrunkLevel(playerid, 50000);
  184. SendClientMessage(playerid, lightblue, "You're now under effects of drugs. Be sure the cops wont bust you.");
  185. SetTimer("drunkmiddle", 150000, false);
  186. }
  187. else
  188. SendClientMessage(playerid, red, "[ERROR] You don't have drugs. Ask someone who has it to give it to you.");
  189. }
  190.  
  191. forward drunkmiddle(playerid);
  192.  
  193. public drunkmiddle(playerid)
  194. {
  195. SendClientMessage(playerid, lightblue, "You've slowly recovering your self from the drugs.");
  196. SetPlayerDrunkLevel(playerid, 55000);
  197. SetTimer("drunkend", 360000, false);
  198. return 1;
  199. }
  200.  
  201. forward drunkend(playerid);
  202.  
  203. public drunkend(playerid)
  204. {
  205. SetPlayerDrunkLevel(playerid, 0);
  206. SendClientMessage(playerid, lightblue, "You fully recovered your self from the drugs.");
  207. IsDrunk[playerid] = 0;
  208. return 1;
  209. }
  210.  
  211. COMMAND:mydrugs(playerid, params[])
  212. {
  213. new string[256];
  214.  
  215. if(PlayerInfo[playerid][pDrugs] >= 1)
  216. {
  217. format(string, 256, "Drugs in your bag: %i", PlayerInfo[playerid][pDrugs]);
  218. SendClientMessage(playerid, lightblue, string);
  219. }
  220. else if(PlayerInfo[playerid][pDrugs] < 1)
  221. {
  222. SendClientMessage(playerid, lightblue, "You don't have any drugs in your bag.");
  223. }
  224. return 1;
  225. }
  226.  
  227. COMMAND:givedrugs(playerid, params[])
  228. {
  229. new OtherPlayer, OtherPlayerName[24], msg[2000], YourName[24];
  230. new Float:x, Float:y, Float:z;
  231. GetPlayerPos(playerid, x, y, z);
  232.  
  233. if(PlayerInfo[playerid][pDrugs] >= 1)
  234. {
  235. if(IsPlayerInRangeOfPoint(OtherPlayer, 2.0, x, y, z))
  236. {
  237. GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));
  238. GetPlayerName(playerid, YourName, sizeof(YourName));
  239. PlayerInfo[OtherPlayer][pDrugs]++;
  240. PlayerInfo[OtherPlayer][pDrugs]--;
  241. format(msg, 2000, "You've sent drugs to %s.", OtherPlayerName);
  242. SendClientMessage(playerid, lightblue, msg);
  243. format(msg, 2000, "You've recieved drugs from %s.", YourName);
  244. SendClientMessage(OtherPlayer, lightblue, msg);
  245. }
  246. else
  247. SendClientMessage(playerid, red, "[ERROR] You're not near that person.");
  248. }
  249. else
  250. SendClientMessage(playerid, red, "[ERROR] You can't send drugs you don't own.");
  251. return 1;
  252. }
  253.  
  254. public OnPlayerEnterCheckpoint(playerid)
  255. {
  256. DisablePlayerCheckpoint(playerid);
  257. return 1;
  258. }
  259.  
  260. // Saving everything when player get's dissconected.
  261.  
  262. public OnPlayerDisconnect(playerid, reason)
  263. {
  264. new INI:File = INI_Open(UserPath(playerid));
  265. INI_SetTag(File,"data");
  266. INI_WriteInt(File,"IsDrugger",PlayerInfo[playerid][pJob]);
  267. INI_WriteInt(File,"AmountOfDrugs",PlayerInfo[playerid][pDrugs]);
  268. INI_Close(File);
  269. return 1;
  270. }
  271.  
  272. public OnPlayerConnect(playerid)
  273. {
  274. if(fexist(UserPath(playerid)))
  275. {
  276. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  277. }
  278. else
  279. {
  280. new INI:File = INI_Open(UserPath(playerid));
  281. INI_SetTag(File,"data");
  282. INI_WriteInt(File,"IsDrugger", 0);
  283. INI_WriteInt(File,"AmountOfDrugs",0);
  284. INI_Close(File);
  285. }
  286. return 1;
  287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement