core.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /*
  2. @Author; Calvin Catt
  3. *** Developer Commands ***
  4. /createsafe [playerSQL] (will link a safe to a player's account)
  5. /deletesafe (will delete the safe you're beside)
  6. /safeconents (will get contents of the safe you're beside and display sqlID & arrayID)
  7. *** Admin Commands ***
  8. /safeconents (will get contents of the safe you're beside and display sqlID & arrayID)
  9. /safesystem (will allow admins to access the safe as the owner would - can be useful for removing items, etc.)
  10. *** Player Commands ***
  11. /safesystem [put/get] [mats/weapon/meth/cocaine/cannabis/cash] [amount/weapon slot]
  12. /safeconents (will get contents of the safe you're beside)
  13. *** Functions ***
  14. SaveSafe(safe);
  15. SaveSafes();
  16. LoadSafes();
  17. */
  18. #define MAX_SAFES 100
  19. #define MAX_SAFE_WEAPONS 10
  20. enum iSafeInfo
  21. {
  22. owner,
  23. Float:posX,
  24. Float:posY,
  25. Float:posZ,
  26. virtualWorld,
  27. interior,
  28. cash,
  29. materials,
  30. meth,
  31. cocaine,
  32. cannabis,
  33. sqlID,
  34. pickupID
  35. }
  36. new itemSafeData[MAX_SAFES][iSafeInfo];
  37. new weaponSafeData[MAX_SAFES][MAX_SAFE_WEAPONS];
  38. new safescript[128];
  39. stock SaveSafe(safe, print = true)
  40. {
  41. if(print) printf("[SAFE] Saving itemSafeData[%d] linked to player SQL: %d", safe, itemSafeData[safe][owner]);
  42. if(itemSafeData[safe][sqlID] == 0) return 1; // We don't save unused safes...
  43. new query[512], weapQuery[256];
  44. for(new i = 0; i < MAX_SAFE_WEAPONS; i++)
  45. {
  46. mysql_format(sqlGameConnection, weapQuery, sizeof(weapQuery), "%s`weapon%d` = %d,", weapQuery, i, weaponSafeData[safe][i]);
  47. }
  48. mysql_format(sqlGameConnection, query, sizeof(query), "UPDATE `safes` SET `cash`= %d,`mats`= %d,`meth`= %d,`cocaine`= %d, %s `cannabis`= %d WHERE `safeID` = %d",
  49. itemSafeData[safe][cash], itemSafeData[safe][materials], itemSafeData[safe][meth], itemSafeData[safe][cocaine], weapQuery, itemSafeData[safe][cannabis], itemSafeData[safe][sqlID]);
  50. mysql_pquery(sqlGameConnection, query);
  51. printf(query);
  52. return 1;
  53. }
  54. stock SaveSafes()
  55. {
  56. printf("[SAFE] Saving all safes.");
  57. for(new i = 0; i < MAX_SAFES; i++)
  58. {
  59. SaveSafe(i, false);
  60. }
  61. return 1;
  62. }
  63. stock LoadSafes()
  64. {
  65. new query[128];
  66. mysql_format(sqlGameConnection, query, sizeof(query), "SELECT * FROM `safes`");
  67. mysql_pquery(sqlGameConnection, query, "OnLoadSafes");
  68. return 1;
  69. }
  70. forward OnDeleteSafe(safe, playerid);
  71. public OnDeleteSafe(safe, playerid)
  72. {
  73. printf("[SAFE] itemSafeData[%d] has been deleted by %s.", safe, itemSafeData[safe][sqlID], PlayerName(playerid));
  74. DestroyDynamicPickup(itemSafeData[safe][pickupID]);
  75. itemSafeData[safe][posX] = 0.00;
  76. itemSafeData[safe][posY] = 0.00;
  77. itemSafeData[safe][posZ] = 0.00;
  78. itemSafeData[safe][interior] = 0;
  79. itemSafeData[safe][virtualWorld] = 0;
  80. itemSafeData[safe][owner] = 0;
  81. itemSafeData[safe][cash] = 0;
  82. itemSafeData[safe][materials] = 0;
  83. itemSafeData[safe][meth] = 0;
  84. itemSafeData[safe][cocaine] = 0;
  85. itemSafeData[safe][cannabis] = 0;
  86. itemSafeData[safe][sqlID] = 0;
  87. SendClientMessage(playerid, COLOR_GRAD1, "Successfully deleted the safe.");
  88. return 1;
  89. }
  90. forward OnLoadSafes();
  91. public OnLoadSafes()
  92. {
  93. new rows, fields;
  94. cache_get_data(rows, fields);
  95. if(rows)
  96. {
  97. new value[8];
  98. for(new safe = 0; safe < rows; safe++)
  99. {
  100. if(safe == MAX_SAFES - 1) return printf("Max safe limit reached.");
  101. itemSafeData[safe][sqlID] = cache_get_field_content_int(safe, "safeID");
  102. cache_get_field_content(safe, "posX", value);
  103. itemSafeData[safe][posX] = floatstr(value);
  104. cache_get_field_content(safe, "posY", value);
  105. itemSafeData[safe][posY] = floatstr(value);
  106. cache_get_field_content(safe, "posZ", value);
  107. itemSafeData[safe][posZ] = floatstr(value);
  108. itemSafeData[safe][interior] = cache_get_field_content_int(safe, "interior");
  109. itemSafeData[safe][virtualWorld] = cache_get_field_content_int(safe, "VW");
  110. itemSafeData[safe][owner] = cache_get_field_content_int(safe, "OwnerID");
  111. itemSafeData[safe][cash] = cache_get_field_content_int(safe, "cash");
  112. itemSafeData[safe][materials] = cache_get_field_content_int(safe, "mats");
  113. itemSafeData[safe][meth] = cache_get_field_content_int(safe, "meth");
  114. itemSafeData[safe][cocaine] = cache_get_field_content_int(safe, "cocaine");
  115. itemSafeData[safe][cannabis] = cache_get_field_content_int(safe, "cannabis");
  116. DestroyDynamicPickup(itemSafeData[safe][pickupID]);
  117. itemSafeData[safe][pickupID] = CreateDynamicPickup(1210, 23, itemSafeData[safe][posX], itemSafeData[safe][posY], itemSafeData[safe][posZ], itemSafeData[safe][virtualWorld], itemSafeData[safe][interior], -1, 100.0);
  118. for(new i = 0; i < MAX_SAFE_WEAPONS; i++)
  119. {
  120. new weapstr[16];
  121. format(weapstr, sizeof(weapstr), "weapon%d", i);
  122. weaponSafeData[safe][i] = cache_get_field_content_int(safe, weapstr);
  123. }
  124. }
  125. printf("[SAFE] %d safes loaded successfully.", rows);
  126. }
  127. else printf("[SAFE] No safes to load.");
  128. return 1;
  129. }
  130. forward GetSafeSQL(safe);
  131. public GetSafeSQL(safe) //get ID after insert query has complete
  132. {
  133. new saveQuery[300];
  134. mysql_format(sqlGameConnection, saveQuery, sizeof(saveQuery), "SELECT `safeID` FROM `safes` ORDER BY `safeID` DESC LIMIT 1");
  135. mysql_pquery(sqlGameConnection, saveQuery, "SetSafeSQL", "i", safe);
  136. return 1;
  137. }
  138. forward SetSafeSQL(safe);
  139. public SetSafeSQL(safe)
  140. {
  141. itemSafeData[safe][sqlID] = cache_get_field_content_int(0, "safeID");
  142. printf("[SAFE] itemSafeData[%d] has been assigned sqlID %d.", safe, itemSafeData[safe][sqlID]);
  143. return 1;
  144. }
  145. CMD:createsafe(playerid, params[])
  146. {
  147. if(PlayerInfo[playerid][pDev] >= 2)
  148. {
  149. new sqlid, unusedid = -1;
  150. if(sscanf(params, "i", sqlid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /createsafe [sqlID]");
  151. new searchstr[64];
  152. for(new i = 0; i < MAX_SAFES; i++)
  153. {
  154. format(searchstr, sizeof(searchstr), "%0.2f,%0.2f,%0.2f", itemSafeData[i][posX], itemSafeData[i][posY],itemSafeData[i][posZ]);
  155. if(strcmp(searchstr, "0.00,0.00,0.00", true) == 0)
  156. {
  157. unusedid = i;
  158. break;
  159. }
  160. }
  161. if(unusedid == -1) return SendClientMessage(playerid, COLOR_GRAD1, "MAX_SAFES has been reached, unable to create another safe!");
  162. itemSafeData[unusedid][owner] = sqlid;
  163. GetPlayerPos(playerid, itemSafeData[unusedid][posX], itemSafeData[unusedid][posY], itemSafeData[unusedid][posZ]);
  164. itemSafeData[unusedid][interior] = GetPlayerInterior(playerid);
  165. itemSafeData[unusedid][virtualWorld] = GetPlayerVirtualWorld(playerid);
  166. DestroyDynamicPickup(itemSafeData[unusedid][pickupID]);
  167. itemSafeData[unusedid][pickupID] = CreateDynamicPickup(1210, 23, itemSafeData[unusedid][posX], itemSafeData[unusedid][posY], itemSafeData[unusedid][posZ], itemSafeData[unusedid][virtualWorld], itemSafeData[unusedid][interior], -1, 100.0);
  168. new query[512];
  169. mysql_format( sqlGameConnection, query, sizeof(query), "INSERT INTO `safes` SET `OwnerID` = %d, `posX`= %f,`posY`= %f,`posZ`= %f,`VW`= %d,`interior`= %d",
  170. itemSafeData[unusedid][owner], itemSafeData[unusedid][posX], itemSafeData[unusedid][posY], itemSafeData[unusedid][posZ], itemSafeData[unusedid][virtualWorld], itemSafeData[unusedid][interior]);
  171. mysql_pquery( sqlGameConnection, query, "GetSafeSQL", "i", unusedid);
  172. printf(query);
  173. SaveSafe(unusedid);
  174. SendClientMessage(playerid, COLOR_GRAD1, "Successfully created a safe.");
  175. return 1;
  176. }
  177. return 1;
  178. }
  179. CMD:deletesafe(playerid, params[])
  180. {
  181. new safe = -1;
  182. for(new i = 0; i < MAX_SAFES; i++)
  183. {
  184. if(IsPlayerInRangeOfPoint(playerid, 5.0, itemSafeData[i][posX], itemSafeData[i][posY], itemSafeData[i][posZ]))
  185. {
  186. if((GetPlayerVirtualWorld(playerid) == itemSafeData[i][virtualWorld]) && (GetPlayerInterior(playerid) == itemSafeData[i][interior]))
  187. {
  188. if(itemSafeData[i][owner] != 0) // Prevent deleting a blank one then trying to delete from SQL
  189. {
  190. safe = i;
  191. }
  192. }
  193. }
  194. }
  195. if(safe == -1) return SendClientMessage(playerid, COLOR_GRAD1, "You are not within range of a safe!");
  196. if(PlayerInfo[playerid][pDev] < 2) return AdmErrorMsg;
  197. new query[256];
  198. // Shouldn't need LIMIT 1 but we'll keep it in, just in case...
  199. mysql_format(sqlGameConnection, query, sizeof(query), "DELETE FROM `safes` WHERE `safeID`= %d LIMIT 1", itemSafeData[safe][sqlID]);
  200. mysql_pquery(sqlGameConnection, query, "OnDeleteSafe", "ii", safe, playerid);
  201. return 1;
  202. }
  203. CMD:safecontents(playerid, params[])
  204. {
  205. new safe = -1;
  206. for(new i = 0; i < MAX_SAFES; i++)
  207. {
  208. if(IsPlayerInRangeOfPoint(playerid, 5.0, itemSafeData[i][posX], itemSafeData[i][posY], itemSafeData[i][posZ]))
  209. {
  210. if((GetPlayerVirtualWorld(playerid) == itemSafeData[i][virtualWorld]) && (GetPlayerInterior(playerid) == itemSafeData[i][interior]))
  211. {
  212. safe = i;
  213. }
  214. }
  215. }
  216. if(safe == -1) return SendClientMessage(playerid, COLOR_GRAD1, "You are not within range of a safe!");
  217. // We'll let admins use this to view safes
  218. if( ((itemSafeData[safe][owner] != PlayerInfo[playerid][pID]) && (PlayerInfo[playerid][pAdmin] < 4) && (PlayerInfo[playerid][pDev] < 2)) ) return SendClientMessage(playerid, COLOR_GREY, "You do not have access to that safe!");
  219. new clientMsg[512], titlestr[32];
  220. format(titlestr, sizeof(titlestr), "** SAFE CONTENTS **");
  221. format(clientMsg, sizeof(clientMsg), "{007BD0}Materials:{FFFFFF} %d\n", itemSafeData[safe][materials]);
  222. format(clientMsg, sizeof(clientMsg), "%s{007BD0}Cannabis:{FFFFFF} %d\n", clientMsg, itemSafeData[safe][cannabis]);
  223. format(clientMsg, sizeof(clientMsg), "%s{007BD0}Cocaine:{FFFFFF} %d\n", clientMsg, itemSafeData[safe][cocaine]);
  224. format(clientMsg, sizeof(clientMsg), "%s{007BD0}Meth:{FFFFFF} %d\n", clientMsg, itemSafeData[safe][meth]);
  225. new weapstr[256];
  226. for(new i = 0; i < MAX_SAFE_WEAPONS; i++)
  227. {
  228. new WeaponName[32];
  229. GetWeaponName(weaponSafeData[safe][i], WeaponName, 32);
  230. if(i == 0) format(weapstr, sizeof(weapstr), "{007BD0}Weapon %d: %s\n", i, WeaponName);
  231. else format(weapstr, sizeof(weapstr), "%s{007BD0}Weapon %d: %s\n", weapstr, i, WeaponName);
  232. }
  233. format(clientMsg, sizeof(clientMsg), "%s{007BD0}Cash:{FFFFFF} %d\n%s", clientMsg, itemSafeData[safe][cash], weapstr); // Add safe + weapon contents strings together
  234. if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pDev] >= 1) {
  235. format(clientMsg, sizeof(clientMsg), "%s\n** %d'S SAFE CONTENTS (sqlID: %d | arrayID: %d) **", clientMsg, itemSafeData[safe][owner], itemSafeData[safe][sqlID], safe);
  236. }
  237. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, titlestr, clientMsg, "Okay", "");
  238. return 1;
  239. }
  240. CMD:safesystem(playerid, params[]) // cmd name will be changed soon
  241. {
  242. new safe = -1;
  243. for(new i = 0; i < MAX_SAFES; i++)
  244. {
  245. if(IsPlayerInRangeOfPoint(playerid, 5.0, itemSafeData[i][posX], itemSafeData[i][posY], itemSafeData[i][posZ]))
  246. {
  247. if((GetPlayerVirtualWorld(playerid) == itemSafeData[i][virtualWorld]) && (GetPlayerInterior(playerid) == itemSafeData[i][interior]))
  248. {
  249. safe = i;
  250. }
  251. }
  252. }
  253. if(safe == -1) return SendClientMessage(playerid, COLOR_GRAD1, "You are not within range of a safe!");
  254. // We'll let admins use the safes to remove items etc.
  255. if( (itemSafeData[safe][owner] != PlayerInfo[playerid][pID]) && (PlayerInfo[playerid][pAdmin] < 4) ) return SendClientMessage(playerid, COLOR_GREY, "You do not have access to that safe!");
  256. new sec[24], thing[24], amount[24], str[128];
  257. if(sscanf(params, "s[24]s[24]s[24]", sec, thing, amount)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /safe [put/get] [mats/weapon/meth/cocaine/cannabis/cash] [amount/weapon slot]");
  258. {
  259. if(strcmp(sec, "put", true) == 0)
  260. {
  261. // put mats
  262. if(strcmp(thing, "mats", true) == 0)
  263. {
  264. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  265. if(PlayerInfo[playerid][pMats] < strval(amount)) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much materials.");
  266. if(strval(amount) < 1 || strval(amount) > 50000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 50000.");
  267. if(itemSafeData[safe][materials] + strval(amount) > 100000) return SendClientMessage(playerid, COLOR_GREY, "The safe can't hold more than 100,000 materials.");
  268. PlayerInfo[playerid][pMats] -= strval(amount);
  269. itemSafeData[safe][materials] += strval(amount);
  270. SaveSafe(safe);
  271. format(str, sizeof(str), "* %s deposits materials into their safe.", PlayerICName(playerid));
  272. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  273. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  274. return 1;
  275. }
  276. // put cannabis
  277. if(strcmp(thing, "cannabis", true) == 0)
  278. {
  279. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  280. if(PlayerInfo[playerid][pCannabis] < strval(amount)) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much cannabis.");
  281. if(strval(amount) < 1 || strval(amount) > 1000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 1000.");
  282. if(itemSafeData[safe][cannabis] + strval(amount) > 1000) return SendClientMessage(playerid, COLOR_GREY, "The safe can't hold more than 1000 cannabis.");
  283. PlayerInfo[playerid][pCannabis] -= strval(amount);
  284. itemSafeData[safe][cannabis] += strval(amount);
  285. SaveSafe(safe);
  286. format(str, sizeof(str), "* %s deposits some pot into a safe.", PlayerICName(playerid));
  287. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  288. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  289. return 1;
  290. }
  291. // put meth
  292. if(strcmp(thing, "meth", true) == 0)
  293. {
  294. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  295. if(PlayerInfo[playerid][pMeth] < strval(amount)) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much meth.");
  296. if(strval(amount) < 1 || strval(amount) > 1000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 1000.");
  297. if(itemSafeData[safe][meth] + strval(amount) > 1000) return SendClientMessage(playerid, COLOR_GREY, "The safe can't hold more than 1000 meth.");
  298. PlayerInfo[playerid][pMeth] -= strval(amount);
  299. itemSafeData[safe][meth] += strval(amount);
  300. SaveSafe(safe);
  301. format(str, sizeof(str), "* %s deposits some pot into a safe.", PlayerICName(playerid));
  302. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  303. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  304. return 1;
  305. }
  306. // put cocaine
  307. if(strcmp(thing, "cocaine", true) == 0)
  308. {
  309. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  310. if(PlayerInfo[playerid][pCocaine] < strval(amount)) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much cocaine.");
  311. if(strval(amount) < 1 || strval(amount) > 1000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 1000.");
  312. if(itemSafeData[safe][cocaine] + strval(amount) > 1000) return SendClientMessage(playerid, COLOR_GREY, "The safe can't hold more than 1000 cocaine.");
  313. PlayerInfo[playerid][pCocaine] -= strval(amount);
  314. itemSafeData[safe][cocaine] += strval(amount);
  315. SaveSafe(safe);
  316. format(str, sizeof(str), "* %s deposits some cocaine into a safe.", PlayerICName(playerid));
  317. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  318. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  319. return 1;
  320. }
  321. if(strcmp(thing, "weapon", true) == 0)
  322. {
  323. if(strval(amount) < 0 || strval(amount) > 9) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /safe put weapon [0-9]");
  324. if(weaponSafeData[safe][strval(amount)] != 0) return SendClientMessage(playerid, COLOR_GREY, "You already have a weapon stored in that slot.");
  325. if(GetPlayerWeapon(playerid) == 0) return SendClientMessage(playerid, COLOR_GREY, "You are not holding a weapon.");
  326. if(HaveAdminWeapon(playerid, GetPlayerWeapon(playerid)) == GetPlayerWeapon(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can not store admin weapons.");
  327. new weaponName[64];
  328. GetWeaponName(GetPlayerWeapon(playerid), weaponName, sizeof(weaponName));
  329. TakePlayerWeapon(playerid, GetPlayerWeapon(playerid));
  330. weaponSafeData[safe][strval(amount)] = GetPlayerWeapon(playerid);
  331. format(safescript, sizeof safescript, "* %s places a %s in the safe.", PlayerICName(playerid), weaponName);
  332. ProxDetector(10.0, playerid, safescript, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  333. printf("%s has %s a %s in slot %s", PlayerName(playerid), sec, weaponName, amount); // log what the player is doing
  334. return 1;
  335. }
  336. }
  337. if(strcmp(sec, "get", true) == 0)
  338. {
  339. if(strcmp(thing, "mats", true) == 0)
  340. {
  341. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  342. if(strval(amount) > itemSafeData[safe][materials]) return SendClientMessage(playerid, COLOR_GREY, "The safe doesn't have that much materials.");
  343. if(strval(amount) < 1 || strval(amount) > 50000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 50000.");
  344. PlayerInfo[playerid][pMats] += strval(amount);
  345. itemSafeData[safe][materials] -= strval(amount);
  346. SaveSafe(safe);
  347. format(str, sizeof(str), "* %s takes some materials from a safe.", PlayerICName(playerid));
  348. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  349. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  350. return 1;
  351. }
  352. // fget pot
  353. if(strcmp(thing, "cannabis", true) == 0)
  354. {
  355. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  356. if(strval(amount) > itemSafeData[safe][cannabis]) return SendClientMessage(playerid, COLOR_GREY, "Family safe doesn't have that much cannabis.");
  357. if(strval(amount) < 1 || strval(amount) > 50) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 50.");
  358. if(strval(amount) + PlayerInfo[playerid][pCannabis] > 50) return SendClientMessage(playerid, COLOR_GREY, "You can only hold a max of 50 cannabis.");
  359. PlayerInfo[playerid][pCannabis] += strval(amount);
  360. itemSafeData[safe][cannabis] -= strval(amount);
  361. SaveSafe(safe);
  362. format(str, sizeof(str), "* %s takes some pot from a safe.", PlayerICName(playerid));
  363. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  364. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  365. return 1;
  366. }
  367. // fget crack
  368. if(strcmp(thing, "cocaine", true) == 0)
  369. {
  370. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  371. if(strval(amount) > itemSafeData[safe][cocaine]) return SendClientMessage(playerid, COLOR_GREY, "Family safe doesn't have that much cocaine.");
  372. if(strval(amount) < 1 || strval(amount) > 25)SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 25.");
  373. if(strval(amount) + PlayerInfo[playerid][pCocaine] > 25) return SendClientMessage(playerid, COLOR_GREY, "You can only hold a max of 25 cocaine.");
  374. PlayerInfo[playerid][pCocaine] += strval(amount);
  375. itemSafeData[safe][cocaine] -= strval(amount);
  376. SaveSafe(safe);
  377. format(str, sizeof(str), "* %s takes some crack from a safe.", PlayerICName(playerid));
  378. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  379. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  380. return 1;
  381. }
  382. if(strcmp(thing, "meth", true) == 0)
  383. {
  384. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The amount must be a number.");
  385. if(strval(amount) > itemSafeData[safe][meth]) return SendClientMessage(playerid, COLOR_GREY, "Family safe doesn't have that much meth.");
  386. if(strval(amount) < 1 || strval(amount) > 25)SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 25.");
  387. if(strval(amount) + PlayerInfo[playerid][pMeth] > 25) return SendClientMessage(playerid, COLOR_GREY, "You can only hold a max of 25 meth.");
  388. PlayerInfo[playerid][pMeth] += strval(amount);
  389. itemSafeData[safe][meth] -= strval(amount);
  390. SaveSafe(safe);
  391. format(str, sizeof(str), "* %s takes some crack from a safe.", PlayerICName(playerid));
  392. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  393. printf("%s has %s %s %s", PlayerName(playerid), sec, amount, thing); // log what the player is doing
  394. return 1;
  395. }
  396. if(strcmp(thing, "weapon", true) == 0)
  397. {
  398. if(!IsNumeric(amount)) return SendClientMessage(playerid, COLOR_GREY, "The slot must be a number.");
  399. if(strval(amount) < 0 || strval(amount) > 9) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /safe get weapon [0-9]");
  400. if(PlayerInfo[playerid][pConnectTime] < 2) return SendClientMessage(playerid, COLOR_GREY, "You must play for 2 hours before using a weapon.");
  401. if(weaponSafeData[safe][strval(amount)] == 0) return SendClientMessage(playerid, COLOR_GREY, "You do not have a weapon stored in the safe.");
  402. new WeaponName[32];
  403. GetWeaponName(weaponSafeData[safe][strval(amount)], WeaponName, 32);
  404. format(safescript, sizeof safescript, "* %s takes a %s from the safe.", PlayerICName(playerid), WeaponName);
  405. ProxDetector(10.0, playerid, safescript, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  406. GivePlayerGun(playerid, weaponSafeData[safe][strval(amount)]);
  407. weaponSafeData[safe][strval(amount)] = 0;
  408. printf("%s has taken a %s from slot %d", PlayerName(playerid), WeaponName, strval(amount)); // log what the player is doing
  409. }
  410. }
  411. return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /safe [put/get] [mats/weapon/meth/cocaine/cannabis/cash]");
  412. }
  413. }