1
0

toys.pwn 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Toy System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. stock CompleteToyTrade(playerid)
  34. {
  35. new string[156],
  36. sellerid = GetPVarInt(playerid, "ttSeller"),
  37. name[24],
  38. toyid = GetPVarInt(sellerid, "ttToy");
  39. for(new i;i<sizeof(HoldingObjectsAll);i++)
  40. {
  41. if(HoldingObjectsAll[i][holdingmodelid] == toyid)
  42. {
  43. format(name, sizeof(name), "(%s)", HoldingObjectsAll[i][holdingmodelname]);
  44. }
  45. }
  46. if(toyid != 0 && (strcmp(name, "None", true) == 0))
  47. {
  48. format(name, sizeof(name), "(ID: %d)", toyid);
  49. }
  50. new icount = GetPlayerToySlots(playerid);
  51. if(!toyCountCheck(playerid))
  52. {
  53. format(string, sizeof(string), "%s has declined the toy offer. (no free toy slots)", GetPlayerNameEx(playerid));
  54. SendClientMessageEx(sellerid, COLOR_GREY, string);
  55. SendClientMessageEx(playerid, COLOR_GREY, "You don't have any free toy slots.");
  56. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttBuyer");
  57. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttCost");
  58. DeletePVar(playerid, "ttSeller");
  59. HideTradeToysGUI(playerid);
  60. return 1;
  61. }
  62. if(GetPlayerCash(playerid) < GetPVarInt(sellerid, "ttCost"))
  63. {
  64. format(string, sizeof(string), "%s has declined the toy offer. (Not enough money)", GetPlayerNameEx(playerid));
  65. SendClientMessageEx(sellerid, COLOR_GREY, string);
  66. SendClientMessageEx(playerid, COLOR_GREY, "You do not have enough money on you.");
  67. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttBuyer");
  68. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttCost");
  69. DeletePVar(playerid, "ttSeller");
  70. HideTradeToysGUI(playerid);
  71. return 1;
  72. }
  73. GivePlayerCash(playerid, -GetPVarInt(sellerid, "ttCost"));
  74. GivePlayerCash(sellerid, GetPVarInt(sellerid, "ttCost"));
  75. for(new i = 0; i < icount; i++)
  76. {
  77. if(!PlayerToyInfo[playerid][i][ptModelID])
  78. {
  79. PlayerToyInfo[playerid][i][ptModelID] = toyid;
  80. PlayerToyInfo[playerid][i][ptBone] = 1; // Doesn't need to be accurate, you can let the player choose.
  81. PlayerToyInfo[playerid][i][ptPosX] = 1.0;
  82. PlayerToyInfo[playerid][i][ptPosY] = 1.0;
  83. PlayerToyInfo[playerid][i][ptPosZ] = 1.0;
  84. PlayerToyInfo[playerid][i][ptRotX] = 0.0;
  85. PlayerToyInfo[playerid][i][ptRotY] = 0.0;
  86. PlayerToyInfo[playerid][i][ptRotZ] = 0.0;
  87. PlayerToyInfo[playerid][i][ptScaleX] = 1.0;
  88. PlayerToyInfo[playerid][i][ptScaleY] = 1.0;
  89. PlayerToyInfo[playerid][i][ptScaleZ] = 1.0;
  90. PlayerToyInfo[playerid][i][ptTradable] = 1;
  91. if(PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptSpecial] == 1)
  92. {
  93. PlayerToyInfo[playerid][i][ptSpecial] = 0;
  94. }
  95. else
  96. PlayerToyInfo[playerid][i][ptSpecial] = PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptSpecial];
  97. if(PlayerToyInfo[playerid][i][ptSpecial] == 2)
  98. {
  99. PlayerToyInfo[playerid][i][ptBone] = 2;
  100. PlayerToyInfo[playerid][i][ptPosX] = 0.07;
  101. PlayerToyInfo[playerid][i][ptPosY] = 0.0;
  102. PlayerToyInfo[playerid][i][ptPosZ] = 0.0;
  103. PlayerToyInfo[playerid][i][ptRotX] = 88.0;
  104. PlayerToyInfo[playerid][i][ptRotY] = 75.0;
  105. PlayerToyInfo[playerid][i][ptRotZ] = 0.0;
  106. PlayerToyInfo[playerid][i][ptScaleX] = 0.0;
  107. PlayerToyInfo[playerid][i][ptScaleY] = 0.0;
  108. PlayerToyInfo[playerid][i][ptScaleZ] = 0.0;
  109. }
  110. // Seller
  111. mysql_format(MainPipeline, string, sizeof(string), "DELETE FROM `toys` WHERE `id` = '%d'", PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptID]);
  112. mysql_tquery(MainPipeline, string, "OnQueryFinish", "ii", SENDDATA_THREAD, sellerid);
  113. g_mysql_NewToy(playerid, i);
  114. break;
  115. }
  116. }
  117. PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptID] = 0;
  118. PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptModelID] = 0;
  119. PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptBone] = 0;
  120. PlayerToyInfo[sellerid][GetPVarInt(sellerid, "ttToySlot")][ptSpecial] = 0;
  121. for(new i; i < 10; i++)
  122. {
  123. if(PlayerHoldingObject[sellerid][i] == GetPVarInt(sellerid, "ttToySlot"))
  124. {
  125. if(IsPlayerAttachedObjectSlotUsed(sellerid, i))
  126. {
  127. RemovePlayerAttachedObject(sellerid, i);
  128. PlayerHoldingObject[sellerid][i] = 0;
  129. break;
  130. }
  131. }
  132. }
  133. if(PlayerInfo[sellerid][pBackpack] > 0 && PlayerInfo[sellerid][pBEquipped])
  134. {
  135. switch(PlayerInfo[sellerid][pBackpack])
  136. {
  137. case 1: // Small
  138. {
  139. if(PlayerHoldingObject[sellerid][9] != 0 || IsPlayerAttachedObjectSlotUsed(sellerid, 9))
  140. RemovePlayerAttachedObject(sellerid, 9), PlayerHoldingObject[sellerid][9] = 0;
  141. SetPlayerAttachedObject(sellerid, 9, 371, 1, -0.002, -0.140999, -0.01, 8.69999, 88.8, -8.79993, 1.11, 0.963);
  142. }
  143. case 2: // Med
  144. {
  145. if(PlayerHoldingObject[sellerid][9] != 0 || IsPlayerAttachedObjectSlotUsed(sellerid, 9))
  146. RemovePlayerAttachedObject(sellerid, 9), PlayerHoldingObject[sellerid][9] = 0;
  147. SetPlayerAttachedObject(sellerid, 9, 371, 1, -0.002, -0.140999, -0.01, 8.69999, 88.8, -8.79993, 1.11, 0.963);
  148. }
  149. case 3: // Large
  150. {
  151. if(PlayerHoldingObject[sellerid][9] != 0 || IsPlayerAttachedObjectSlotUsed(sellerid, 9))
  152. RemovePlayerAttachedObject(sellerid, 9), PlayerHoldingObject[sellerid][9] = 0;
  153. SetPlayerAttachedObject(sellerid, 9, 3026, 1, -0.254999, -0.109, -0.022999, 10.6, -1.20002, 3.4, 1.265, 1.242, 1.062);
  154. }
  155. }
  156. }
  157. OnPlayerStatsUpdate(playerid);
  158. OnPlayerStatsUpdate(sellerid);
  159. format(string, sizeof(string), "%s has accepted your offer and purchased your toy for $%s. %s", GetPlayerNameEx(playerid), number_format(GetPVarInt(sellerid, "ttCost")), name);
  160. SendClientMessageEx(sellerid, COLOR_LIGHTBLUE, string);
  161. format(string, sizeof(string), "You have accepted %s's offer and purchased the toy for $%s. %s", GetPlayerNameEx(sellerid), number_format(GetPVarInt(sellerid, "ttCost")), name);
  162. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  163. format(string, sizeof(string), "[S %s(%d)][IP %s][B %s(%d)][IP %s][P $%s][T: %s(%d)]", GetPlayerNameEx(sellerid), GetPlayerSQLId(sellerid), GetPlayerIpEx(sellerid),
  164. GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(GetPVarInt(sellerid, "ttCost")), name, toyid);
  165. Log("logs/toys.log", string);
  166. format(szMiscArray, sizeof(szMiscArray), "[TOYSALE][$%s] %s(%d) sold toy %s(%d) to %s(%d)", number_format(GetPVarInt(sellerid, "ttCost")), GetPlayerNameEx(playerid), playerid, name, toyid, GetPlayerNameEx(sellerid), sellerid);
  167. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  168. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttSeller");
  169. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttBuyer");
  170. DeletePVar(GetPVarInt(playerid, "ttSeller"), "ttCost");
  171. DeletePVar(playerid, "ttSeller");
  172. HideTradeToysGUI(playerid);
  173. return 1;
  174. }
  175. stock ShowEditMenu(playerid)
  176. {
  177. new
  178. iIndex = GetPVarInt(playerid, "ToySlot");
  179. new toys = 99999;
  180. for(new i; i < 10; i++)
  181. {
  182. if(PlayerHoldingObject[playerid][i] == iIndex + 1)
  183. {
  184. toys = i;
  185. if(IsPlayerAttachedObjectSlotUsed(playerid, toys))
  186. {
  187. PlayerHoldingObject[playerid][i] = 0;
  188. if(!PlayerInfo[playerid][pBEquipped]) RemovePlayerAttachedObject(playerid, toys);
  189. }
  190. break;
  191. }
  192. }
  193. if(PlayerToyInfo[playerid][iIndex][ptScaleX] == 0) {
  194. PlayerToyInfo[playerid][iIndex][ptScaleX] = 1.0;
  195. PlayerToyInfo[playerid][iIndex][ptScaleY] = 1.0;
  196. PlayerToyInfo[playerid][iIndex][ptScaleZ] = 1.0;
  197. }
  198. if(IsPlayerInAnyVehicle(playerid) && PlayerToyInfo[playerid][iIndex][ptSpecial] == 2)
  199. return ShowPlayerDialogEx(playerid, 0, DIALOG_STYLE_MSGBOX, "Edit your toy", "You cannot edit toys while you are inside a vehicle!", "Okay", "");
  200. new toycount = GetFreeToySlot(playerid);
  201. if(toycount == -1) return SendClientMessageEx(playerid, COLOR_GRAD1, "You currently have 10 objects attached, please deattach an object.");
  202. if(toycount == 9 && PlayerInfo[playerid][pBEquipped]) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot attach an object to slot 10 since you have a backpack equipped.");
  203. PlayerHoldingObject[playerid][toycount] = iIndex;
  204. SetPlayerAttachedObject(playerid, toycount, PlayerToyInfo[playerid][iIndex][ptModelID],
  205. PlayerToyInfo[playerid][iIndex][ptBone], PlayerToyInfo[playerid][iIndex][ptPosX],
  206. PlayerToyInfo[playerid][iIndex][ptPosY], PlayerToyInfo[playerid][iIndex][ptPosZ],
  207. PlayerToyInfo[playerid][iIndex][ptRotX], PlayerToyInfo[playerid][iIndex][ptRotY],
  208. PlayerToyInfo[playerid][iIndex][ptRotZ], PlayerToyInfo[playerid][iIndex][ptScaleX],
  209. PlayerToyInfo[playerid][iIndex][ptScaleY], PlayerToyInfo[playerid][iIndex][ptScaleZ]);
  210. new stringg[128];
  211. format(stringg, sizeof(stringg), "Bone (%s)\nOffset\nToggle Auto-Attach", HoldingBones[PlayerToyInfo[playerid][iIndex][ptBone]]);
  212. ShowPlayerDialogEx(playerid, EDITTOYS2, DIALOG_STYLE_LIST, "Toy Menu: Edit", stringg, "Select", "Cancel");
  213. return 1;
  214. }
  215. stock FindFreeAttachedObjectSlot(playerid)
  216. {
  217. new index;
  218. while (index < MAX_PLAYER_ATTACHED_OBJECTS && IsPlayerAttachedObjectSlotUsed(playerid, index))
  219. {
  220. index++;
  221. }
  222. if (index == MAX_PLAYER_ATTACHED_OBJECTS) return -1;
  223. return index;
  224. }
  225. toyCountCheck(playerid) {
  226. new
  227. iCount = GetPlayerToyCount(playerid),
  228. special = GetSpecialPlayerToyCount(playerid);
  229. if(iCount >= 10 + PlayerInfo[playerid][pToySlot] + special) return 0;
  230. return 1;
  231. }
  232. GetPlayerToyCount(playerid)
  233. {
  234. new toys = 0;
  235. for(new i = 0; i < MAX_PLAYERTOYS; i++) if(PlayerToyInfo[playerid][i][ptModelID]) ++toys;
  236. return toys;
  237. }
  238. GetSpecialPlayerToyCount(playerid)
  239. {
  240. new toys = 0;
  241. for(new i = 0; i < MAX_PLAYERTOYS; i++) if(PlayerToyInfo[playerid][i][ptSpecial] != 0) ++toys;
  242. return toys;
  243. }
  244. GetSpecialPlayerToyCountEx(playerid, special)
  245. {
  246. new toys = 0;
  247. for(new i = 0; i < MAX_PLAYERTOYS; i++) if(PlayerToyInfo[playerid][i][ptSpecial] == special) ++toys;
  248. return toys;
  249. }
  250. /* GetSpecialFuncPlayerToyCount(playerid)
  251. {
  252. new toys = 0;
  253. for(new i = 0; i < MAX_PLAYERTOYS; i++) if(PlayerToyInfo[playerid][i][ptSpecial] > 1) ++toys;
  254. return toys;
  255. } */
  256. GetFreeToySlot(playerid)
  257. {
  258. for(new i = 0; i < 10; i++) {
  259. if(PlayerHoldingObject[playerid][i] == 0) {
  260. return i;
  261. }
  262. }
  263. return -1;
  264. }
  265. GetPlayerToySlots(playerid)
  266. {
  267. new special = GetSpecialPlayerToyCount(playerid);
  268. return PlayerInfo[playerid][pToySlot] + 10 + special;
  269. }
  270. AttachToy(playerid, toyid, msg = 1)
  271. {
  272. new toycount = GetFreeToySlot(playerid);
  273. if(toycount == -1)
  274. {
  275. if(msg) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot attach more than 10 objects.");
  276. else return 1;
  277. }
  278. if(toycount == 9 && PlayerInfo[playerid][pBEquipped])
  279. {
  280. if(msg) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot attach an object to slot 10 since you have a backpack equipped.");
  281. else return 1;
  282. }
  283. if(PlayerToyInfo[playerid][toyid][ptScaleX] == 0) {
  284. PlayerToyInfo[playerid][toyid][ptScaleX] = 1.0;
  285. PlayerToyInfo[playerid][toyid][ptScaleY] = 1.0;
  286. PlayerToyInfo[playerid][toyid][ptScaleZ] = 1.0;
  287. }
  288. new name[24];
  289. format(name, sizeof(name), "None");
  290. for(new i; i < sizeof(HoldingObjectsAll); i++)
  291. {
  292. if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][toyid][ptModelID])
  293. {
  294. format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
  295. }
  296. }
  297. if(msg)
  298. {
  299. new string[128];
  300. format(string, sizeof(string), "Successfully attached %s (Bone: %s) (Slot: %d)", name, HoldingBones[PlayerToyInfo[playerid][toyid][ptBone]], toyid);
  301. SendClientMessageEx(playerid, COLOR_RED, string);
  302. }
  303. PlayerHoldingObject[playerid][toycount] = toyid;
  304. SetPlayerAttachedObject(playerid, toycount, PlayerToyInfo[playerid][toyid][ptModelID], PlayerToyInfo[playerid][toyid][ptBone], PlayerToyInfo[playerid][toyid][ptPosX], PlayerToyInfo[playerid][toyid][ptPosY], PlayerToyInfo[playerid][toyid][ptPosZ],
  305. PlayerToyInfo[playerid][toyid][ptRotX], PlayerToyInfo[playerid][toyid][ptRotY], PlayerToyInfo[playerid][toyid][ptRotZ], PlayerToyInfo[playerid][toyid][ptScaleX], PlayerToyInfo[playerid][toyid][ptScaleY], PlayerToyInfo[playerid][toyid][ptScaleZ]);
  306. return 1;
  307. }
  308. stock player_remove_vip_toys(iTargetID)
  309. {
  310. if(PlayerInfo[iTargetID][pDonateRank] >= 3) return 1;
  311. else for(new iToyIter; iToyIter < MAX_PLAYER_ATTACHED_OBJECTS; ++iToyIter) {
  312. for(new LoopRapist; LoopRapist < sizeof(HoldingObjectsCop); ++LoopRapist) {
  313. if(HoldingObjectsCop[LoopRapist][holdingmodelid] == PlayerToyInfo[iTargetID][iToyIter][ptModelID]) {
  314. PlayerToyInfo[iTargetID][iToyIter][ptModelID] = 0;
  315. PlayerToyInfo[iTargetID][iToyIter][ptBone] = 0;
  316. PlayerToyInfo[iTargetID][iToyIter][ptPosX] = 0.0;
  317. PlayerToyInfo[iTargetID][iToyIter][ptPosY] = 0.0;
  318. PlayerToyInfo[iTargetID][iToyIter][ptPosZ] = 0.0;
  319. PlayerToyInfo[iTargetID][iToyIter][ptPosX] = 0.0;
  320. PlayerToyInfo[iTargetID][iToyIter][ptPosY] = 0.0;
  321. PlayerToyInfo[iTargetID][iToyIter][ptPosZ] = 0.0;
  322. if(IsPlayerAttachedObjectSlotUsed(iTargetID, iToyIter)) RemovePlayerAttachedObject(iTargetID, iToyIter);
  323. g_mysql_SaveToys(iTargetID, iToyIter);
  324. }
  325. }
  326. }
  327. SendClientMessageEx(iTargetID, COLOR_WHITE, "All accessories/toys that were property of your former employer have been removed.");
  328. return 1;
  329. }
  330. CMD:shopvest(playerid, params[])
  331. {
  332. if (PlayerInfo[playerid][pShopTech] < 1 && PlayerInfo[playerid][pAdmin] < 1338)
  333. {
  334. SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
  335. return 1;
  336. }
  337. new string[128], giveplayerid, slot, invoice[64];
  338. if(sscanf(params, "uds[64]", giveplayerid, slot, invoice)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /shopvest [player] [slot(0-9)] [invoice #]");
  339. PlayerToyInfo[giveplayerid][slot][ptModelID] = 19142;
  340. PlayerToyInfo[giveplayerid][slot][ptBone] = 1;
  341. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  342. g_mysql_NewToy(giveplayerid, slot);
  343. format(string, sizeof(string), "You have been given a police vest in slot %d, use /toys to manage it", slot);
  344. SendClientMessageEx(giveplayerid, COLOR_LIGHTGREEN, string);
  345. format(string, sizeof(string), "You have given %s a police vest in slot %d", GetPlayerNameEx(giveplayerid), slot);
  346. SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
  347. format(string, sizeof(string), "[SHOPVEST] %s has given %s(%d) a police vest toy - Invoice %s", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), invoice);
  348. Log("logs/shoplog.log", string);
  349. g_mysql_SaveToys(giveplayerid, slot);
  350. return 1;
  351. }
  352. CMD:listtoys(playerid, params[]) {
  353. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1) {
  354. new giveplayerid, string[64];
  355. szMiscArray[0] = 0;
  356. if(sscanf(params, "u", giveplayerid)) {
  357. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /listtoys [player]");
  358. }
  359. else if(IsPlayerConnected(giveplayerid))
  360. {
  361. new icount = GetPlayerToySlots(giveplayerid);
  362. for(new x;x<icount;x++)
  363. {
  364. new name[24] = "None";
  365. for(new i;i<sizeof(HoldingObjectsAll);i++)
  366. {
  367. if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[giveplayerid][x][ptModelID])
  368. {
  369. format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
  370. break;
  371. }
  372. }
  373. if(PlayerToyInfo[giveplayerid][x][ptModelID] != 0 && (strcmp(name, "None", true) == 0))
  374. {
  375. format(name, sizeof(name), "ID: %d", PlayerToyInfo[giveplayerid][x][ptModelID]);
  376. }
  377. format(szMiscArray, sizeof(szMiscArray), "%s(%d) %s (Bone: %s%s)\n", szMiscArray, x, name, HoldingBones[PlayerToyInfo[giveplayerid][x][ptBone]], (PlayerToyInfo[giveplayerid][x][ptSpecial] > 1) ? (", Special") : (""));
  378. }
  379. format(string, sizeof(string), "Listing %s's Toys - Select a Slot", GetPlayerNameEx(giveplayerid));
  380. ShowPlayerDialogEx(playerid, LISTTOYS_DELETETOY, DIALOG_STYLE_LIST, string, szMiscArray, "Delete", "Cancel");
  381. SetPVarInt(playerid, "listtoys_giveplayerid", giveplayerid);
  382. }
  383. else SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
  384. }
  385. return 1;
  386. }
  387. CMD:shoplaser(playerid, params[])
  388. {
  389. if (PlayerInfo[playerid][pShopTech] < 1 && PlayerInfo[playerid][pAdmin] < 1338)
  390. {
  391. SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
  392. return 1;
  393. }
  394. new string[128], giveplayerid, slot, color[32], invoice[64];
  395. if(sscanf(params, "udss[64]", giveplayerid, slot, color, invoice)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /shoplaser [player] [slot(0-9)] [red/green/orange/yellow/pink/blue] [invoice #]");
  396. if(strcmp(color,"red",true) == 0)
  397. {
  398. PlayerToyInfo[giveplayerid][slot][ptModelID] = 18643;
  399. PlayerToyInfo[giveplayerid][slot][ptBone] = 6;
  400. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  401. g_mysql_NewToy(giveplayerid, slot);
  402. }
  403. else if(strcmp(color,"green",true) == 0)
  404. {
  405. PlayerToyInfo[giveplayerid][slot][ptModelID] = 19083;
  406. PlayerToyInfo[giveplayerid][slot][ptBone] = 6;
  407. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  408. g_mysql_NewToy(giveplayerid, slot);
  409. }
  410. else if(strcmp(color,"orange",true) == 0)
  411. {
  412. PlayerToyInfo[giveplayerid][slot][ptModelID] = 19082;
  413. PlayerToyInfo[giveplayerid][slot][ptBone] = 6;
  414. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  415. g_mysql_NewToy(giveplayerid, slot);
  416. }
  417. else if(strcmp(color,"yellow",true) == 0)
  418. {
  419. PlayerToyInfo[giveplayerid][slot][ptModelID] = 19084;
  420. PlayerToyInfo[giveplayerid][slot][ptBone] = 6;
  421. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  422. g_mysql_NewToy(giveplayerid, slot);
  423. }
  424. else if(strcmp(color,"pink",true) == 0)
  425. {
  426. PlayerToyInfo[giveplayerid][slot][ptModelID] = 19081;
  427. PlayerToyInfo[giveplayerid][slot][ptBone] = 6;
  428. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  429. g_mysql_NewToy(giveplayerid, slot);
  430. }
  431. else if(strcmp(color,"blue",true) == 0)
  432. {
  433. PlayerToyInfo[giveplayerid][slot][ptModelID] = 19080;
  434. PlayerToyInfo[giveplayerid][slot][ptBone] = 6;
  435. PlayerToyInfo[giveplayerid][slot][ptTradable] = 1;
  436. g_mysql_NewToy(giveplayerid, slot);
  437. }
  438. format(string, sizeof(string), "You have been given a %s laser in slot %d, use /toys to manage it", color, slot);
  439. SendClientMessageEx(giveplayerid, COLOR_LIGHTGREEN, string);
  440. format(string, sizeof(string), "You have given %s a %s laser in slot %d", GetPlayerNameEx(giveplayerid), color, slot);
  441. SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
  442. format(string, sizeof(string), "[SHOPLASER] %s has given %s(%d) a laser toy - Invoice %s", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), invoice);
  443. Log("logs/shoplog.log", string);
  444. g_mysql_SaveToys(giveplayerid, slot);
  445. return 1;
  446. }
  447. CMD:giveobject(playerid, params[])
  448. {
  449. if(PlayerInfo[playerid][pAdmin] >= 4)
  450. {
  451. new giveplayerid, object;
  452. if(sscanf(params, "ud", giveplayerid, object)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /giveobject [player] [object]");
  453. if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified");
  454. szMiscArray[0] = 0;
  455. SetPVarInt(playerid, "giveplayeridtoy", giveplayerid);
  456. SetPVarInt(playerid, "toyid", object);
  457. new icount = GetPlayerToySlots(giveplayerid);
  458. for(new x;x<icount;x++)
  459. {
  460. new name[24];
  461. format(name, sizeof(name), "None");
  462. for(new i;i<sizeof(HoldingObjectsAll);i++)
  463. {
  464. if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[giveplayerid][x][ptModelID])
  465. {
  466. format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
  467. }
  468. }
  469. if(PlayerToyInfo[giveplayerid][x][ptModelID] != 0 && (strcmp(name, "None", true) == 0))
  470. {
  471. format(name, sizeof(name), "ID: %d", PlayerToyInfo[giveplayerid][x][ptModelID]);
  472. }
  473. format(szMiscArray, sizeof(szMiscArray), "%s(%d) %s (Bone: %s)\n", szMiscArray, x, name, HoldingBones[PlayerToyInfo[giveplayerid][x][ptBone]]);
  474. }
  475. ShowPlayerDialogEx(playerid, GIVETOY, DIALOG_STYLE_LIST, "Select a slot", szMiscArray, "Select", "Cancel");
  476. }
  477. else {
  478. return SendClientMessageEx(playerid, COLOR_GRAD1, "You're not authorized to use this command!");
  479. }
  480. return 1;
  481. }
  482. CMD:shopobject(playerid, params[])
  483. {
  484. if(PlayerInfo[playerid][pShopTech] >= 1)
  485. {
  486. ShowPlayerDialogEx(playerid, SHOPOBJECT_ORDERID, DIALOG_STYLE_INPUT, "Shop Objects - Order ID", "Please enter the Order ID", "OK", "Cancel");
  487. }
  488. else
  489. {
  490. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  491. return 1;
  492. }
  493. return 1;
  494. }
  495. CMD:buytoys(playerid, params[])
  496. {
  497. if(IsPlayerInRangeOfPoint(playerid, 4, 2787.095947, 2390.353027, 1240.531127) || IsPlayerInRangeOfPoint(playerid, 4, 1774.7533, 1422.6665, 2013.4979) || IsPlayerInRangeOfPoint(playerid, 4, 775.0900, 1742.4900, 1938.3800))
  498. {
  499. if(PlayerInfo[playerid][pDonateRank] < 3)
  500. {
  501. SendClientMessageEx(playerid, COLOR_WHITE, "* You are not a Gold or Platinum VIP!");
  502. }
  503. else
  504. {
  505. ShowPlayerDialogEx( playerid, BUYTOYSGOLD, DIALOG_STYLE_MSGBOX, "Toy Store", "Welcome to the VIP toy store! Here you can buy accessories to attach to your player.\n\nFirst, we will choose a slot to store the toy in.","Continue", "Cancel" );
  506. }
  507. }
  508. else
  509. {
  510. new biz = InBusiness(playerid);
  511. if (biz == INVALID_BUSINESS_ID || Businesses[biz][bType] != BUSINESS_TYPE_CLOTHING) {
  512. SendClientMessageEx(playerid, COLOR_GRAD2, " You are not in a clothing shop!");
  513. return 1;
  514. }
  515. if (Businesses[biz][bInventory] < 1) {
  516. SendClientMessageEx(playerid, COLOR_GRAD2, " Store does not have any clothes!");
  517. return 1;
  518. }
  519. if (!Businesses[biz][bStatus]) {
  520. SendClientMessageEx(playerid, COLOR_GRAD2, " This clothing store is closed!");
  521. return 1;
  522. }
  523. ShowPlayerDialogEx( playerid, BUYTOYS, DIALOG_STYLE_MSGBOX, "Toy Store", "Welcome to the toy store! Here you can buy accessories to attach to your player.\n\nFirst, we will choose a slot to store the toy in.","Continue", "Cancel" );
  524. }
  525. return 1;
  526. }
  527. CMD:toyhelp(playerid, params[])
  528. {
  529. SetPVarInt(playerid, "HelpResultCat0", 9);
  530. Help_ListCat(playerid, DIALOG_HELPCATOTHER1);
  531. return 1;
  532. }
  533. CMD:otoyhelp(playerid, params[])
  534. {
  535. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  536. SendClientMessageEx(playerid, COLOR_WHITE,"*** TOY HELP ***");
  537. SendClientMessageEx(playerid, COLOR_GRAD3,"To buy a toy, go to any clothing store and type {AA3333}/buytoys");
  538. SendClientMessageEx(playerid, COLOR_GRAD3,"To attach/dettach, edit, or delete a toy type {AA3333}/toys");
  539. SendClientMessageEx(playerid, COLOR_GRAD3,"To quickly attach all your toys, type {AA3333}/wat");
  540. SendClientMessageEx(playerid, COLOR_GRAD3,"To quickly detach all your toys, type {AA3333}/dat");
  541. SendClientMessageEx(playerid, COLOR_GRAD3,"To quickly attach a specfic toy slot, type {AA3333}/wt [toyslot]");
  542. SendClientMessageEx(playerid, COLOR_GRAD3,"To quickly detach a specfic toy slot, type {AA3333}/dt [toyslot]");
  543. return 1;
  544. }
  545. CMD:toys(playerid, params[])
  546. {
  547. if(GetPVarInt(playerid, "EventToken" ) == 1 || PlayerInfo[playerid][pJailTime] != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot use this command at the moment.");
  548. ShowPlayerDialogEx( playerid, TOYS, DIALOG_STYLE_LIST, "Toy Menu", "Attach/Dettach a Toy\nEdit a Toy\nDelete a Toy","Select", "Cancel" );
  549. return 1;
  550. }
  551. CMD:wt(playerid, params[])
  552. {
  553. new toyslot;
  554. if(sscanf(params, "d", toyslot)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /wt [toyslot]");
  555. if(toyslot < 1 || toyslot > MAX_PLAYERTOYS+1) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /wt [toyslot]");
  556. if(GetPVarInt(playerid, "EventToken" ) == 1 || PlayerInfo[playerid][pJailTime] != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot use this command at the moment.");
  557. for(new i; i < 10; i++)
  558. {
  559. if(PlayerHoldingObject[playerid][i] == toyslot)
  560. {
  561. if(IsPlayerAttachedObjectSlotUsed(playerid, i))
  562. {
  563. return 1;
  564. }
  565. }
  566. }
  567. // Toy Slot is -1 since players see their toys list starting off from 1
  568. if(PlayerToyInfo[playerid][toyslot-1][ptScaleX] == 0) {
  569. PlayerToyInfo[playerid][toyslot-1][ptScaleX] = 1.0;
  570. PlayerToyInfo[playerid][toyslot-1][ptScaleY] = 1.0;
  571. PlayerToyInfo[playerid][toyslot-1][ptScaleZ] = 1.0;
  572. }
  573. if(PlayerToyInfo[playerid][toyslot-1][ptModelID] != 0 && PlayerToyInfo[playerid][toyslot-1][ptSpecial] != 2)
  574. {
  575. new toycount = GetFreeToySlot(playerid);
  576. if(PlayerInfo[playerid][pBEquipped] && toycount == 9) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot use attach this toy since you have your backpack equipped.");
  577. PlayerHoldingObject[playerid][toycount] = toyslot;
  578. SetPlayerAttachedObject(playerid, toycount,
  579. PlayerToyInfo[playerid][toyslot-1][ptModelID],
  580. PlayerToyInfo[playerid][toyslot-1][ptBone],
  581. PlayerToyInfo[playerid][toyslot-1][ptPosX],
  582. PlayerToyInfo[playerid][toyslot-1][ptPosY],
  583. PlayerToyInfo[playerid][toyslot-1][ptPosZ],
  584. PlayerToyInfo[playerid][toyslot-1][ptRotX],
  585. PlayerToyInfo[playerid][toyslot-1][ptRotY],
  586. PlayerToyInfo[playerid][toyslot-1][ptRotZ],
  587. PlayerToyInfo[playerid][toyslot-1][ptScaleX],
  588. PlayerToyInfo[playerid][toyslot-1][ptScaleY],
  589. PlayerToyInfo[playerid][toyslot-1][ptScaleZ]
  590. );
  591. }
  592. return 1;
  593. }
  594. CMD:dt(playerid, params[])
  595. {
  596. new toyslot;
  597. if(sscanf(params, "d", toyslot)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /dt [toyslot]");
  598. if(toyslot < 1 || toyslot > MAX_PLAYERTOYS) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /dt [toyslot]");
  599. for(new i; i < 10; i++)
  600. {
  601. if(PlayerHoldingObject[playerid][i] == toyslot)
  602. {
  603. if(IsPlayerAttachedObjectSlotUsed(playerid, i) || PlayerHoldingObject[playerid][i])
  604. {
  605. if(i == 9 && PlayerInfo[playerid][pBEquipped] || PlayerToyInfo[playerid][toyslot-1][ptSpecial] == 2)
  606. break;
  607. RemovePlayerAttachedObject(playerid, i);
  608. PlayerHoldingObject[playerid][i] = 0;
  609. break;
  610. }
  611. }
  612. }
  613. return 1;
  614. }
  615. CMD:wat(playerid, params[])
  616. {
  617. if(GetPVarInt(playerid, "EventToken" ) == 1 || PlayerInfo[playerid][pJailTime] != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot use this command at the moment");
  618. new count = 0;
  619. SendClientMessageEx(playerid, COLOR_WHITE, "* Attached max toys allowed.");
  620. for(new x;x<MAX_PLAYERTOYS;x++)
  621. {
  622. if(PlayerToyInfo[playerid][x][ptScaleX] == 0) {
  623. PlayerToyInfo[playerid][x][ptScaleX] = 1.0;
  624. PlayerToyInfo[playerid][x][ptScaleY] = 1.0;
  625. PlayerToyInfo[playerid][x][ptScaleZ] = 1.0;
  626. }
  627. if(PlayerToyInfo[playerid][x][ptModelID] != 0 && PlayerToyInfo[playerid][x][ptSpecial] != 2)
  628. {
  629. if(x == 9 && PlayerInfo[playerid][pBEquipped])
  630. break;
  631. SetPlayerAttachedObject(playerid, x, PlayerToyInfo[playerid][x][ptModelID], PlayerToyInfo[playerid][x][ptBone], PlayerToyInfo[playerid][x][ptPosX], PlayerToyInfo[playerid][x][ptPosY], PlayerToyInfo[playerid][x][ptPosZ], PlayerToyInfo[playerid][x][ptRotX], PlayerToyInfo[playerid][x][ptRotY], PlayerToyInfo[playerid][x][ptRotZ], PlayerToyInfo[playerid][x][ptScaleX], PlayerToyInfo[playerid][x][ptScaleY], PlayerToyInfo[playerid][x][ptScaleZ]),
  632. PlayerHoldingObject[playerid][count] = x;
  633. count++;
  634. }
  635. if(count == 10)
  636. break;
  637. }
  638. return 1;
  639. }
  640. CMD:dat(playerid, params[])
  641. {
  642. SendClientMessageEx(playerid, COLOR_WHITE, "* Detached all toys.");
  643. for(new i; i < 10; i++)
  644. {
  645. if((IsPlayerAttachedObjectSlotUsed(playerid, i) || PlayerHoldingObject[playerid][i]) && PlayerToyInfo[playerid][PlayerHoldingObject[playerid][i]][ptSpecial] != 2)
  646. {
  647. if(i == 9 && PlayerInfo[playerid][pBEquipped])
  648. break;
  649. PlayerHoldingObject[playerid][i] = 0;
  650. RemovePlayerAttachedObject(playerid, i);
  651. }
  652. }
  653. return 1;
  654. }
  655. CMD:selltoy(playerid, params[])
  656. {
  657. new name[24], targetid, cost;
  658. if(GetPVarType(playerid, "ttBuyer")) return SendClientMessageEx(playerid, COLOR_GREY, "You're already trading with someone else.");
  659. if(GetPVarType(playerid, "IsInArena")) return SendClientMessageEx(playerid,COLOR_GREY,"You cannot do this while being in an arena!");
  660. if(GetPVarInt( playerid, "EventToken") != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use this while you're in an event.");
  661. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use this while being cuffed.");
  662. if(GetPVarInt(playerid, "WatchingTV")) return SendClientMessageEx(playerid, COLOR_GREY, "You can not do this while watching TV!");
  663. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid,COLOR_GREY,"You can not do this while in jail or prison!");
  664. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot do this right now.");
  665. if(sscanf(params, "ud", targetid, cost)) return SendClientMessageEx(playerid, COLOR_GRAD1, "USAGE: /selltoy [playerid] [price]");
  666. if(!IsPlayerConnected(targetid)) return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  667. if(targetid == playerid) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot use this command on yourself.");
  668. if(!ProxDetectorS(5.0, playerid, targetid)) return SendClientMessageEx(playerid, COLOR_GREY, "This player is not near you.");
  669. if(InsideTradeToys[targetid] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This person is currently trading at the moment, please try again later.");
  670. if(cost < 1 || cost > 1000000000) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot sell a toy for less than $1.");
  671. SetPVarInt(targetid, "ttSeller", playerid);
  672. SetPVarInt(playerid, "ttBuyer", targetid);
  673. SetPVarInt(playerid, "ttCost", cost);
  674. new icount = GetPlayerToySlots(playerid);
  675. for(new x;x<icount;x++)
  676. {
  677. format(name, sizeof(name), "None");
  678. for(new i;i<sizeof(HoldingObjectsAll);i++)
  679. {
  680. if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
  681. {
  682. format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
  683. }
  684. }
  685. if(PlayerToyInfo[playerid][x][ptModelID] != 0 && (strcmp(name, "None", true) == 0))
  686. {
  687. format(name, sizeof(name), "ID: %d", PlayerToyInfo[playerid][x][ptModelID]);
  688. }
  689. format(szMiscArray, sizeof(szMiscArray), "%s(%d) %s\n", szMiscArray, x+1, name);
  690. }
  691. ShowPlayerDialogEx(playerid, SELLTOY, DIALOG_STYLE_LIST, "Select a toy to sell", szMiscArray, "Sell", "Cancel"); // x+1 since toys list starts off from 1 (From players view)
  692. return 1;
  693. }