Bonika

Untitled

Jan 12th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.47 KB | None | 0 0
  1. local func = {}
  2.  
  3. func["dbConnect"] = exports["rise_mysql"]:getConnection()
  4.  
  5. weapons = {}
  6.  
  7. itemCache = {}
  8.  
  9.  
  10.  
  11. addEventHandler("onResourceStart", resourceRoot,function()
  12.  
  13. for k,v in ipairs(getElementsByType("vehicle")) do
  14.  
  15. setElementData(v,"veh:use",false)
  16.  
  17. setElementData(v,"veh:player",nil)
  18.  
  19. end
  20.  
  21. for k,v in ipairs(getElementsByType("player")) do
  22.  
  23. weapons[v] = {}
  24.  
  25. itemCache[v] = {
  26.  
  27. ["bag"] = {},
  28.  
  29. ["key"] = {},
  30.  
  31. ["vehicle"] = {},
  32.  
  33. ["object"] = {},
  34.  
  35. }
  36.  
  37. loadInventoryElement(v)
  38.  
  39. end
  40.  
  41. for k,v in ipairs(getElementsByType("vehicle")) do
  42.  
  43. itemCache[v] = {
  44.  
  45. ["bag"] = {},
  46.  
  47. ["key"] = {},
  48.  
  49. ["vehicle"] = {},
  50.  
  51. ["object"] = {},
  52.  
  53. }
  54.  
  55. loadInventoryElement(v)
  56.  
  57. end
  58.  
  59. end)
  60.  
  61.  
  62.  
  63. function loadInventoryElement(element)
  64.  
  65. local elementTypes = getTypeOfElement(element)
  66.  
  67. local elementOwnerID = tonumber(getElementData(element, elementTypes[2]))
  68.  
  69. if not itemCache[element] then
  70.  
  71. itemCache[element] = {
  72.  
  73. ["bag"] = {},
  74.  
  75. ["key"] = {},
  76.  
  77. ["vehicle"] = {},
  78.  
  79. ["object"] = {},
  80.  
  81. }
  82.  
  83. end
  84.  
  85. dbQuery(function(qh, element)
  86.  
  87. local res, rows, err = dbPoll(qh, 0)
  88.  
  89. if rows > 0 then
  90.  
  91. for k, row in pairs(res) do
  92.  
  93. itemCache[element][tostring(row["type"])][tonumber(row["slot"])] = {
  94.  
  95. ["dbid"] = tonumber(row["id"]),
  96.  
  97. ["id"] = tonumber(row["itemid"]),
  98.  
  99. ["value"] = tostring(row["value"]),
  100.  
  101. ["count"] = tonumber(row["count"]),
  102.  
  103. ["duty"] = tonumber(row["dutyitem"]),
  104.  
  105. ["slot"] = tonumber(row["slot"]),
  106.  
  107. ["health"] = tonumber(row["itemState"]),
  108.  
  109. ["name"] = tostring(row["name"]),
  110.  
  111. ["weaponserial"] = tostring(row["weaponserial"]),
  112.  
  113. }
  114.  
  115. end
  116.  
  117. end
  118.  
  119. end, {element}, func["dbConnect"], "SELECT * FROM `items` WHERE `owner` = ?",elementOwnerID)
  120.  
  121. end
  122.  
  123.  
  124.  
  125. func["onStop"] = function()
  126.  
  127. for k,v in ipairs(getElementsByType("player")) do
  128.  
  129. if getElementData(v,"loggedin") then
  130.  
  131. if getElementData(v,"acc:id") > 0 then
  132.  
  133. if itemCache[v] then
  134.  
  135. saveOneElementInventory(v)
  136.  
  137. end
  138.  
  139. end
  140.  
  141. end
  142.  
  143. end
  144.  
  145. for k,v in ipairs(getElementsByType("vehicle")) do
  146.  
  147. if (getElementData(v,"veh:id") or 0) > 0 then
  148.  
  149. if itemCache[v] then
  150.  
  151. saveOneElementInventory(v)
  152.  
  153. end
  154.  
  155. end
  156.  
  157. end
  158.  
  159. for k,v in ipairs(getElementsByType("object", getResourceRootElement(getResourceFromName("rise_item")))) do
  160.  
  161. if getElementData(v,"dbid") and getElementData(v,"dbid") > 0 then
  162.  
  163. if itemCache[v] then
  164.  
  165. saveOneElementInventory(v)
  166.  
  167. end
  168.  
  169. end
  170.  
  171. end
  172.  
  173. end
  174.  
  175. addEventHandler("onResourceStop",resourceRoot,func["onStop"])
  176.  
  177.  
  178.  
  179. function removeDuplicate(s, id)
  180.  
  181. for k, v in pairs(itemCache) do
  182.  
  183. if isElement(k) then
  184.  
  185. if getElementType(k) == 'player' then
  186.  
  187. for i = 1, row * column do
  188.  
  189. if v['bag'][i] and v['bag'][i]['dbid'] == id then
  190.  
  191. itemCache[k]['bag'][i] = nil
  192.  
  193. if getElementType(k) == 'player' then
  194.  
  195. triggerClientEvent(k,"updateItemClick",k)
  196.  
  197. end
  198.  
  199. end
  200.  
  201. if v['key'] and v['key'][i] and v['key'][i]['dbid'] == id then
  202.  
  203. itemCache[k]['key'][i] = nil
  204.  
  205. if getElementType(k) == 'player' then
  206.  
  207. triggerClientEvent(k,"updateItemClick",k)
  208.  
  209. end
  210.  
  211. end
  212.  
  213. end
  214.  
  215. else
  216.  
  217. for i = 1, row * column do
  218.  
  219. if v[getTypeOfElement(k)[1]][i] then
  220.  
  221. local dbid = v[getTypeOfElement(k)[1]][i]['dbid']
  222.  
  223. if dbid == 2484 then iprint('miafasz?') end
  224.  
  225. if id == 2484 then iprint('miafasz? miafasz?') end
  226.  
  227. if dbid == id then
  228.  
  229. itemCache[k][getTypeOfElement(k)[1]][i] = nil
  230.  
  231. end
  232.  
  233. end
  234.  
  235. end
  236.  
  237. end
  238.  
  239. end
  240.  
  241. end
  242.  
  243. if id == 2484 then iprint('AZTAKURVA') end
  244.  
  245. end
  246.  
  247.  
  248.  
  249. function saveOneElementInventory(element)
  250.  
  251. if getElementType(element) == "player" then
  252.  
  253. for i = 1, row * column do
  254.  
  255. if (itemCache[element]["bag"][i]) then
  256.  
  257. local dbid = tonumber(itemCache[element]["bag"][i]["dbid"])
  258.  
  259. local item = tonumber(itemCache[element]["bag"][i]["id"])
  260.  
  261. local value = tostring(itemCache[element]["bag"][i]["value"])
  262.  
  263. local count = tonumber(itemCache[element]["bag"][i]["count"])
  264.  
  265. local duty = tonumber(itemCache[element]["bag"][i]["duty"])
  266.  
  267. local state = tonumber(itemCache[element]["bag"][i]["health"])
  268.  
  269. local name = tostring(itemCache[element]["bag"][i]["name"])
  270.  
  271. local weaponserial = tostring(itemCache[element]["bag"][i]["weaponserial"])
  272.  
  273. dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,"bag",getElementData(element,"acc:id"),duty,state,name,weaponserial,dbid)
  274.  
  275. --setTimer(removeDuplicate, 1000, 1, element, dbid)
  276.  
  277. end
  278.  
  279. end
  280.  
  281. for i = 1, row * column do
  282.  
  283. if (itemCache[element]["key"][i]) then
  284.  
  285. local dbid = tonumber(itemCache[element]["key"][i]["dbid"])
  286.  
  287. local item = tonumber(itemCache[element]["key"][i]["id"])
  288.  
  289. local value = tostring(itemCache[element]["key"][i]["value"])
  290.  
  291. local count = tonumber(itemCache[element]["key"][i]["count"])
  292.  
  293. local duty = tonumber(itemCache[element]["key"][i]["duty"])
  294.  
  295. local state = tonumber(itemCache[element]["key"][i]["health"])
  296.  
  297. local name = tostring(itemCache[element]["key"][i]["name"])
  298.  
  299. local weaponserial = tostring(itemCache[element]["key"][i]["weaponserial"])
  300.  
  301. dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,"key",getElementData(element,"acc:id"),duty,state,name,weaponserial,dbid)
  302.  
  303. --setTimer(removeDuplicate, 1000, 1, element, dbid)
  304.  
  305. end
  306.  
  307. end
  308.  
  309. elseif getElementType(element) == "vehicle" then
  310.  
  311. for i = 1, row * column do
  312.  
  313. if (itemCache[element][getTypeOfElement(element)[1]][i]) then
  314.  
  315. local dbid = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["dbid"])
  316.  
  317. local item = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["id"])
  318.  
  319. local value = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["value"])
  320.  
  321. local count = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["count"])
  322.  
  323. local duty = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["duty"])
  324.  
  325. local state = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["health"])
  326.  
  327. local name = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["name"])
  328.  
  329. local weaponserial = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["weaponserial"])
  330.  
  331. dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,getTypeOfElement(element)[1],getElementData(element,"veh:id"),duty,state,name,weaponserial,dbid)
  332.  
  333. --setTimer(removeDuplicate, 1000, 1, element, dbid)
  334.  
  335. end
  336.  
  337. end
  338.  
  339. elseif getElementType(element) == "object" then
  340.  
  341. for i = 1, row * column do
  342.  
  343. if (itemCache[element][getTypeOfElement(element)[1]][i]) then
  344.  
  345. local dbid = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["dbid"])
  346.  
  347. local item = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["id"])
  348.  
  349. local value = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["value"])
  350.  
  351. local count = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["count"])
  352.  
  353. local duty = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["duty"])
  354.  
  355. local state = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["health"])
  356.  
  357. local name = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["name"])
  358.  
  359. local weaponserial = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["weaponserial"])
  360.  
  361. dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,getTypeOfElement(element)[1],getElementData(element,"dbid"),duty,state,name,weaponserial,dbid)
  362.  
  363. --setTimer(removeDuplicate, 1000, 1, element, dbid)
  364.  
  365. end
  366.  
  367. end
  368.  
  369. end
  370.  
  371. end
  372.  
  373.  
  374.  
  375. function getElementItems(playerSource, element, playerValue)
  376.  
  377. if (element) then
  378.  
  379. if not itemCache[element] then
  380.  
  381. itemCache[element] = {
  382.  
  383. ["bag"] = {},
  384.  
  385. ["key"] = {},
  386.  
  387. ["licens"] = {},
  388.  
  389. ["vehicle"] = {},
  390.  
  391. ["object"] = {},
  392.  
  393. }
  394.  
  395. end
  396.  
  397. if (tonumber(playerValue) == 1 or tonumber(playerValue) == 2) then
  398.  
  399. triggerClientEvent(playerSource, "setElementItems", playerSource, itemCache, playerValue, element)
  400.  
  401. else
  402.  
  403. return itemCache
  404.  
  405. end
  406.  
  407. end
  408.  
  409. end
  410.  
  411. addEvent("getElementItems", true)
  412.  
  413. addEventHandler("getElementItems", getRootElement(), getElementItems)
  414.  
  415.  
  416.  
  417. function takeStatus(playerSource, elementSource, itemData, newStatus)
  418.  
  419. if (newStatus) then
  420.  
  421. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])]["health"] = newStatus
  422.  
  423. end
  424.  
  425. end
  426.  
  427. addEvent("takeStatus", true)
  428.  
  429. addEventHandler("takeStatus", getRootElement(), takeStatus)
  430.  
  431.  
  432.  
  433. function updateItemSlot(playerSource, elementSource, newSlot, oldItem,oldSlot,click)
  434.  
  435. if (newSlot and oldItem) then
  436.  
  437. if click == 1 then
  438.  
  439. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(oldSlot)] = nil
  440.  
  441. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(newSlot)] = {
  442.  
  443. ["dbid"] = tonumber(oldItem["dbid"]),
  444.  
  445. ["id"] = tonumber(oldItem["id"]),
  446.  
  447. ["value"] = tostring(oldItem["value"]),
  448.  
  449. ["count"] = tonumber(oldItem["count"]),
  450.  
  451. ["duty"] = tonumber(oldItem["duty"]),
  452.  
  453. ["slot"] = tonumber(newSlot),
  454.  
  455. ["health"] = tonumber(oldItem["health"]),
  456.  
  457. ["name"] = tostring(oldItem["name"]),
  458.  
  459. ["weaponserial"] = tostring(oldItem["weaponserial"]),
  460.  
  461. }
  462.  
  463. triggerClientEvent(playerSource,"updateItemClick",playerSource)
  464.  
  465. end
  466.  
  467. --itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(newSlot)] = oldItem
  468.  
  469. --itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][oldSlot] = nil
  470.  
  471.  
  472.  
  473. -- outputChatBox("-------------------------------------")
  474.  
  475. -- outputChatBox("dbid: "..itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(newSlot)]["dbid"].." - "..tonumber(oldItem["dbid"]))
  476.  
  477. -- outputChatBox("new slot: "..newSlot.." old slot: "..oldItem["slot"])
  478.  
  479. getElementItems(playerSource, elementSource, 2)
  480.  
  481. else
  482.  
  483. triggerClientEvent(playerSource,"updateItemClick",playerSource)
  484.  
  485. end
  486.  
  487. end
  488.  
  489. addEvent("updateItemSlot", true)
  490.  
  491. addEventHandler("updateItemSlot", getRootElement(), updateItemSlot)
  492.  
  493.  
  494.  
  495. function updateItemCount(playerSource, elementSource, itemSlot, newCount,itemData)
  496.  
  497. if (newCount) then
  498.  
  499. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemSlot)]["count"] = newCount
  500.  
  501. end
  502.  
  503. end
  504.  
  505. addEvent("updateItemCount", true)
  506.  
  507. addEventHandler("updateItemCount", getRootElement(), updateItemCount)
  508.  
  509.  
  510.  
  511. function updateItemName(playerSource, elementSource, itemSlot, newName, itemData)
  512.  
  513. if (newName) then
  514.  
  515. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])]["name"] = newName
  516.  
  517. end
  518.  
  519. end
  520.  
  521. addEvent("updateItemName", true)
  522.  
  523. addEventHandler("updateItemName", getRootElement(), updateItemName)
  524.  
  525.  
  526.  
  527. function updateItemValue(playerSource, elementSource, itemSlot, newValue, itemData)
  528.  
  529. if (newValue) then
  530.  
  531. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])]["value"] = newValue
  532.  
  533. end
  534.  
  535. end
  536.  
  537. addEvent("updateItemValue", true)
  538.  
  539. addEventHandler("updateItemValue", getRootElement(), updateItemValue)
  540.  
  541.  
  542.  
  543. function deleteItem(playerSource, elementSource,itemData,state)
  544.  
  545. if not state then
  546.  
  547. state = 0
  548.  
  549. end
  550.  
  551. if (elementSource) then
  552.  
  553. if state == 0 then
  554.  
  555. if getElementType(elementSource) == "player" then
  556.  
  557. func["delActionbarItem"](elementSource,itemData["dbid"])
  558.  
  559. end
  560.  
  561. end
  562.  
  563. dbExec(func["dbConnect"],"DELETE FROM `items` WHERE `id` = ?",itemData["dbid"])
  564.  
  565. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])] = nil
  566.  
  567. getElementItems(playerSource, elementSource, 2)
  568.  
  569. end
  570.  
  571. end
  572.  
  573. addEvent("deleteItem", true)
  574.  
  575. addEventHandler("deleteItem", getRootElement(), deleteItem)
  576.  
  577.  
  578.  
  579. func["delActionbarItem"] = function(element,itemDBID)
  580.  
  581. dbQuery(function(q, element)
  582.  
  583. local rs, rws, errs = dbPoll(q, 0)
  584.  
  585. if rws > 0 then
  586.  
  587. for k,r in pairs(rs) do
  588.  
  589. dbExec(func["dbConnect"], "DELETE FROM `actionbaritems` WHERE `id`=?",r["id"])
  590.  
  591. triggerClientEvent(element,"delActionBarSlot",element,element,r["actionslot"])
  592.  
  593. end
  594.  
  595. end
  596.  
  597. end, {element}, func["dbConnect"],"SELECT * FROM `actionbaritems` WHERE `itemdbid` = ?", itemDBID)
  598.  
  599. end
  600.  
  601.  
  602.  
  603. addEventHandler("onPlayerQuit", root, function()
  604.  
  605. local showElement = getElementData(source,"show:inv")
  606.  
  607. if isElement(showElement) then
  608.  
  609. if getElementType(showElement) == "vehicle" then
  610.  
  611. if (getElementData(showElement, "veh:use") or false) then
  612.  
  613. if getElementData(showElement, "veh:player") == source then
  614.  
  615. setElementData(showElement, "veh:player", nil)
  616.  
  617. setElementData(showElement, "veh:use", false)
  618.  
  619. setVehicleDoorOpenRatio(showElement,1,0,1200)
  620.  
  621. end
  622.  
  623. end
  624.  
  625. end
  626.  
  627. if getElementType(showElement) == "object" then
  628.  
  629. if getElementModel(showElement) == 2332 then
  630.  
  631. if (getElementData(showElement, "safe:use") or false) then
  632.  
  633. if getElementData(showElement, "safe:player") == source then
  634.  
  635. setElementData(showElement, "safe:player", nil)
  636.  
  637. setElementData(showElement, "safe:use", false)
  638.  
  639. end
  640.  
  641. end
  642.  
  643. end
  644.  
  645. end
  646.  
  647. end
  648.  
  649. end)
  650.  
  651.  
  652.  
  653. addCommandHandler("fixinv",function(playerSource,cmd)
  654.  
  655. if getElementData(playerSource,"acc:admin") >= 4 then
  656.  
  657. local playerX,playerY,playerZ = getElementPosition(playerSource)
  658.  
  659. for k,v in ipairs(getElementsByType("object")) do
  660.  
  661. if getElementData(v,"szef") then
  662.  
  663. if getElementData(v,"safe:use") then
  664.  
  665. local objectX,objectY,objectZ = getElementPosition(v)
  666.  
  667. if getDistanceBetweenPoints3D(playerX,playerY,playerZ,objectX,objectY,objectZ) <= 2 then
  668.  
  669. setElementData(v, "safe:player", nil)
  670.  
  671. setElementData(v, "safe:use", false)
  672.  
  673. outputChatBox("[RiseMTA]:#ffffff Sikeresen fix-eltél egy #ACD373'széf'#ffffff inventory-t.",playerSource,172, 211, 115,true)
  674.  
  675. return
  676.  
  677. end
  678.  
  679. end
  680.  
  681. end
  682.  
  683. end
  684.  
  685.  
  686.  
  687. for k,v in ipairs(getElementsByType("vehicle")) do
  688.  
  689. if getElementData(v,"dbid") and getElementData(v,"dbid") > 0 then
  690.  
  691. if getElementData(v, "veh:use") then
  692.  
  693. local vehicleX,vehicleY,vehicleZ = getElementPosition(v)
  694.  
  695. if getDistanceBetweenPoints3D(playerX,playerY,playerZ,vehicleX,vehicleY,vehicleZ) <= 2 then
  696.  
  697. setElementData(v, "veh:player", nil)
  698.  
  699. setElementData(v, "veh:use", false)
  700.  
  701. setVehicleDoorOpenRatio(v,1,0,1200)
  702.  
  703. outputChatBox("[RiseMTA]:#ffffff Sikeresen fix-eltél egy #ACD373'csomagtartó'#ffffff inventory-t.",playerSource,172, 211, 115,true)
  704.  
  705. end
  706.  
  707. end
  708.  
  709. end
  710.  
  711. end
  712.  
  713.  
  714.  
  715. end
  716.  
  717. end)
  718.  
  719.  
  720.  
  721. function createNewItem(playerSource, elementSource, itemID, itemSlot, itemCount, itemDuty, itemValue,itemHealth,itemName,weaponserial,oldDBID)
  722.  
  723. if (itemID and itemSlot) then
  724.  
  725. local elementType = getTypeOfElement(elementSource)
  726.  
  727. local elementOwnerID = tonumber(getElementData(elementSource, elementType[2]))
  728.  
  729. dbQuery(function(qh,itemID,elementOwnerID,itemSlot)
  730.  
  731. local query, query_lines,id = dbPoll(qh, 0)
  732.  
  733. local id = tonumber(id)
  734.  
  735. if id > 0 then
  736.  
  737. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemID))[1]][tonumber(itemSlot)] = {
  738.  
  739. ["dbid"] = tonumber(id),
  740.  
  741. ["id"] = tonumber(itemID),
  742.  
  743. ["value"] = tostring(itemValue),
  744.  
  745. ["count"] = tonumber(itemCount),
  746.  
  747. ["duty"] = tonumber(itemDuty),
  748.  
  749. ["slot"] = tonumber(itemSlot),
  750.  
  751. ["health"] = tonumber(itemHealth),
  752.  
  753. ["name"] = tostring(itemName),
  754.  
  755. ["weaponserial"] = tostring(weaponserial),
  756.  
  757. }
  758.  
  759. if getElementType(elementSource) == "player" and weaponModels[itemID] then
  760.  
  761. if isElement(weapons[elementSource][oldDBID]) then
  762.  
  763. weapons[elementSource][id] = weapons[elementSource][oldDBID]
  764.  
  765. end
  766.  
  767. end
  768.  
  769. getElementItems(playerSource, elementSource, 2)
  770.  
  771. end
  772.  
  773. end,{itemID,elementOwnerID,itemSlot},func["dbConnect"], "INSERT INTO `items` SET `itemid` = ?, `slot` = ?, `owner` = ?, `value` = ?, `count` = ?, `type` = ?, `dutyitem` = ?, `itemState` = ?, `name` = ?, `weaponserial` = ?",itemID, itemSlot, elementOwnerID, itemValue, itemCount, getTypeOfElement(elementSource,tonumber(itemID))[1], itemDuty,itemHealth,itemName,weaponserial)
  774.  
  775. end
  776.  
  777. end
  778.  
  779. addEvent("createNewItem", true)
  780.  
  781. addEventHandler("createNewItem", getRootElement(), createNewItem)
  782.  
  783.  
  784.  
  785. function tradeItem(playerSource, elementSource, activeElementSource, activeItem,click)
  786.  
  787. if (playerSource and elementSource and activeItem) then
  788.  
  789. if click == 1 then
  790.  
  791. local elementType = getTypeOfElement(elementSource)
  792.  
  793. local itemDBID = activeItem["dbid"]
  794.  
  795. local elementOwnerID = tonumber(getElementData(elementSource, elementType[2]))
  796.  
  797. --local elementOwnerType = elementType[1]
  798.  
  799. if not itemCache[elementSource] then
  800.  
  801. itemCache[elementSource] = {
  802.  
  803. ["bag"] = {},
  804.  
  805. ["key"] = {},
  806.  
  807. ["vehicle"] = {},
  808.  
  809. ["object"] = {},
  810.  
  811. }
  812.  
  813. end
  814.  
  815. local weight = getElementItemsWeight(elementSource)
  816.  
  817. if weight + (getItemWeight(activeItem["id"]) * activeItem["count"]) > getTypeOfElement(elementSource)[3] then
  818.  
  819. outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem inventoryja nem bír el több tárgyat.", playerSource,172, 211, 115, true)
  820.  
  821. triggerClientEvent(playerSource,"updateItemClick",playerSource)
  822.  
  823. return
  824.  
  825. end
  826.  
  827.  
  828.  
  829. local pSlotState, pSlotID = getFreeSlot(elementSource, activeItem["id"])
  830.  
  831. if (pSlotState and pSlotID) then
  832.  
  833. local itemName = ""
  834.  
  835. if #activeItem["name"] <= 0 then
  836.  
  837. itemName = getItemName(activeItem["id"],tonumber(activeItem["value"]))
  838.  
  839. else
  840.  
  841. itemName = activeItem["name"]
  842.  
  843. end
  844.  
  845.  
  846.  
  847. if getElementType(elementSource) == "vehicle" and elementSource ~= playerSource and (activeItem["id"] == 176 and hasItem(elementSource,176,1)) then
  848.  
  849. outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem már rendelkezik egy ilyen tárggyal. #ACD373("..itemName..")", playerSource,172, 211, 115, true)
  850.  
  851. elseif getElementType(elementSource) == "vehicle" and elementSource ~= playerSource and (activeItem["id"] == 177 and hasItem(elementSource,177,1)) then
  852.  
  853. outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem már rendelkezik egy ilyen tárggyal. #ACD373("..itemName..")", playerSource,172, 211, 115, true)
  854.  
  855. else
  856.  
  857. itemCache[activeElementSource][getTypeOfElement(activeElementSource,tonumber(activeItem["id"]))[1]][tonumber(activeItem["slot"])] = nil
  858.  
  859. itemCache[elementSource][getTypeOfElement(elementSource,tonumber(activeItem["id"]))[1]][tonumber(pSlotID)] = {
  860.  
  861. ["dbid"] = tonumber(activeItem["dbid"]),
  862.  
  863. ["id"] = tonumber(activeItem["id"]),
  864.  
  865. ["value"] = tostring(activeItem["value"]),
  866.  
  867. ["count"] = tonumber(activeItem["count"]),
  868.  
  869. ["duty"] = tonumber(activeItem["duty"]),
  870.  
  871. ["slot"] = tonumber(pSlotID),
  872.  
  873. ["health"] = tonumber(activeItem["health"]),
  874.  
  875. ["name"] = tostring(activeItem["name"]),
  876.  
  877. ["weaponserial"] = tostring(activeItem["weaponserial"]),
  878.  
  879. }
  880.  
  881. if getElementType(elementSource) == "player" and elementSource ~= playerSource then
  882.  
  883. if isElement(getElementData(elementSource,"show:inv")) and getElementType(getElementData(elementSource,"show:inv")) == "player" then
  884.  
  885. getElementItems(elementSource, elementSource, 2)
  886.  
  887. end
  888.  
  889. func["delActionbarItem"](activeElementSource,activeItem["dbid"])
  890.  
  891. end
  892.  
  893. getElementItems(playerSource, activeElementSource, 2)
  894.  
  895.  
  896.  
  897. if getElementType(elementSource) == "player" and elementSource ~= playerSource then
  898.  
  899. exports["rise_chat"]:sendLocalMeAction(playerSource,"átadott egy tárgyat "..string.gsub(getPlayerName(elementSource), "_", " ").." -nak/nek. ("..itemName..")")
  900.  
  901. dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(elementSource, 'char:id'), getTypeOfElement(elementSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
  902.  
  903. itemAnim(playerSource,elementSource)
  904.  
  905. if weaponModels[activeItem["id"]] then
  906.  
  907. delAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
  908.  
  909. addAttachWeapon(elementSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
  910.  
  911. end
  912.  
  913. elseif getElementType(elementSource) == "vehicle" and elementSource ~= playerSource then
  914.  
  915. --local lampTable = exports["dm_vehiclelights"]:getLamp()
  916.  
  917. --if lampTable[getElementModel(elementSource)] then
  918.  
  919. --if activeItem["id"] == 176 then
  920.  
  921. --exports["dm_vehiclelights"]:loadTaxilamp(elementSource)
  922.  
  923. --end
  924.  
  925. --end
  926.  
  927. --local sirenTable = exports["dm_vehiclelights"]:getSiren()
  928.  
  929. --if sirenTable[getElementModel(elementSource)] then
  930.  
  931. --if activeItem["id"] == 177 then
  932.  
  933. --exports["dm_vehiclelights"]:loadSiren(elementSource)
  934.  
  935. --end
  936.  
  937. --end
  938.  
  939. exports["rise_chat"]:sendLocalMeAction(playerSource,"berakott egy tárgyat a jármű csomagtartójába. ("..itemName..")")
  940.  
  941. dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(elementSource, 'veh:id'), getTypeOfElement(elementSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
  942.  
  943. if weaponModels[activeItem["id"]] then
  944.  
  945. delAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
  946.  
  947. end
  948.  
  949. elseif getElementType(activeElementSource) == "vehicle" and elementSource == playerSource then
  950.  
  951. --local lampTable = exports["dm_vehiclelights"]:getLamp()
  952.  
  953. --if lampTable[getElementModel(activeElementSource)] then
  954.  
  955. -- if activeItem["id"] == 176 then
  956.  
  957. -- exports["dm_vehiclelights"]:destroyLamp(activeElementSource)
  958.  
  959. -- end
  960.  
  961. -- end
  962.  
  963. -- local sirenTable = exports["dm_vehiclelights"]:getSiren()
  964.  
  965. -- if sirenTable[getElementModel(activeElementSource)] then
  966.  
  967. -- if activeItem["id"] == 177 then
  968.  
  969. -- exports["dm_vehiclelights"]:destroySiren(activeElementSource)
  970.  
  971. --end
  972.  
  973. --end
  974.  
  975. exports["rise_chat"]:sendLocalMeAction(playerSource,"kivett egy tárgyat a jármű csomagtartójából. ("..itemName..")")
  976.  
  977. dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(playerSource, 'char:id'), getTypeOfElement(playerSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
  978.  
  979. if weaponModels[activeItem["id"]] then
  980.  
  981. addAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
  982.  
  983. end
  984.  
  985. elseif getElementType(elementSource) == "object" and elementSource ~= playerSource then
  986.  
  987. exports["rise_chat"]:sendLocalMeAction(playerSource,"berakott egy tárgyat a széfbe. ("..itemName..")")
  988.  
  989. dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(elementSource, 'dbid'), getTypeOfElement(elementSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
  990.  
  991. if weaponModels[activeItem["id"]] then
  992.  
  993. delAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
  994.  
  995. end
  996.  
  997. elseif getElementType(activeElementSource) == "object" and elementSource == playerSource then
  998.  
  999. exports["rise_chat"]:sendLocalMeAction(playerSource,"kivett egy tárgyat a széfből. ("..itemName..")")
  1000.  
  1001. dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(playerSource, 'char:id'), getTypeOfElement(playerSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
  1002.  
  1003. if weaponModels[activeItem["id"]] then
  1004.  
  1005. addAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
  1006.  
  1007. end
  1008.  
  1009. end
  1010.  
  1011. end
  1012.  
  1013. else
  1014.  
  1015. outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem inventoryja nem bír el több tárgyat.", playerSource,172, 211, 115, true)
  1016.  
  1017. end
  1018.  
  1019. triggerClientEvent(playerSource,"updateItemClick",playerSource)
  1020.  
  1021. end
  1022.  
  1023. end
  1024.  
  1025. end
  1026.  
  1027. addEvent("tradeItem", true)
  1028.  
  1029. addEventHandler("tradeItem", getRootElement(), tradeItem)
  1030.  
  1031.  
  1032.  
  1033. function getElementItemsWeight(element)
  1034.  
  1035. local bagWeight = 0
  1036.  
  1037. local keyWeight = 0
  1038.  
  1039. local vehWeight = 0
  1040.  
  1041. local objectWeight = 0
  1042.  
  1043. if getElementType(element) == "player" then
  1044.  
  1045. for i = 1, row * column do
  1046.  
  1047. if (itemCache[element]["bag"][i]) then
  1048.  
  1049. bagWeight = bagWeight + (getItemWeight(itemCache[element]["bag"][i]["id"]) * itemCache[element]["bag"][i]["count"])
  1050.  
  1051. end
  1052.  
  1053. end
  1054.  
  1055. for i = 1, row * column do
  1056.  
  1057. if (itemCache[element]["key"][i]) then
  1058.  
  1059. keyWeight = keyWeight + (getItemWeight(itemCache[element]["key"][i]["id"]) * itemCache[element]["key"][i]["count"])
  1060.  
  1061. end
  1062.  
  1063. end
  1064.  
  1065. end
  1066.  
  1067. if getElementType(element) == "vehicle" then
  1068.  
  1069. for i = 1, row * column do
  1070.  
  1071. if (itemCache[element]["vehicle"][i]) then
  1072.  
  1073. vehWeight = vehWeight + (getItemWeight(itemCache[element]["vehicle"][i]["id"]) * itemCache[element]["vehicle"][i]["count"])
  1074.  
  1075. end
  1076.  
  1077. end
  1078.  
  1079. end
  1080.  
  1081. if getElementType(element) == "object" then
  1082.  
  1083. for i = 1, row * column do
  1084.  
  1085. if (itemCache[element]["object"][i]) then
  1086.  
  1087. objectWeight = objectWeight + (getItemWeight(itemCache[element]["object"][i]["id"]) * itemCache[element]["object"][i]["count"])
  1088.  
  1089. end
  1090.  
  1091. end
  1092.  
  1093. end
  1094.  
  1095. return math.ceil(bagWeight + keyWeight + vehWeight + objectWeight)
  1096.  
  1097. end
  1098.  
  1099.  
  1100.  
  1101. function hasItem(element,item,value)
  1102.  
  1103. if not value then
  1104.  
  1105. value = 1
  1106.  
  1107. end
  1108.  
  1109. for i = 1, row * column do
  1110.  
  1111. if (itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]) then
  1112.  
  1113. if tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"]) == tonumber(item) then
  1114.  
  1115. if value == -1 then
  1116.  
  1117. if tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"]) < 4 then
  1118.  
  1119. return true,itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["dbid"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
  1120.  
  1121. end
  1122.  
  1123. elseif tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"]) == tonumber(value) then
  1124.  
  1125. return true,itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["dbid"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
  1126.  
  1127. end
  1128.  
  1129. end
  1130.  
  1131. end
  1132.  
  1133. end
  1134.  
  1135. return false,-1,-1,-1,-1
  1136.  
  1137. end
  1138.  
  1139.  
  1140.  
  1141. function getItemCount(element,item,value)
  1142.  
  1143. local r = 0
  1144.  
  1145. for i = 1, row*column do
  1146.  
  1147. if (itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]) then
  1148.  
  1149. if tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"]) == tonumber(item) then
  1150.  
  1151. if not value then
  1152.  
  1153. r = r + itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
  1154.  
  1155. elseif value and value == itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"] then
  1156.  
  1157. r = r + itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
  1158.  
  1159. end
  1160.  
  1161. end
  1162.  
  1163. end
  1164.  
  1165. end
  1166.  
  1167. return r
  1168.  
  1169. end
  1170.  
  1171.  
  1172.  
  1173. function hasItemCount(element,item,count,itemData)
  1174.  
  1175. if not itemData then
  1176.  
  1177. itemData = itemCache
  1178.  
  1179. end
  1180.  
  1181.  
  1182.  
  1183. for i = 1, row * column do
  1184.  
  1185. if (itemData[element][getTypeOfElement(element,tonumber(item))[1]][i]) then
  1186.  
  1187. if tonumber(itemData[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"]) == tonumber(item) and tonumber(itemData[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]) >= tonumber(count) then
  1188.  
  1189. return true
  1190.  
  1191. end
  1192.  
  1193. end
  1194.  
  1195. end
  1196.  
  1197. if count == -1 then
  1198.  
  1199. return true
  1200.  
  1201. end
  1202.  
  1203. return false
  1204.  
  1205. end
  1206.  
  1207.  
  1208.  
  1209. function giveItem(playerSource, itemID, itemValue, itemCount, itemDuty, itemState,itemName,serial)
  1210.  
  1211. local r = false
  1212.  
  1213. if (playerSource and itemID and itemValue and itemCount and itemDuty) then
  1214.  
  1215. if not itemState then
  1216.  
  1217. itemState = 100
  1218.  
  1219. else
  1220.  
  1221. itemState = itemState
  1222.  
  1223. end
  1224.  
  1225. if not itemName then
  1226.  
  1227. itemName = ""
  1228.  
  1229. else
  1230.  
  1231. itemName = itemName
  1232.  
  1233. end
  1234.  
  1235. if weaponModels[itemID] then
  1236.  
  1237. weaponSerial = generateSerial()
  1238.  
  1239. else
  1240.  
  1241. --if itemID == 65 then
  1242.  
  1243. -- weaponSerial = serial
  1244.  
  1245. --else
  1246.  
  1247. weaponSerial = ""
  1248.  
  1249. --end
  1250.  
  1251. end
  1252.  
  1253. local elementType = getTypeOfElement(playerSource)
  1254.  
  1255. local elementOwnerID = tonumber(getElementData(playerSource, elementType[2]))
  1256.  
  1257. --local elementOwnerType = elementType[1]
  1258.  
  1259. local pSlotState, pSlotID = getFreeSlot(playerSource, itemID)
  1260.  
  1261.  
  1262.  
  1263. dbQuery(function(qh,itemID,elementOwnerID,pSlotID)
  1264.  
  1265. local query, query_lines,id = dbPoll(qh, 0)
  1266.  
  1267. local id = tonumber(id)
  1268.  
  1269. if id > 0 then
  1270.  
  1271.  
  1272.  
  1273. itemCache[playerSource][getTypeOfElement(playerSource,tonumber(itemID))[1]][tonumber(pSlotID)] = {
  1274.  
  1275. ["dbid"] = tonumber(id),
  1276.  
  1277. ["id"] = tonumber(itemID),
  1278.  
  1279. ["value"] = tostring(itemValue),
  1280.  
  1281. ["count"] = tonumber(itemCount),
  1282.  
  1283. ["duty"] = tonumber(itemDuty),
  1284.  
  1285. ["slot"] = tonumber(pSlotID),
  1286.  
  1287. ["health"] = tonumber(itemState),
  1288.  
  1289. ["name"] = tostring(itemName),
  1290.  
  1291. ["weaponserial"] = tostring(weaponSerial),
  1292.  
  1293. }
  1294.  
  1295.  
  1296.  
  1297. if weaponModels[itemID] then
  1298.  
  1299. addAttachWeapon(playerSource,itemID,itemValue,id)
  1300.  
  1301. end
  1302.  
  1303. if isElement(getElementData(playerSource,"show:inv")) and getElementType(getElementData(playerSource,"show:inv")) == "player" then
  1304.  
  1305. getElementItems(playerSource, playerSource, 2)
  1306.  
  1307. end
  1308.  
  1309. r = true
  1310.  
  1311. end
  1312.  
  1313. end,{itemID,elementOwnerID,pSlotID},func["dbConnect"], "INSERT INTO `items` SET `itemid` = ?, `slot` = ?, `owner` = ?, `value` = ?, `count` = ?, `type` = ?, `dutyitem` = ?, `itemState` = ?, `name` = ?, `weaponserial` = ?",itemID, pSlotID, elementOwnerID, itemValue, itemCount, getTypeOfElement(playerSource,tonumber(itemID))[1], itemDuty, itemState,itemName,weaponSerial)
  1314.  
  1315. end
  1316.  
  1317. return r
  1318.  
  1319. end
  1320.  
  1321. addEvent("giveItem", true)
  1322.  
  1323. addEventHandler("giveItem", root, giveItem)
  1324.  
  1325.  
  1326.  
  1327. addCommandHandler("giveitem",function(playerSource, cmd, id, item, value, count,dutyitem, itemState)
  1328.  
  1329. if getElementData(playerSource, "acc:admin") >= 6 then
  1330.  
  1331. if id and item and value and count and dutyitem then
  1332.  
  1333. local targetPlayer, targetPlayerName = exports['rise_core']:findPlayer(playerSource, id)
  1334.  
  1335. if targetPlayer then
  1336.  
  1337. if getElementData(targetPlayer,"loggedin") then
  1338.  
  1339. local weight = getElementItemsWeight(targetPlayer)
  1340.  
  1341. if weight + (getItemWeight(tonumber(item)) * tonumber(count)) > getTypeOfElement(targetPlayer)[3] then
  1342.  
  1343. outputChatBox("[RiseMTA]:#ffffff A kiválasztott játékos nem bír el több tárgyat. #ACD373(Súly)", playerSource,172, 211, 115,true)
  1344.  
  1345. return
  1346.  
  1347. end
  1348.  
  1349. local pSlotState, pSlotID = getFreeSlot(targetPlayer, tonumber(item))
  1350.  
  1351. if pSlotState then
  1352.  
  1353. if tonumber(item) == 47 or tonumber(item) == 48 or tonumber(item) == 71 or tonumber(item) == 72 then
  1354.  
  1355. triggerEvent("givePlayerIdentity",targetPlayer,targetPlayer,tonumber(item))
  1356.  
  1357. elseif tonumber(item) == 8 then
  1358.  
  1359. exports.rise_phone:addPhone(targetPlayer)
  1360.  
  1361. else
  1362.  
  1363. giveItem(targetPlayer,tonumber(item),tostring(value),tonumber(count),tonumber(dutyitem))
  1364.  
  1365. outputChatBox("[RiseMTA]:#ffffff Sikeresen adtál #ACD373"..string.gsub(getPlayerName(targetPlayer), "_", " ").."#ffffff -nak/nek #ACD373"..tonumber(count).."#ffffff darab #ACD373"..getItemName(tonumber(item),tostring(value)).."#ffffff -t.",playerSource,172, 211, 115,true)
  1366.  
  1367. outputChatBox("[RiseMTA]:#ffffff Sikeresen kaptál #ACD373"..getElementData(playerSource,"char:anick").."#ffffff -tól/től #ACD373"..tonumber(count).."#ffffff darab #ACD373"..getItemName(tonumber(item),tostring(value)).."#ffffff -t.",targetPlayer,172, 211, 115,true)
  1368.  
  1369. end
  1370.  
  1371. else
  1372.  
  1373. outputChatBox("[RiseMTA]:#ffffff A kiválasztott játékos nem bír el több tárgyat. #ACD373(Slot)", playerSource,172, 211, 115,true)
  1374.  
  1375. end
  1376.  
  1377. else
  1378.  
  1379. outputChatBox("[RiseMTA]:#ffffff A kiválasztott játékos nincs bejelentkezve.", playerSource,172, 211, 115,true)
  1380.  
  1381. end
  1382.  
  1383. end
  1384.  
  1385. else
  1386.  
  1387. outputChatBox("Használat:#ffffff /"..cmd.." [NÉVRÉSZLET/ID] [ItemID] [érték] [db] [dutyItem: 0=Nem , 1=Igen]", playerSource,172, 211, 115,true)
  1388.  
  1389. end
  1390.  
  1391. end
  1392.  
  1393. end)
  1394.  
  1395.  
  1396.  
  1397. addCommandHandler("changelock",function(playerSource,cmd,typ)
  1398.  
  1399. if getElementData(playerSource,"acc:admin") >= 7 then
  1400.  
  1401. if typ then
  1402.  
  1403. typ = tostring(typ)
  1404.  
  1405. if typ == "vehicle" then
  1406.  
  1407. local veh = getPedOccupiedVehicle(playerSource)
  1408.  
  1409. if isElement(veh) then
  1410.  
  1411. local dbid = getElementData(veh,"veh:id")
  1412.  
  1413. takeAllItem(0,dbid)
  1414.  
  1415. giveItem(playerSource,0,dbid,1,0)
  1416.  
  1417. outputChatBox("[RiseMTA]:#ffffff Sikeresen changelock-oltál egy járművet. #ACD373("..dbid..")", playerSource,172, 211, 115, true)
  1418.  
  1419. else
  1420.  
  1421. outputChatBox("[RiseMTA]:#ffffff Nem ülsz járműben.", playerSource,172, 211, 115, true)
  1422.  
  1423. end
  1424.  
  1425. elseif typ == "interior" then
  1426.  
  1427. if getElementData(playerSource, "isInIntMarker") then
  1428.  
  1429. local theMarkElement = getElementData(playerSource,"int:Marker")
  1430.  
  1431. if getElementData(theMarkElement,"isIntMarker") then
  1432.  
  1433. local dbid = getElementData(theMarkElement,"int:id")
  1434.  
  1435. takeAllItem(1,dbid)
  1436.  
  1437. giveItem(playerSource,1,dbid,1,0)
  1438.  
  1439. outputChatBox("[RiseMTA]:#ffffff Sikeresen changelock-oltál egy interiort. #ACD373("..dbid..")", playerSource,172, 211, 115, true)
  1440.  
  1441. end
  1442.  
  1443. else
  1444.  
  1445. outputChatBox("[DoubleMTA - Interior]:#ffffff Nem állsz interior marker-ben.",playerSource,172, 211, 115,true)
  1446.  
  1447. end
  1448.  
  1449. end
  1450.  
  1451. else
  1452.  
  1453. outputChatBox("Használat:#ffffff /"..cmd.." [tipus: vehicle, interior]", playerSource,172, 211, 115, true)
  1454.  
  1455. end
  1456.  
  1457. end
  1458.  
  1459. end)
  1460.  
  1461.  
  1462.  
  1463. addCommandHandler("delplayeritem",function(playerSource,cmd,who,category,slot)
  1464.  
  1465. if getElementData(playerSource,"acc:admin") >= 7 then
  1466.  
  1467. if who and category and slot then
  1468.  
  1469. if category == "bag" or category == "key" then
  1470.  
  1471. slot = tonumber(slot)
  1472.  
  1473. if type(slot) == "number" then
  1474.  
  1475. local targetPlayer, targetPlayerName = exports['rise_core']:findPlayer(playerSource,who)
  1476.  
  1477. if targetPlayer then
  1478.  
  1479. if(itemCache[targetPlayer][category])then
  1480.  
  1481. if(itemCache[targetPlayer][category][slot])then
  1482.  
  1483. outputChatBox("[RiseMTA]:#ffffff Sikeresen töröltél #ACD373"..getPlayerName(targetPlayer):gsub("_", " ").."#ffffff -tól/től egy #D23131"..getItemName(itemCache[targetPlayer][category][slot]["id"],itemCache[targetPlayer][category][slot]["value"]).."#ffffff -t.",playerSource,172, 211, 115, true)
  1484.  
  1485. outputChatBox("[RiseMTA]:#ffffff Sikeresen törölt tőled #ACD373"..getElementData(targetPlayer,"anev").."#ffffff egy #D23131"..getItemName(itemCache[targetPlayer][category][slot]["id"],itemCache[targetPlayer][category][slot]["value"]).."#ffffff -t.",targetPlayer,172, 211, 115, true)
  1486.  
  1487. if(weaponModels[itemCache[targetPlayer][category][slot]["id"]])then
  1488.  
  1489. delAttachWeapon(targetPlayer,itemCache[targetPlayer][category][slot]["id"],itemCache[targetPlayer][category][slot]["value"],itemCache[targetPlayer][category][slot]["dbid"])
  1490.  
  1491. end
  1492.  
  1493. deleteItem(targetPlayer,targetPlayer,itemCache[targetPlayer][category][slot])
  1494.  
  1495. else
  1496.  
  1497. outputChatBox("[RiseMTA]:#ffffff A kiválaszott játékosnak a #7cc576'"..category.."'#ffffff inventoryjában nincs ezen a sloton item. #ACD373("..slot..")", playerSource,172, 211, 115, true)
  1498.  
  1499. end
  1500.  
  1501. end
  1502.  
  1503. end
  1504.  
  1505. else
  1506.  
  1507. outputChatBox("[RiseMTA]:#ffffff A slot csak szám lehet.", playerSource,172, 211, 115, true)
  1508.  
  1509. end
  1510.  
  1511. else
  1512.  
  1513. outputChatBox("[RiseMTA]:#ffffff A kategória csak bag, key lehet.", playerSource,172, 211, 115, true)
  1514.  
  1515. end
  1516.  
  1517. else
  1518.  
  1519. outputChatBox("Használat:#ffffff /"..cmd.." [ID/Név] [category: bag,key] [slot]", playerSource,172, 211, 115, true)
  1520.  
  1521. end
  1522.  
  1523. end
  1524.  
  1525. end)
  1526.  
  1527.  
  1528.  
  1529. function addPhone(playerSource,typ)
  1530.  
  1531. local thePhoneNumber = math.random(7868771+getElementData(playerSource,"dbid"),7968771+getElementData(playerSource,"playerid"))
  1532.  
  1533. dbQuery(function(qh, playerSource)
  1534.  
  1535. local res, rows, err = dbPoll(qh, 0)
  1536.  
  1537. if rows > 0 then
  1538.  
  1539. giveItem(playerSource,174,thePhoneNumber,1,0)
  1540.  
  1541. end
  1542.  
  1543. end, {playerSource}, func["dbConnect"],"INSERT INTO phones SET phoneNumber = ?, type = ?, date = NOW()",tonumber(thePhoneNumber),tostring(typ))
  1544.  
  1545. end
  1546.  
  1547. addEvent("addPhone",true)
  1548.  
  1549. addEventHandler("addPhone",getRootElement(),addPhone)
  1550.  
  1551.  
  1552.  
  1553. function getFreeSlot(elementSource, forItemID)
  1554.  
  1555. local nextSlot = 1
  1556.  
  1557. for i = 1, (row * column) do
  1558.  
  1559. if not (itemCache[elementSource][getTypeOfElement(elementSource,tonumber(forItemID))[1]][i]) then
  1560.  
  1561. return true, nextSlot
  1562.  
  1563. else
  1564.  
  1565. nextSlot = nextSlot + 1
  1566.  
  1567. end
  1568.  
  1569. end
  1570.  
  1571.  
  1572.  
  1573. return false, -1
  1574.  
  1575. end
  1576.  
  1577.  
  1578.  
  1579. function doorState(vehicle,typ)
  1580.  
  1581. if typ == 1 then
  1582.  
  1583. setVehicleDoorOpenRatio(vehicle,1,1,1200)
  1584.  
  1585. --setElementData(vehicle,"veh:use",true)
  1586.  
  1587. --setElementData(vehicle,"veh:player",source)
  1588.  
  1589. else
  1590.  
  1591. setVehicleDoorOpenRatio(vehicle,1,0,1200)
  1592.  
  1593. --setElementData(vehicle,"veh:use",false)
  1594.  
  1595. --setElementData(vehicle,"veh:player",nil)
  1596.  
  1597. end
  1598.  
  1599. end
  1600.  
  1601. addEvent("doorState", true)
  1602.  
  1603. addEventHandler("doorState", root, doorState)
  1604.  
  1605.  
  1606.  
  1607. function itemAnim(element, targetElement)
  1608.  
  1609. if isElement(element) and isElement(targetElement) then
  1610.  
  1611. setPedAnimation(element,"DEALER","DEALER_DEAL",3000,false,false,false,false)
  1612.  
  1613. setPedAnimation(targetElement,"DEALER","DEALER_DEAL",3000,false,false,false,false)
  1614.  
  1615. end
  1616.  
  1617. end
  1618.  
  1619. addEvent("itemAnim", true)
  1620.  
  1621. addEventHandler("itemAnim", root, itemAnim)
  1622.  
  1623.  
  1624.  
  1625. function takeItem(playerSource,item)
  1626.  
  1627. local elem = 0
  1628.  
  1629. if itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]] then
  1630.  
  1631. for i = 1, row * column do
  1632.  
  1633. if (itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]) then
  1634.  
  1635. if itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["id"] == item then
  1636.  
  1637. elem = elem+1
  1638.  
  1639. if elem == 1 then
  1640.  
  1641. if itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["count"] > 1 then
  1642.  
  1643. itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["count"] = itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["count"]-1
  1644.  
  1645. getElementItems(playerSource, playerSource, 2)
  1646.  
  1647. else
  1648.  
  1649. if weaponModels[itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["id"]] then
  1650.  
  1651. delAttachWeapon(playerSource,itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["id"],itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["value"],itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["dbid"])
  1652.  
  1653. end
  1654.  
  1655. deleteItem(playerSource,playerSource,itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i])
  1656.  
  1657. end
  1658.  
  1659. end
  1660.  
  1661. end
  1662.  
  1663. end
  1664.  
  1665. end
  1666.  
  1667. end
  1668.  
  1669. end
  1670.  
  1671.  
  1672.  
  1673. function takeAllItem(item,value)
  1674.  
  1675. for k,v in ipairs(getElementsByType("vehicle")) do
  1676.  
  1677. if getElementData(v,"dbid") > 0 then
  1678.  
  1679. if itemCache[v] then
  1680.  
  1681. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]] then
  1682.  
  1683. for i = 1, row * column do
  1684.  
  1685. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i] then
  1686.  
  1687. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"] == tonumber(item) and tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["value"]) == tonumber(value) then
  1688.  
  1689. itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"]))[1]][tonumber(i)] = nil
  1690.  
  1691. if isElement(getElementData(v, "veh:player")) then
  1692.  
  1693. getElementItems(getElementData(v, "veh:player"),v,1)
  1694.  
  1695. end
  1696.  
  1697. end
  1698.  
  1699. end
  1700.  
  1701. end
  1702.  
  1703. end
  1704.  
  1705. end
  1706.  
  1707. end
  1708.  
  1709. end
  1710.  
  1711.  
  1712.  
  1713. for k,v in ipairs(getElementsByType("object")) do
  1714.  
  1715. if getElementData(v,"szef") and getElementData(v,"dbid") > 0 then
  1716.  
  1717. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]] then
  1718.  
  1719. for i = 1, row * column do
  1720.  
  1721. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i] then
  1722.  
  1723. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"] == tonumber(item) and tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["value"]) == tonumber(value) then
  1724.  
  1725. itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"]))[1]][tonumber(i)] = nil
  1726.  
  1727. if isElement(getElementData(v, "safe:player")) then
  1728.  
  1729. getElementItems(getElementData(v, "safe:player"),v,1)
  1730.  
  1731. end
  1732.  
  1733. end
  1734.  
  1735. end
  1736.  
  1737. end
  1738.  
  1739. end
  1740.  
  1741. end
  1742.  
  1743. end
  1744.  
  1745.  
  1746.  
  1747. for k,v in ipairs(getElementsByType("player")) do
  1748.  
  1749. if getElementData(v,"loggedin") then
  1750.  
  1751. if itemCache[v] then
  1752.  
  1753. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]] then
  1754.  
  1755. for i = 1, row * column do
  1756.  
  1757. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i] then
  1758.  
  1759. if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"] == tonumber(item) and tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["value"]) == tonumber(value) then
  1760.  
  1761. itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"]))[1]][tonumber(i)] = nil
  1762.  
  1763. if isElement(getElementData(v,"show:inv")) and getElementType(getElementData(v,"show:inv")) == "player" then
  1764.  
  1765. getElementItems(v,v,2)
  1766.  
  1767. end
  1768.  
  1769. end
  1770.  
  1771. end
  1772.  
  1773. end
  1774.  
  1775. end
  1776.  
  1777. end
  1778.  
  1779. end
  1780.  
  1781. end
  1782.  
  1783.  
  1784.  
  1785. dbQuery(function(query)
  1786.  
  1787. local query, query_lines = dbPoll(query, 0)
  1788.  
  1789. for k, row in pairs (query) do
  1790.  
  1791. dbExec(func["dbConnect"],"DELETE FROM `items` WHERE `id` = ?",row["id"])
  1792.  
  1793. end
  1794.  
  1795. end, func["dbConnect"], "SELECT * FROM `items` WHERE `value` = ? AND `itemid` = ?",tonumber(value),tonumber(item))
  1796.  
  1797. end
  1798.  
  1799.  
  1800.  
  1801. function RemovePlayerDutyItems(element) -- duty cuccok
  1802.  
  1803. if element and itemCache[element] and itemCache[element]["bag"] then
  1804.  
  1805. for i = 1, row * column do
  1806.  
  1807. if (itemCache[element]["bag"][i]) then
  1808.  
  1809. if itemCache[element]["bag"][i]["duty"] == 1 then
  1810.  
  1811. if weaponModels[itemCache[element]["bag"][i]["id"]] then
  1812.  
  1813. delAttachWeapon(element,itemCache[element]["bag"][i]["id"],itemCache[element]["bag"][i]["value"],itemCache[element]["bag"][i]["dbid"])
  1814.  
  1815. end
  1816.  
  1817. deleteItem(element,element,itemCache[element]["bag"][i])
  1818.  
  1819. end
  1820.  
  1821. end
  1822.  
  1823. end
  1824.  
  1825. end
  1826.  
  1827. end
  1828.  
  1829. addEvent("RemovePlayerDutyItems", true)
  1830.  
  1831. addEventHandler("RemovePlayerDutyItems",getRootElement(),RemovePlayerDutyItems)
  1832.  
  1833.  
  1834.  
  1835. function deleteItemByID(element, itemID, itemPrice)
  1836.  
  1837. for k,v in ipairs(getElementsByType("player")) do
  1838.  
  1839. if getElementData(v,"loggedin") then
  1840.  
  1841. if itemCache[v] then
  1842.  
  1843. if itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]] then
  1844.  
  1845. for i = 1, row * column do
  1846.  
  1847. if itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]][i] then
  1848.  
  1849. if itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]][i]["id"] == tonumber(itemID) then
  1850.  
  1851. itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]][i]["id"]))[1]][tonumber(i)] = nil
  1852.  
  1853. if isElement(getElementData(v,"show:inv")) and getElementType(getElementData(v,"show:inv")) == "player" then
  1854.  
  1855. getElementItems(v,v,2)
  1856.  
  1857. end
  1858.  
  1859. end
  1860.  
  1861. end
  1862.  
  1863. end
  1864.  
  1865. end
  1866.  
  1867. end
  1868.  
  1869. end
  1870.  
  1871. end
  1872.  
  1873. dbQuery(function(query)
  1874.  
  1875. local query, query_lines = dbPoll(query, 0)
  1876.  
  1877. for k, row in pairs (query) do
  1878.  
  1879. dbExec(func["dbConnect"],"DELETE FROM `items` WHERE `id` = ?",row["id"])
  1880.  
  1881. end
  1882.  
  1883. end, func["dbConnect"], "SELECT * FROM `items` WHERE `itemid` = ?",tonumber(itemID))
  1884.  
  1885. end
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893. function addAttachWeapon(playerSource,item,value,dbid)
  1894.  
  1895. --[[
  1896.  
  1897. if not weapons[playerSource] then
  1898.  
  1899. weapons[playerSource] = {}
  1900.  
  1901. end
  1902.  
  1903. if not isElement(weapons[playerSource][dbid]) or not weapons[playerSource][dbid] then
  1904.  
  1905. local x,y,z = getElementPosition(playerSource)
  1906.  
  1907. if weaponModels[item] then
  1908.  
  1909. weapons[playerSource][dbid] = createObject(weaponModels[item][1],x,y,z)
  1910.  
  1911. setElementInterior(weapons[playerSource][dbid],getElementInterior(playerSource))
  1912.  
  1913. setElementDimension(weapons[playerSource][dbid],getElementDimension(playerSource))
  1914.  
  1915. setElementData(weapons[playerSource][dbid],"attachedObject",true)
  1916.  
  1917.  
  1918.  
  1919. if tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 264 then
  1920.  
  1921. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/camo")
  1922.  
  1923. elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 265 then
  1924.  
  1925. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/camo2")
  1926.  
  1927. elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 266 then
  1928.  
  1929. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/camo3")
  1930.  
  1931. elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 267 then
  1932.  
  1933. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/gold")
  1934.  
  1935. elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 268 then
  1936.  
  1937. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/gold2")
  1938.  
  1939. elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 269 then
  1940.  
  1941. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/silver")
  1942.  
  1943. elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 270 then
  1944.  
  1945. exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/kitty")
  1946.  
  1947. end
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953. exports.bone_attach:attachElementToBone(weapons[playerSource][dbid], playerSource,weaponPositions[tonumber(weaponIndexByID[item])][1],weaponPositions[tonumber(weaponIndexByID[item])][2],weaponPositions[tonumber(weaponIndexByID[item])][3],weaponPositions[tonumber(weaponIndexByID[item])][4],weaponPositions[tonumber(weaponIndexByID[item])][5],weaponPositions[tonumber(weaponIndexByID[item])][6],weaponPositions[tonumber(weaponIndexByID[item])][7])
  1954.  
  1955. end
  1956.  
  1957. end
  1958.  
  1959. ]]
  1960.  
  1961. end
  1962.  
  1963. addEvent("addAttachWeapon",true)
  1964.  
  1965. addEventHandler("addAttachWeapon",getRootElement(),addAttachWeapon)
  1966.  
  1967.  
  1968.  
  1969. function delAttachWeapon(playerSource,item,value,dbid)
  1970.  
  1971. --[[
  1972.  
  1973. if weapons[playerSource] then
  1974.  
  1975. if isElement(weapons[playerSource][dbid]) then
  1976.  
  1977. if tonumber(item) == 84 and tonumber(value) == 20 then
  1978.  
  1979. exports["rise_weapontuning"]:removeStickerFromObject(object)
  1980.  
  1981. end
  1982.  
  1983. exports.bone_attach:detachElementFromBone(weapons[playerSource][dbid])
  1984.  
  1985. destroyElement(weapons[playerSource][dbid])
  1986.  
  1987. weapons[playerSource][dbid] = {}
  1988.  
  1989. end
  1990.  
  1991. end
  1992.  
  1993. ]]
  1994.  
  1995. end
  1996.  
  1997. addEvent("delAttachWeapon",true)
  1998.  
  1999. addEventHandler("delAttachWeapon",getRootElement(),delAttachWeapon)
  2000.  
  2001.  
  2002.  
  2003. addEventHandler("onPlayerQuit",getRootElement(),function()
  2004.  
  2005. if getElementData(source,"loggedin") then
  2006.  
  2007. saveOneElementInventory(source)
  2008.  
  2009. for i = 1, row * column do
  2010.  
  2011. if (itemCache[source]["bag"][i]) then
  2012.  
  2013. if weapons[source] then
  2014.  
  2015. if isElement(weapons[source][itemCache[source]["bag"][i]["dbid"]]) then
  2016.  
  2017. exports.bone_attach:detachElementFromBone(weapons[source][itemCache[source]["bag"][i]["dbid"]])
  2018.  
  2019. destroyElement(weapons[source][itemCache[source]["bag"][i]["dbid"]])
  2020.  
  2021. end
  2022.  
  2023. end
  2024.  
  2025. end
  2026.  
  2027. end
  2028.  
  2029. weapons[source] = {}
  2030.  
  2031. end
  2032.  
  2033. end)
  2034.  
  2035.  
  2036.  
  2037. --Actionbar server--
  2038.  
  2039.  
  2040.  
  2041. addEvent("moveItemToActionBar",true)
  2042.  
  2043. addEventHandler("moveItemToActionBar", getRootElement(),function(playerSource,itemdbid,item,category,actionslot)
  2044.  
  2045.  
  2046.  
  2047. local dbid = tonumber(getElementData(playerSource, "acc:id"))
  2048.  
  2049. dbExec(func["dbConnect"],"INSERT INTO actionbaritems SET itemdbid = ?, item = ?, owner = ?, category = ?, actionslot = ?",itemdbid,item,dbid,category,actionslot)
  2050.  
  2051. end)
  2052.  
  2053.  
  2054.  
  2055. function deleteActionBarItem(player,actionslot)
  2056.  
  2057. local dbid = tonumber(getElementData(player, "acc:id"))
  2058.  
  2059. dbExec(func["dbConnect"], "DELETE FROM `actionbaritems` WHERE owner=? and actionslot=?", dbid, actionslot)
  2060.  
  2061. end
  2062.  
  2063. addEvent("deleteActionBarItem",true)
  2064.  
  2065. addEventHandler("deleteActionBarItem", getRootElement(), deleteActionBarItem)
  2066.  
  2067.  
  2068.  
  2069. function loadActionBarItems(playerSource)
  2070.  
  2071. local dbid = getElementData(playerSource,"acc:id")
  2072.  
  2073. local loadedTables = {}
  2074.  
  2075. dbQuery(function(qh)
  2076.  
  2077. local res, rows, err = dbPoll(qh, 0)
  2078.  
  2079. if rows > 0 then
  2080.  
  2081. for k, row in pairs(res) do
  2082.  
  2083. loadedTables[#loadedTables+1] = {["id"] = tonumber(row["id"]),["owner"] = tonumber(row["owner"]),["itemdbid"] = tonumber(row["itemdbid"]),["item"] = tonumber(row["item"]),["category"] = tostring(row["category"]),["actionslot"] = tonumber(row["actionslot"])}
  2084.  
  2085. end
  2086.  
  2087. end
  2088.  
  2089. triggerClientEvent(playerSource,"actionBarEvent",playerSource,playerSource,loadedTables)
  2090.  
  2091. end,func["dbConnect"],"SELECT * FROM actionbaritems WHERE owner=?",dbid)
  2092.  
  2093. end
  2094.  
  2095. addEvent("loadActionBarItems",true)
  2096.  
  2097. addEventHandler("loadActionBarItems",getRootElement(),loadActionBarItems)
  2098.  
  2099.  
  2100.  
  2101. addEvent("takeTicket",true)
  2102.  
  2103. addEventHandler("takeTicket",getRootElement(),function(playerSource,id)
  2104.  
  2105. dbQuery(function(query)
  2106.  
  2107. local query, query_lines = dbPoll(query, 0)
  2108.  
  2109. for k, row in pairs (query) do
  2110.  
  2111. outputChatBox("[RiseMTA]:#ffffff Mivel nem fizetted be a csekket, ezért a bírság összegének a dupláját vonta le a rendszer, ami #ACD373"..(row["amount"]*2).."#ffffff dollár.",playerSource,172, 211, 115,true)
  2112.  
  2113. setElementData(playerSource,"money",getElementData(playerSource,"money") -(row["amount"]*2))
  2114.  
  2115. dbExec(func["dbConnect"], "DELETE FROM `tickets` WHERE id=?",id)
  2116.  
  2117. end
  2118.  
  2119. end, func["dbConnect"], "SELECT * FROM `tickets` WHERE `id` = ?", tonumber(id))
  2120.  
  2121. end)
Add Comment
Please, Sign In to add comment