Advertisement
Guest User

lockers.pwn

a guest
Jul 18th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.14 KB | None | 0 0
  1. #define MAX_LOCKER_NAME 64
  2.  
  3. new LockerItems[][ESafeSingleItems] = {
  4. {"None","None",ESafeItemType:-1},
  5. {"Cash","Money",ESafeItemType_Money},
  6. {"Pot","Pot",ESafeItemType_Pot},
  7. {"Coke","Coke",ESafeItemType_Coke},
  8. {"Gun","Unused",ESafeItemType_Gun},
  9. {"Meth","Meth",ESafeItemType_Meth},
  10. {"Materials A","MatsA",ESafeItemType_MatsA},
  11. {"Materials B","MatsB",ESafeItemType_MatsB},
  12. {"Materials C","MatsC",ESafeItemType_MatsC},
  13. {"Special Item","SpecialItem",ESafeItemType_SpecialItem}
  14. };
  15.  
  16. enum {
  17. ELockerDialog_GiveTake = ELockers_Base + 1,
  18. ELockerDialog_ModifySlot,
  19. ELockerDialog_Take,
  20. ELockerDialog_StoreChoose,
  21. ELockerDialog_TakeAmount,
  22. ELockerDialog_StoreAmount
  23. }
  24. enum ELockerIconInfo {
  25. ELockerName[MAX_LOCKER_NAME],
  26. Float:ELockerPickupX,
  27. Float:ELockerPickupY,
  28. Float:ELockerPickupZ,
  29. ELockerPickupInt,
  30. ELockerPickupVW,
  31. ELockerPickupID,
  32. Text3D:ELockerText,
  33. };
  34. //todo: mechanic, lawyer, trucker?
  35. new LockerIcons[][ELockerIconInfo] = {
  36. {"Unity Station Locker (( /locker ))",1743.28, -1864.23, 13.57, 0, 0, 0, Text3D:0},
  37. {"Santa Maria Beach Locker (( /locker ))",532.8861, -1812.9851, 6.578125, 0, 0, 0, Text3D:0},
  38. {"East LS Locker (( /locker ))",2368.7751,-1479.0050,23.9779, 0, 0, 0, Text3D:0}
  39. };
  40. #define NUM_LOCKER_SLOTS 7 //update in DB too
  41. lockersOnGameModeInit() {
  42. for(new i=0;i<sizeof(LockerIcons);i++) {
  43. LockerIcons[i][ELockerText] = CreateDynamic3DTextLabel(LockerIcons[i][ELockerName], 0x2BFF00AA, LockerIcons[i][ELockerPickupX], LockerIcons[i][ELockerPickupY], LockerIcons[i][ELockerPickupZ]+1.0, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, LockerIcons[i][ELockerPickupVW], LockerIcons[i][ELockerPickupInt]);
  44. LockerIcons[i][ELockerPickupID] = CreateDynamicPickup(1239, 16, LockerIcons[i][ELockerPickupX], LockerIcons[i][ELockerPickupY], LockerIcons[i][ELockerPickupZ], LockerIcons[i][ELockerPickupVW], LockerIcons[i][ELockerPickupInt]);
  45. }
  46. }
  47. lockersOnCharLogin(playerid) {
  48. checkLockers(playerid);
  49. }
  50. lockersOnPlayerDisconnect(playerid, reason) {
  51. #pragma unused reason
  52. //saveLockers(playerid);
  53. deleteLockerPVars(playerid);
  54. }
  55. YCMD:locker(playerid, params[], help) {
  56. if(help) {
  57. SendClientMessage(playerid, X11_WHITE, "Access your public lockers");
  58. return 1;
  59. }
  60. if(!isAtLockerLocation(playerid)) {
  61. SendClientMessage(playerid, X11_TOMATO_2, "You aren't at the locker point");
  62. return 1;
  63. }
  64. if(isInPaintball(playerid) || IsPlayerInEvent(playerid)) {
  65. SendClientMessage(playerid, X11_TOMATO_2, "You can't do this right now!");
  66. return 1;
  67. }
  68. if(IsOnDuty(playerid)) {
  69. SendClientMessage(playerid, X11_TOMATO_2, "You can't do this on duty!");
  70. return 1;
  71. }
  72. showTypeLockerMenu(playerid);
  73. return 1;
  74. }
  75. isAtLockerLocation(playerid) {
  76. for(new i=0;i<sizeof(LockerIcons);i++) {
  77. if(IsPlayerInRangeOfPoint(playerid, 5.0,LockerIcons[i][ELockerPickupX], LockerIcons[i][ELockerPickupY], LockerIcons[i][ELockerPickupZ])) {
  78. return 1;
  79. }
  80. }
  81. return 0;
  82. }
  83. showTypeLockerMenu(playerid) {
  84. ShowPlayerDialog(playerid, ELockerDialog_GiveTake, DIALOG_STYLE_MSGBOX, "{00BFFF}Locker Menu","What would you like to do with your public locker?", "Store", "Take");
  85. }
  86. lockersOnDialogResp(playerid, dialogid, response, listitem, inputtext[]) {
  87. new msg[128];
  88. new total;
  89. new pvarname[64];
  90. switch(dialogid) {
  91. case ELockerDialog_GiveTake: {
  92. showLockerTakeMenu(playerid,!response);
  93. }
  94. case ELockerDialog_Take: {
  95. SetPVarInt(playerid, "ItemIndex", listitem);
  96. if(GetPVarInt(playerid, "LockerTake") != 1) {
  97. if(response) {
  98. showStoreTypeChoose(playerid);
  99. return 1;
  100. }
  101. return 1;
  102. }
  103. if(response) {
  104. format(pvarname, sizeof(pvarname), "Item%dType",listitem);
  105. new index = GetPVarInt(playerid, pvarname);
  106. format(pvarname, sizeof(pvarname), "Item%d",listitem);
  107. total = GetPVarInt(playerid, pvarname);
  108. if(index == 0) {
  109. SendClientMessage(playerid, X11_TOMATO_2, "Theres nothing in this slot!");
  110. return 1;
  111. } else if(index == 4) {
  112. if(IsGunBanned(playerid)) {
  113. SendClientMessage(playerid, X11_TOMATO_2, "You are weapon banned!");
  114. return 1;
  115. }
  116. new gun, ammo, slot;
  117. decodeWeapon(total, gun, ammo);
  118. slot = GetWeaponSlot(gun);
  119. new curgun, curammo;
  120. GetPlayerWeaponDataEx(playerid, slot, curgun, curammo);
  121. if(curgun != 0) {
  122. SendClientMessage(playerid, X11_TOMATO_2, "You are already holding a weapon in this slot!");
  123. return 1;
  124. }
  125. GivePlayerWeaponEx(playerid, gun, ammo);
  126. SetPVarInt(playerid, pvarname, 0);
  127. format(pvarname, sizeof(pvarname), "Item%dType",listitem);
  128. SetPVarInt(playerid, pvarname, 0);
  129. format(msg, sizeof(msg), "* %s takes something out %s locker.", GetPlayerNameEx(playerid, ENameType_RPName), getPossiveAdjective(playerid));
  130. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  131. SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have successfully taken this item from your locker");
  132. saveLockers(playerid);
  133. return 1;
  134. } else if(index == 9) { //special item
  135. if(HasSpecialItem(playerid)) {
  136. SendClientMessage(playerid, X11_TOMATO_2, "You are already holding a special item!");
  137. return 1;
  138. }
  139. GivePlayerItem(playerid, total);
  140. SetPVarInt(playerid, pvarname, 0);
  141. format(pvarname, sizeof(pvarname), "Item%dType",listitem);
  142. SetPVarInt(playerid, pvarname, 0);
  143. saveLockers(playerid);
  144. return 1;
  145. }
  146. GetItemName(findItemType(index),pvarname, sizeof(pvarname));
  147. SetPVarInt(playerid, "ItemIndex", listitem);
  148. format(msg, sizeof(msg), "Enter how much %s you would like to remove\nYou current have: %d in your locker and %d on hand.",pvarname,total,GetPVarInt(playerid, LockerItems[index][ESafeSItemPVar]));
  149. ShowPlayerDialog(playerid, ELockerDialog_TakeAmount, DIALOG_STYLE_INPUT, "{00BFFF}Locker Menu",msg, "Take", "Cancel");
  150. }
  151. }
  152. case ELockerDialog_TakeAmount: {
  153. if(response) {
  154. total = strval(inputtext);
  155. if(total <= 0) {
  156. SendClientMessage(playerid, X11_TOMATO_2, "Invalid Amount!");
  157. return 1;
  158. }
  159. new index = GetPVarInt(playerid, "ItemIndex");
  160. format(pvarname, sizeof(pvarname), "Item%d",index);
  161. if(GetPVarInt(playerid, pvarname) < total) {
  162. SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough!");
  163. return 1;
  164. } else {
  165. new lockertotal;
  166. format(pvarname, sizeof(pvarname), "Item%d", index);
  167. lockertotal = GetPVarInt(playerid, pvarname);
  168. format(pvarname, sizeof(pvarname), "Item%dType", index);
  169. new type = GetPVarInt(playerid, pvarname);
  170. if((lockertotal - total) < 1) {
  171. DeletePVar(playerid, pvarname);
  172. format(pvarname, sizeof(pvarname), "Item%d", index);
  173. DeletePVar(playerid, pvarname);
  174. } else {
  175. format(pvarname, sizeof(pvarname), "Item%d", index);
  176. SetPVarInt(playerid, pvarname, lockertotal - total);
  177. }
  178. new amount = GetPVarInt(playerid, LockerItems[type][ESafeSItemPVar]);
  179. amount += total;
  180. SetPVarInt(playerid, LockerItems[type][ESafeSItemPVar], amount);
  181. GiveMoneyEx(playerid, 0); //sync money
  182. format(msg, sizeof(msg), "* %s takes something out %s locker.", GetPlayerNameEx(playerid, ENameType_RPName), getPossiveAdjective(playerid));
  183. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  184. SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have successfully taken this item from your locker");
  185. saveLockers(playerid);
  186. }
  187. }
  188. DeletePVar(playerid, "ItemIndex");
  189. }
  190. case ELockerDialog_StoreChoose: {
  191. if(!response) return 1;
  192. listitem++;
  193. format(pvarname, sizeof(pvarname), "Item%dType",GetPVarInt(playerid, "ItemIndex"));
  194. SetPVarInt(playerid, "StorageSlot", listitem);
  195. new index = GetPVarInt(playerid, pvarname);
  196. if((listitem != index && index != 0) || LockerItems[index][ESafeSType] == ESafeItemType_Gun || LockerItems[index][ESafeSType] == ESafeItemType_SpecialItem) {
  197. SendClientMessage(playerid, X11_TOMATO_2, "You can't store this here!");
  198. return 1;
  199. }
  200. if(LockerItems[listitem][ESafeSType] == ESafeItemType_Gun) {
  201. if(IsGunBanned(playerid)) {
  202. SendClientMessage(playerid, X11_TOMATO_2, "You are weapon banned!");
  203. return 1;
  204. }
  205. new gun, ammo, gslot;
  206. gslot = GetWeaponSlot(GetPlayerWeaponEx(playerid));
  207. GetPlayerWeaponDataEx(playerid, gslot ,gun, ammo);
  208. gslot = encodeWeapon(gun, ammo);
  209. new itemindex = GetPVarInt(playerid, "ItemIndex");
  210. format(pvarname, sizeof(pvarname), "Item%d", itemindex);
  211. SetPVarInt(playerid, pvarname, gslot);
  212. format(pvarname, sizeof(pvarname), "Item%dType", itemindex);
  213. SetPVarInt(playerid, pvarname, listitem);
  214. RemovePlayerWeapon(playerid, gun);
  215. format(msg, sizeof(msg), "* %s puts something into %s locker.", GetPlayerNameEx(playerid, ENameType_RPName), getPossiveAdjective(playerid));
  216. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  217. SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have successfully stored this item in your locker");
  218. saveLockers(playerid);
  219. return 1;
  220. } else if(LockerItems[listitem][ESafeSType] == ESafeItemType_SpecialItem) {
  221. if(!HasSpecialItem(playerid)) {
  222. SendClientMessage(playerid, X11_TOMATO_2, "You are not carrying a special item.");
  223. return 1;
  224. }
  225. new itemindex = GetPVarInt(playerid, "ItemIndex");
  226. new item = GetPVarInt(playerid, "SpecialItem");
  227. format(pvarname, sizeof(pvarname), "Item%dType", itemindex);
  228. SetPVarInt(playerid, pvarname, listitem);
  229. format(pvarname, sizeof(pvarname), "Item%d",itemindex);
  230. SetPVarInt(playerid, pvarname, item);
  231. format(msg, sizeof(msg), "* %s puts something into %s locker.", GetPlayerNameEx(playerid, ENameType_RPName), getPossiveAdjective(playerid));
  232. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  233. SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have successfully stored this item in your locker");
  234. RemovePlayerItem(playerid);
  235. saveLockers(playerid);
  236. return 1;
  237. }
  238. GetItemName(findItemType(listitem),pvarname, sizeof(pvarname));
  239. format(msg, sizeof(msg), "Enter how much %s you would like to store\nYou current have: %d in your locker and %d on hand.",pvarname,total,GetPVarInt(playerid, LockerItems[index][ESafeSItemPVar]));
  240. ShowPlayerDialog(playerid, ELockerDialog_StoreAmount, DIALOG_STYLE_INPUT, "{00BFFF}Locker Menu",msg, "Store", "Cancel");
  241. }
  242. case ELockerDialog_StoreAmount: {
  243. total = strval(inputtext);
  244. if(total <= 0) {
  245. SendClientMessage(playerid, X11_TOMATO_2, "Invalid Amount!");
  246. return 1;
  247. }
  248. new slot = GetPVarInt(playerid, "StorageSlot");
  249. if(GetPVarInt(playerid, LockerItems[slot][ESafeSItemPVar]) < total) {
  250. SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough!");
  251. return 1;
  252. }
  253. new lockertotal;
  254. new index = GetPVarInt(playerid, "ItemIndex");
  255. format(pvarname, sizeof(pvarname), "Item%d", index);
  256. lockertotal = GetPVarInt(playerid, pvarname);
  257. SetPVarInt(playerid, pvarname, lockertotal + total);
  258. format(pvarname, sizeof(pvarname), "Item%dType", index);
  259. new curslot = GetPVarInt(playerid, pvarname);
  260. new localtotal = GetPVarInt(playerid, LockerItems[slot][ESafeSItemPVar]);
  261. localtotal -= total;
  262. SetPVarInt(playerid, LockerItems[slot][ESafeSItemPVar], localtotal);
  263. GiveMoneyEx(playerid, 0); //sync money
  264. SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have successfully stored this item from your locker");
  265. if(curslot == 0) {
  266. SetPVarInt(playerid, pvarname, slot);
  267. }
  268. format(msg, sizeof(msg), "* %s puts something into %s locker.", GetPlayerNameEx(playerid, ENameType_RPName), getPossiveAdjective(playerid));
  269. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  270. DeletePVar(playerid, "StorageSlot");
  271. DeletePVar(playerid, "ItemIndex");
  272. saveLockers(playerid);
  273. }
  274. }
  275. return 1;
  276. }
  277. showStoreTypeChoose(playerid) {
  278. dialogstr[0] = 0;
  279. tempstr[0] = 0;
  280. for(new i=1;i<sizeof(LockerItems);i++) {
  281. format(tempstr, sizeof(tempstr), "%s\n",LockerItems[i][ESafeSItemName]);
  282. strcat(dialogstr, tempstr, sizeof(dialogstr));
  283. }
  284. ShowPlayerDialog(playerid, ELockerDialog_StoreChoose, DIALOG_STYLE_LIST, "{00BFFF}Locker Menu",dialogstr, "Take", "Cancel");
  285. }
  286. showLockerTakeMenu(playerid,take) {
  287. dialogstr[0] = 0;
  288. tempstr[0] = 0;
  289. new pvarname[64];
  290. for(new i=0;i<NUM_LOCKER_SLOTS;i++) {
  291. new index,amount;
  292. format(pvarname, sizeof(pvarname), "Item%dType",i);
  293. index = GetPVarInt(playerid, pvarname);
  294. format(pvarname, sizeof(pvarname), "Item%d",i);
  295. amount = GetPVarInt(playerid, pvarname);
  296. if(index == 0) { //none
  297. strcat(dialogstr, "None\n", sizeof(dialogstr));
  298. } else {
  299. new ESafeItemType:type = findItemType(index);
  300. if(type == ESafeItemType_Gun) {
  301. new gun, ammo;
  302. decodeWeapon(amount, gun, ammo);
  303. GetWeaponNameEx(gun, pvarname, sizeof(pvarname));
  304. amount = ammo;
  305. } else {
  306. GetItemName(type,pvarname, sizeof(pvarname));
  307. }
  308. if(type == ESafeItemType_SpecialItem) {
  309. format(tempstr, sizeof(tempstr), "%s - %s\n",pvarname,GetCarryingItemName(amount));
  310. } else {
  311. format(tempstr, sizeof(tempstr), "%s - %s\n",pvarname,getNumberString(amount));
  312. }
  313. strcat(dialogstr, tempstr, sizeof(dialogstr));
  314. }
  315. }
  316. SetPVarInt(playerid, "LockerTake", take);
  317. ShowPlayerDialog(playerid, ELockerDialog_Take, DIALOG_STYLE_LIST, "{00BFFF}Locker Menu",dialogstr, "Take", "Cancel");
  318. }
  319. checkLockers(playerid) {
  320. format(query, sizeof(query), "SELECT 1 FROM `lockers` WHERE `charid` = %d",GetPVarInt(playerid, "CharID"));
  321. mysql_function_query(g_mysql_handle, query, true, "OnCheckLockers", "d",playerid);
  322. }
  323. insertLockers(playerid) {
  324. format(query, sizeof(query), "INSERT INTO `lockers` SET `charid` = %d",GetPVarInt(playerid, "CharID"));
  325. mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
  326. }
  327. forward OnCheckLockers(playerid);
  328. public OnCheckLockers(playerid) {
  329. new rows, fields;
  330. cache_get_data(rows, fields);
  331. if(rows > 0) {
  332. loadLockers(playerid);
  333. } else {
  334. insertLockers(playerid);
  335. }
  336. }
  337. saveLockers(playerid) {
  338. new pvarname[64],pvarname2[64];
  339. format(query, sizeof(query), "UPDATE `lockers` SET ");
  340. for(new i=0;i<NUM_LOCKER_SLOTS;i++) {
  341. format(pvarname, sizeof(pvarname), "Item%dType",i);
  342. format(pvarname2, sizeof(pvarname2), "Item%d",i);
  343. format(tempstr, sizeof(tempstr), "`item%dtype` = %d,`item%d` = %d,",i,GetPVarInt(playerid, pvarname), i, GetPVarInt(playerid, pvarname2));
  344. strcat(query, tempstr, sizeof(query));
  345. }
  346. query[strlen(query)-1] = 0;
  347. format(tempstr, sizeof(tempstr), " WHERE `charid` = %d",GetPVarInt(playerid, "CharID"));
  348. strcat(query, tempstr, sizeof(query));
  349. mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
  350. }
  351. deleteLockerPVars(playerid) {
  352. new pvarname[32];
  353. for(new i=0;i<NUM_LOCKER_SLOTS;i++) {
  354. format(pvarname, sizeof(pvarname), "Item%dType",i);
  355. DeletePVar(playerid, pvarname);
  356. format(pvarname, sizeof(pvarname), "Item%d",i);
  357. DeletePVar(playerid, pvarname);
  358. }
  359. }
  360. /*
  361. forward OnLoadLocker(playerid);
  362. public OnLoadLocker(playerid) {
  363. new id_string[64],pvarname[64];
  364. new i;
  365. new rows, fields;
  366. cache_get_data(rows, fields);
  367. if(rows < 1) {
  368. SendClientMessage(playerid, X11_TOMATO_2, "Error: You don't have a locker table in the database! Contact an admin(preferablly a scripter)");
  369. return 1;
  370. }
  371. for(i=0;i<NUM_LOCKER_SLOTS*2;i+=2) {
  372. cache_get_row(0, i, id_string);
  373. format(pvarname, sizeof(pvarname), "Item%dType",i);
  374. SetPVarInt(playerid, pvarname, strval(id_string));
  375. cache_get_row(0, i+1, id_string);
  376. format(pvarname, sizeof(pvarname), "Item%d",i);
  377. SetPVarInt(playerid, pvarname, strval(id_string));
  378. }
  379. return 1;
  380. }
  381. */
  382. GetItemName(ESafeItemType:item, dst[], dstlen) {
  383. for(new i=0;i<sizeof(LockerItems);i++) {
  384. if(LockerItems[i][ESafeSType] == item) {
  385. format(dst, dstlen, "%s",LockerItems[i][ESafeSItemName]);
  386. return 1;
  387. }
  388. }
  389. return 0;
  390. }
  391. ESafeItemType:findItemType(index) {
  392. if(index < 0 || index > sizeof(LockerItems)) return ESafeItemType:-1;
  393. return LockerItems[index][ESafeSType];
  394. }
  395. loadLockers(playerid) {
  396. query[0] = 0;
  397. tempstr[0] = 0;
  398. format(query, sizeof(query), "SELECT ");
  399. for(new i=0;i<NUM_LOCKER_SLOTS;i++) {
  400. format(tempstr, sizeof(tempstr), "`item%dtype`,`item%d`,",i, i);
  401. strcat(query, tempstr, sizeof(query));
  402. }
  403. query[strlen(query)-1] = 0;
  404. format(tempstr, sizeof(tempstr), " FROM `lockers` WHERE `charid` = %d",GetPVarInt(playerid, "CharID"));
  405. strcat(query, tempstr, sizeof(query));
  406. mysql_function_query(g_mysql_handle, query, true, "OnLoadLockers", "d", playerid);
  407. }
  408. forward OnLoadLockers(playerid);
  409. public OnLoadLockers(playerid) {
  410. new id_string[32];
  411. new pvarname[64];
  412. new x;
  413. for(new i=0;i<NUM_LOCKER_SLOTS*2;i+=2) {
  414. format(pvarname, sizeof(pvarname), "Item%dType",x);
  415. cache_get_row(0, i, id_string);
  416. //printf("PVarName: %s", pvarname);
  417. SetPVarInt(playerid, pvarname, strval(id_string));
  418. cache_get_row(0, i+1, id_string);
  419. format(pvarname, sizeof(pvarname), "Item%d",x);
  420. SetPVarInt(playerid, pvarname, strval(id_string));
  421. //printf("PVarName: %s", pvarname);
  422. x++;
  423. }
  424. }
  425. YCMD:checklocker(playerid, params[], help) {
  426. if(help) {
  427. SendClientMessage(playerid, X11_WHITE, "Displays the contents of a players locker");
  428. return 1;
  429. }
  430. new pvarname[64];
  431. new target;
  432. if(!sscanf(params, "k<playerLookup_acc>",target)) {
  433. if(!IsPlayerConnectEx(target)) {
  434. SendClientMessage(playerid, X11_TOMATO_2, "User not found");
  435. return 1;
  436. }
  437. format(query, sizeof(query), "******* %s's Locker *******",GetPlayerNameEx(target, ENameType_CharName));
  438. SendClientMessage(playerid, X11_WHITE, query);
  439. for(new i=0;i<NUM_LOCKER_SLOTS;i++) {
  440. new index,amount;
  441. format(pvarname, sizeof(pvarname), "Item%dType",i);
  442. index = GetPVarInt(target, pvarname);
  443. format(pvarname, sizeof(pvarname), "Item%d",i);
  444. amount = GetPVarInt(target, pvarname);
  445. if(index == 0) { //none
  446. format(query, sizeof(query), "%d. None",i+1);
  447. } else {
  448. new ESafeItemType:type = findItemType(index);
  449. if(type == ESafeItemType_Gun) {
  450. new gun, ammo;
  451. decodeWeapon(amount, gun, ammo);
  452. GetWeaponNameEx(gun, pvarname, sizeof(pvarname));
  453. amount = ammo;
  454. } else {
  455. GetItemName(type,pvarname, sizeof(pvarname));
  456. }
  457. if(type != ESafeItemType_SpecialItem) {
  458. format(query, sizeof(query), "%d. %s - %s",i+1,pvarname,getNumberString(amount));
  459. } else {
  460. format(query, sizeof(query), "%d. %s - %s",i+1,pvarname,GetCarryingItemName(amount));
  461. }
  462. }
  463. SendClientMessage(playerid, COLOR_LIGHTBLUE, query);
  464. }
  465. } else {
  466. SendClientMessage(playerid, X11_WHITE, "USAGE: /checklocker [playerid/name]");
  467. }
  468. return 1;
  469. }
  470. getPlayerLockerWealth(playerid) {
  471. new value;
  472. new pvarname[64];
  473. for(new i=0;i<NUM_LOCKER_SLOTS;i++) {
  474. new index,amount;
  475. format(pvarname, sizeof(pvarname), "Item%dType",i);
  476. index = GetPVarInt(playerid, pvarname);
  477. format(pvarname, sizeof(pvarname), "Item%d",i);
  478. amount = GetPVarInt(playerid, pvarname);
  479. new ESafeItemType:type = findItemType(index);
  480. if(type == ESafeItemType_Money) {
  481. value += amount;
  482. }
  483. }
  484. return value;
  485. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement