Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.29 KB | None | 0 0
  1. if fileExists("client.lua") then
  2. fileDelete("client.lua")
  3. end
  4.  
  5. local monitorSize = {guiGetScreenSize()}
  6. local show = false
  7. local Elsolepes = false
  8. local create = false
  9. local createEdit = false
  10. local cursorinInventory = false
  11. local item_table_player = {}
  12. local item_table_action = {}
  13. local itemElement = nil
  14. local item_size = 40
  15. local sor, oszlop, margin = 0, 0, 0
  16. local font = dxCreateFont("files/fonts/myriadproregular.ttf",9) --<[ Font ]>--
  17. local font2 = dxCreateFont("files/fonts/myriadproregular.ttf",10) --<[ Font ]>--
  18. local Tick = getTickCount()
  19. local actionbarSlot = 6
  20. local tooltip_text_color = tocolor(255, 255, 255, 255)
  21. local clickedSlot = -1
  22. local movedSlot = -1
  23. local cloneSlot = -1
  24. local clickedItem = -1
  25. local movedItem = -1
  26. local cloneItem = -1
  27. local clickedCount = -1
  28. local movedCount = -1
  29. local cloneCount = -1
  30. local clickedValue = -1
  31. local movedValue = -1
  32. local cloneValue = -1
  33. local clickDown = nil
  34. local currentSlot = -1
  35. local cursorIsActionbar = false
  36. local moving = true
  37. local currentItem = 0
  38. local currentCount = 0
  39. local weight = 0
  40. local currentValue = 0
  41. local countText = ""
  42. local clientActionSlot = 0
  43. local statisztikaSzazaleka = 0
  44. local hasznaloSlot = -1
  45. local hasznaloItem = -1
  46. local hasznaloCount = -1
  47. local hasznaloValue = -1
  48. local showAction = true
  49. local moveOffsetX, moveOffsetY = 0, 0
  50.  
  51.  
  52. local weaponTable = {
  53. [14] = true,
  54. [15] = true,
  55. [16] = true,
  56. [17] = true,
  57. [18] = true,
  58. [22] = true,
  59. [23] = true,
  60. [24] = true,
  61. [25] = true,
  62. }
  63.  
  64. local jugadores = {}
  65. local lplayer = getLocalPlayer()
  66. local info = {}
  67. local sx,sy = guiGetScreenSize()
  68. local slotok = {}
  69.  
  70. local playerWeaponTable = {}
  71. local lplayer = getLocalPlayer()
  72. local info = {}
  73. local sx,sy = guiGetScreenSize()
  74. local weaponsTable = {14,15,16,17,18,20,22,23,24}
  75.  
  76. for i=1, actionbarSlot do
  77. item_table_action[i] = {-1, -1, -1}
  78. end
  79.  
  80. for i = 0 , 50 do
  81. setElementData(localPlayer, "char:fishing"..i, false)
  82. setElementData(localPlayer, "char:weaponGettin"..i, false)
  83. setElementData(localPlayer, "char:badge"..i, false)
  84. end
  85. for _, value in ipairs (getElementsByType("vehicle")) do
  86. setElementData(value, "inUse", false)
  87. setElementData(value, "clickToVehicle", 0)
  88. end
  89.  
  90. setElementData(localPlayer, "char:vehicle", false)
  91.  
  92. function getItemImg(item)
  93. return fileExists("files/items/"..item..".png") and "files/items/"..item..".png" or "files/items/0.png"
  94. end
  95.  
  96. function receiveItems(data)
  97. item_table = {}
  98. item_table = data
  99.  
  100. if(itemElement and getElementType(itemElement) == "player" and itemElement == localPlayer or itemElement==nil )then
  101. item_table_player = data
  102. for index, value in ipairs (item_table) do
  103. if value[5] > 0 then
  104. item_table_action[tonumber(value[5])] = {item_table[tonumber(index)][6], item_table[tonumber(index)][1], item_table[tonumber(index)][3]}
  105. end
  106. end
  107. end
  108.  
  109. isMove = false
  110. movedItem = 0
  111. newCount = 0
  112. movedSlot = -1
  113. movedCount = 0
  114. movedValue = 0
  115. selectedAmount = 0
  116. currentActionSlot = 0
  117. end
  118. addEvent("onClientReceiveItems", true)
  119. addEventHandler("onClientReceiveItems", getRootElement(), receiveItems)
  120.  
  121. addEventHandler("onClientElementDataChange", getRootElement(), function(dataName)
  122. if source and getElementType(source) == "player" and source == localPlayer and dataName == "loggedin" then
  123. setTimer(function()
  124. triggerServerEvent("playerLoadItemsToServer", localPlayer, localPlayer)
  125. --streamedIn()
  126. end, 1000, 1)
  127. end
  128. end)
  129.  
  130. function isInSlot(xS,yS,wS,hS)
  131. if(isCursorShowing()) then
  132. XY = {guiGetScreenSize()}
  133. local cursorX, cursorY = getCursorPosition()
  134. cursorX, cursorY = cursorX*XY[1], cursorY*XY[2]
  135. if(dobozbaVan(xS,yS,wS,hS, cursorX, cursorY)) then
  136. return true
  137. else
  138. return false
  139. end
  140. end
  141. end
  142.  
  143. function dobozbaVan(dX, dY, dSZ, dM, eX, eY)
  144. if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then
  145. return true
  146. else
  147. return false
  148. end
  149. end
  150.  
  151. function checkCursor()
  152. if not guiGetInputEnabled() and not isMTAWindowActive() and isCursorShowing( ) then
  153. return true
  154. else
  155. return false
  156. end
  157. end
  158.  
  159. function getCursorPos()
  160. if checkCursor() then
  161. cx,cy = getCursorPosition ()
  162. cx,cy = cx*panelX,cy*panelY
  163. else
  164. cx,cy = -500,-500
  165. end
  166. return cx,cy
  167. end
  168.  
  169. function isInBox( xmin, ymin, xmax, ymax )
  170. if checkCursor() then
  171. x,y = getCursorPos()
  172. xmin = tonumber(xmin) or 0
  173. xmax = (tonumber(xmax) or 0)+xmin
  174. ymin = tonumber(ymin) or 0
  175. ymax = (tonumber(ymax) or 0)+ymin
  176. return x >= xmin and x <= xmax and y >= ymin and y <= ymax
  177. else
  178. return false
  179. end
  180. end
  181.  
  182. function dxDrawRectangleBox(left, top, width, height)
  183. --dxDrawRectangle(left, top, width, height, tocolor(71, 167, 223,50))
  184. dxDrawRectangle(left-1, top, 1, height, tocolor(71, 167, 223,230))
  185. dxDrawRectangle(left+width, top, 1, height, tocolor(71, 167, 223,230))
  186. dxDrawRectangle(left, top-1, width, 1, tocolor(71, 167, 223,230))
  187. dxDrawRectangle(left, top+height, width, 1, tocolor(71, 167, 223,230))
  188. end
  189.  
  190. function getSlot(slot)
  191. slot = slot + 1
  192. if not item_table then
  193. item_table = {}
  194. end
  195.  
  196. if(item_table[slot] and item_table[slot][1])then
  197. return item_table[slot][1]
  198. else
  199. return -1
  200. end
  201. end
  202.  
  203. function getItemCountNormal()
  204. local c = 0
  205. local item = 50
  206. for i=1, item do
  207. if(item_table[element][i][1]>-1)then
  208. c = c + 1
  209. end
  210. end
  211. k = c
  212. return k
  213. end
  214.  
  215. function getSlotCount(slot)
  216. slot = slot + 1
  217. if item_table[slot] then
  218. if(item_table[slot][3])then
  219. return item_table[slot][3]
  220. else
  221. return 1
  222. end
  223. end
  224. end
  225.  
  226. function math.round(number, decimals, method)
  227. decimals = decimals or 0
  228. local factor = 10 ^ decimals
  229. if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
  230. else return tonumber(("%."..decimals.."f"):format(number)) end
  231. end
  232.  
  233. function getSlotValue(slot)
  234. slot = slot + 1
  235. if item_table[slot] then
  236. if (item_table[slot][2])then
  237. return item_table[slot][2]
  238. else
  239. return 0
  240. end
  241. end
  242. end
  243.  
  244. addEventHandler("onClientClick", root, function(key, state, cx, cy)
  245. if show then
  246. if key == "left" and state == "down" then
  247. if cx >= panelX and cx <= panelX+width then
  248. if cy >= panelY and cy <= panelY+25 then
  249. moveOffset = true
  250. moveOffsetX, moveOffsetY = cx-panelX, cy-panelY
  251. end
  252. end
  253. else
  254. moveOffset = false
  255. end
  256. end
  257. end)
  258.  
  259. function setSlotValue(slot, item, val, db, duty)
  260. slot = slot + 1
  261. if (not item) then item = 0 end
  262. if (not val) then val = 0 end
  263. if (not db) then db = 1 end
  264. item_table[slot] = {item, val, db, -1, -1, slot, duty}
  265. triggerServerEvent("updateValue", itemElement, itemElement, slot, item, val, db, duty)
  266. end
  267.  
  268. function hasItem(element, itemID, itemValue)
  269. if element == localPlayer then
  270. if itemValue then
  271. for k,v in pairs(item_table) do
  272. if v[1] == itemID and tonumber(v[2]) == tonumber(itemValue) then
  273. return true, k, v[2], v[3]
  274. end
  275. end
  276. else
  277. for k,v in pairs(item_table) do
  278. if v[1] == itemID then
  279. return true, k, v[2], v[3]
  280. end
  281. end
  282. end
  283. end
  284. return false
  285. end
  286.  
  287. function getPlayeritems(element)
  288. if element then
  289. return item_table
  290. end
  291. end
  292.  
  293. function deleteItem(element, slot)
  294. if not element and not slot then return end
  295. triggerServerEvent("deleteSlot", element, element, slot)
  296. end
  297.  
  298. function getPlayerItem(itemID)
  299. if not itemID then return end
  300. for k,v in pairs(item_table) do
  301. if v[1] == itemID then
  302. modositItemCountIfWant(v[6])
  303. break
  304. end
  305. end
  306. end
  307.  
  308. function openInventory(element)
  309. itemElement = element
  310. if not (create and item_table) then
  311. create = true
  312. --triggerServerEvent("sendPlayerItemsToClient", getLocalPlayer(), getLocalPlayer(), getLocalPlayer())
  313. triggerServerEvent("triggerItemsByType", localPlayer, itemElement)
  314. end
  315. end
  316.  
  317. for i=1, actionbarSlot do
  318. bindKey(i, "down", function()
  319. if isTimer(timer) then return end
  320. timer = setTimer(function() end, 2000, 1) --- spam védelem
  321. if item_table_action[i] and item_table_action[i][2] > -1 and hasItem(localPlayer, item_table_action[i][2]) then
  322. useItem(item_table[item_table_action[i][1]][4], item_table[item_table_action[i][1]][6], item_table[item_table_action[i][1]][1], item_table[item_table_action[i][1]][2], item_table[item_table_action[i][1]][3])
  323. end
  324. if item_table_action[i] and item_table_action[i][1] and item_table[item_table_action[i][1]][3] < 1 and hasItem(localPlayer, item_table_action[i][2]) then
  325. item_table_action[i] = {-1, -1, -1}
  326. end
  327. end)
  328. end
  329.  
  330. function split(text, delimeter)
  331. local result = {}
  332. for match in (text..delimeter):gmatch("(.-)"..delimeter) do
  333. result[#result + 1] = match
  334. end
  335. return result
  336. end
  337.  
  338. function getItemsWeight()
  339. local weight = 0
  340. if(item_table)then
  341. for i=1, 50 do
  342. if(item_table[i] and item_table[i][1]>0)then
  343. weight = weight + getItemWeight(item_table[i][1])*item_table[i][3]
  344. end
  345. end
  346. end
  347. return weight
  348. end
  349.  
  350. function getMaxWeight()
  351. if(tostring(getElementType(itemElement))=="player")then
  352. return 25
  353. elseif(tostring(getElementType(itemElement))=="vehicle")then
  354. return 50
  355. elseif(tostring(getElementType(itemElement))=="object")then
  356. return 100
  357. end
  358. return 0
  359. end
  360.  
  361. addCommandHandler("seeinv", function(cmd, name)
  362. if getElementData(localPlayer,"acc:admin") <= 1 then
  363. return
  364. end
  365. if(not name)then
  366. outputChatBox("#47a7df[Használat]: #ffffff/"..cmd.." [Név]",0,0,0,true)
  367. return
  368. end
  369. local targetPlayer, targetPlayerName = exports.mta_main:findPlayer(getLocalPlayer(), name)
  370. if(not targetPlayer)then
  371. return
  372. end
  373. openInventory(targetPlayer)
  374. show = true
  375. Elsolepes = true
  376. Tick = getTickCount()
  377. progress = "OutBack"
  378. showAction = false
  379. toggleControl ("fire", false)
  380. playSound("files/sounds/open.mp3", false)
  381.  
  382. moving = false
  383. end)
  384.  
  385. function checkPlayerInventory(Player)
  386. openInventory(Player)
  387. show = true
  388. Elsolepes = true
  389. Tick = getTickCount()
  390. progress = "OutBack"
  391. showAction = false
  392. toggleControl ("fire", false)
  393. playSound("files/sounds/open.mp3", false)
  394.  
  395. moving = false
  396. end
  397.  
  398. function createInventory()
  399. ------ActionBar
  400. if not getElementData(localPlayer, "loggedin") then return end
  401. if not getElementData(localPlayer, "toggle-->All") then return end
  402. if isPedDead(localPlayer) then return end
  403. monitorSize = {guiGetScreenSize()}
  404. if showAction then
  405. clientActionSlot = -1
  406. local width, height = item_size*actionbarSlot + 5*(actionbarSlot+1)
  407. dxDrawRectangle(monitorSize[1]/2-width/2, monitorSize[2]-60+5-5, width, item_size+10, tocolor(0, 0, 0, 200))
  408. if (isInSlot(monitorSize[1]/2-width/2, monitorSize[2]-60+5-5, width, item_size+10)) then
  409. cursorIsActionbar = true
  410. else
  411. cursorIsActionbar = false
  412. end
  413. for i= 1, actionbarSlot do
  414. dxDrawRectangle(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5, monitorSize[2]-60+5, item_size, item_size, tocolor(255, 255, 255, 20))
  415. if getKeyState(i) then
  416. dxDrawRectangle(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5+2, monitorSize[2]-60+5+2, item_size-4, item_size-4, tocolor(71, 167, 223, 100))
  417. end
  418. if isInSlot(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5, monitorSize[2]-60+5, item_size, item_size) then
  419. dxDrawRectangle(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5, monitorSize[2]-60+5, item_size, item_size, tocolor(71, 167, 223, 100))
  420. clientActionSlot = i
  421. end
  422. if(item_table_action[i] and item_table_action[i][1]>-1 and hasItem(localPlayer, item_table_action[i][2]))then
  423. dxDrawImage(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5, monitorSize[2]-60+5, item_size, item_size, getItemImg(item_table_action[i][2]), 0, 0, 0, tocolor(255,255,255,255), false) --Item
  424. if item_table[item_table_action[i][1]] and item_table[item_table_action[i][1]][3] > 1 then
  425. dxDrawText(item_table[item_table_action[i][1]][3], monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-2, monitorSize[2]-60+5+item_size-15+1, item_size, item_size, tocolor(0, 0, 0, 255), 1, font, "left", "top", false, false, false, true)
  426. dxDrawText(item_table[item_table_action[i][1]][3], monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-1, monitorSize[2]-60+5+item_size-15, item_size, item_size, tocolor(255, 255, 255, 255), 1, font, "left", "top", false, false, false, true)
  427. end
  428. if isInSlot(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5, monitorSize[2]-60+5, item_size, item_size, item_size, item_size) or getKeyState(i) then
  429. dxDrawRectangleBox(monitorSize[1]/2-width/2 + 5 + item_size*(i-1) + 5*i-5, monitorSize[2]-60+5, item_size, item_size)
  430. end
  431. end
  432. end
  433. end
  434.  
  435. --------------------------------------------------------------------------
  436. -------------------------- Inventory ---------------------------------------
  437. sor, oszlop, margin = 5, 10, 5 -- 2 * 5 = 10 Slot
  438.  
  439. width, height = item_size*oszlop + margin*(oszlop+1), item_size * sor + (1+sor)*margin
  440. clickedSlot = -1
  441. clickedItem = -1
  442. if create then
  443. if Elsolepes then
  444. local Time = (getTickCount() - Tick) / 1000
  445. if Time < 1 then
  446. panelY = interpolateBetween(-width,0,0,monitorSize[2]/2-height/2,0,0,Time,progress)
  447. if moveOffsetX == 0 then
  448. panelX = monitorSize[1]-width - 55
  449. else
  450. --panelX = panelX
  451. panelX = monitorSize[1]-width - 55
  452. end
  453. end
  454. elseif not Elsolepes then
  455. if panelY ~= 0-width then
  456. local Time = (getTickCount() - Tick) / 1000
  457. panelY = interpolateBetween(panelY,0,0,-width,0,0,Time,progress)
  458. panelX = monitorSize[1]-width - 55
  459. else
  460. show = false
  461. create = false
  462. toggleControl ("fire", true)
  463. end
  464. end
  465.  
  466. local name = "Ismeretlen"
  467. if(getElementType(itemElement)=="player")then
  468. name = "Inventory"
  469. elseif(getElementType(itemElement)=="vehicle")then
  470. name = "Csomagtartó"
  471. elseif(getElementType(itemElement)=="object")then
  472. name = "Széf"
  473. end
  474.  
  475. if(isInSlot(panelX, panelY, width+20, height+60))then
  476. cursorinInventory = true
  477. else
  478. cursorinInventory = false
  479. end
  480.  
  481. if isCursorShowing() and moveOffset then
  482. local cx, cy = getCursorPosition()
  483. local cx, cy = cx*monitorSize[1], cy*monitorSize[2]
  484.  
  485. panelX = cx-moveOffsetX
  486. panelY = cy-moveOffsetY
  487. end
  488.  
  489. dxDrawRectangle(panelX, panelY, width+20, height+40, tocolor(0, 0, 0, 200)) -- Bg
  490. dxDrawRectangle(panelX, panelY, width+20, 25, tocolor(0, 0, 0, 230))-- Felirat hattere
  491. dxDrawRectangle(panelX, panelY+25, width+20, 3, tocolor(71, 167, 223, 230))--Zöld vonal
  492. dxDrawText("Northen Life MTA - #47a7df"..name, panelX+5, panelY+5, width+10, 3, tocolor(255, 255, 255, 255), 1, font, "left", "top", false, false, false, true)
  493. dxDrawText("Mennyiség: ", panelX+5+width-135, panelY+4, width+10, 3, tocolor(255, 255, 255, 255), 1, font, "left", "top", false, false, false, true)
  494. if isElement(btn_edit) then
  495. countText = guiGetText(btn_edit)
  496. if countText == "" then
  497. countText = ""
  498. end
  499. if tonumber(countText) then
  500. dxDrawText(countText, panelX+width-63, panelY+5, 80, 15, tocolor(255, 255, 255, 255), 1, font, "left", "top", false, false, false, true)
  501. else
  502. dxDrawText("Csak számot", panelX+width-63, panelY+5, 80, 15, tocolor(255, 255, 255, 255), 1, font, "left", "top", false, false, false, true)
  503. end
  504. end
  505. dxDrawRectangle(panelX+width-65, panelY+5, 80, 15, tocolor(255, 255, 255, 80))-- mennyiség hattere
  506. dxDrawImage(panelX+(width-200)/2, panelY+height/2, 200, 50, "files/images/logo.png", 0, 0, 0, tocolor(255, 255, 255, 80)) ---<[ LOGO ]>---
  507.  
  508.  
  509. local j_old = 0
  510. local itembg = 0
  511. local i = 0
  512. local isMove = false
  513. local weight = getItemsWeight()
  514. local weights = 0
  515. for szam=0, (oszlop*sor)-1 do
  516. local j = math.floor(szam/oszlop)
  517. if(j~=j_old)then
  518. i = 0
  519. end
  520.  
  521. --if item_table[szam + 1] then
  522. local item = getSlot(szam)
  523. local value = getSlotValue(szam)
  524. local count = getSlotCount(szam)
  525. dxDrawRectangle(panelX+10 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size, item_size, item_size, tocolor(255, 255, 255, 20)) -- Item BG
  526. if(item>-1) and (show)then
  527. weights = weights +1
  528. isMove = clickDown and movedItem and ( getTickCount( ) - clickDown >= 130 )
  529. if(not(isMove and movedItem==item and movedSlot==szam)) and item_table[szam + 1] then
  530. dxDrawImage(panelX+10 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size, item_size, item_size, getItemImg(item), 0, 0, 0, tocolor(255,255,255, 255)) --Item IMG
  531. if count > 1 then
  532. dxDrawText(count, panelX+12 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size+item_size-16 , item_size, item_size, tocolor(0, 0, 0, 255), 1, font, "left", "top", false, false, false, true)
  533. dxDrawText(count, panelX+13 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size+item_size-15 , item_size, item_size, tocolor(255, 255, 255, 255), 1, font, "left", "top", false, false, false, true)
  534. end
  535.  
  536. end
  537. end
  538. if isInSlot(panelX+10 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size, item_size, item_size) then
  539. clickedSlot = szam
  540. clickedItem = item
  541. clickedCount = count
  542. clickedValue = value
  543. if (item == -1) then
  544. dxDrawRectangle(panelX+10 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size, item_size, item_size, tocolor(71, 167, 223,170)) -- Item BG Hover
  545. elseif (item >= -1) then
  546. dxDrawRectangleBox(panelX+10 + i*item_size + (i+1)*margin, panelY+29 + (j+1)*margin + j*item_size, item_size, item_size)
  547. tooltip_items(getItemName(item, value))
  548. end
  549. end
  550. i = i + 1
  551. j_old = j
  552. --end
  553. end
  554. dxDrawRectangle(panelX+width+margin*2+12, panelY+28, 26, height+12, tocolor(0, 0, 0, 170))-- súly hattere
  555. dxDrawRectangle(panelX+width+margin*2+13, panelY+29+height+10, 24, (-height-10)*weight/getMaxWeight(), tocolor(71, 167, 223, 230))-- súly
  556. --dxDrawText("Súly: "..math.floor(weights).."/50", panelX+7+(width)/2+1, panelY+height+30+2+20/2+1, panelX+7+(width)/2+1, panelY+height+30+2+20/2+1, tocolor(0, 0, 0, 255), 1, font2, "center", "center", false, false, false, true)
  557. -- dxDrawText("Súly: "..math.floor(weights).."/50", panelX+7+(width)/2, panelY+height+30+2+20/2, panelX+7+(width)/2, panelY+height+30+2+20/2, tocolor(255, 255, 255, 255), 1, font2, "center", "center", false, false, false, true)
  558. if(isMove and movedItem>-1 and movedSlot>-1 ) and (show) then
  559. local x,y = getCursorPosition( )
  560. local x,y = x * monitorSize[1]-item_size/2, y * monitorSize[2]-item_size/2
  561. dxDrawImage(x,y, item_size, item_size, getItemImg(movedItem), 0, 0, 0, tocolor(255,255,255, 255)) --Item Move
  562. dxDrawRectangleBox(x,y, item_size, item_size)
  563. end
  564. if(isMove and cloneItem>-1 and cloneSlot>-1 and cloneCount>1 ) and (show)then
  565. dxDrawImage(cx - item_size/2, cy - item_size/2, item_size, item_size, getItemImg(cloneItem), 0, 0, 0, tocolor(255,255,255, 255)) --Item Move
  566. tooltip_items(getItemName(item, value))
  567. end
  568. end
  569. end
  570. addEventHandler("onClientRender", root ,createInventory)
  571.  
  572. bindKey("i", "down", function ()
  573. if not getElementData(localPlayer, "loggedin") or false then return end
  574.  
  575. if isPedDead(localPlayer) then
  576. outputChatBox("#D24D57[Northen Life MTA]: #ffffff Halottan nem tudod megnyitni az inventory-t.",255, 255, 255, true)
  577. return
  578. end
  579.  
  580. --if isTimer(timer) then outputChatBox("anyádat flúdold te cigány kurva") return end
  581. --timer = setTimer(function() end, 3000, 1) --- spam védelem
  582.  
  583. showCursor(not show)
  584.  
  585. if not show then
  586. show = true
  587. setElementData(localPlayer, "char:vehicle", false)
  588. Elsolepes = true
  589. Tick = getTickCount()
  590. openInventory(localPlayer)
  591. progress = "OutBack"
  592. showAction = true
  593. toggleControl ("fire", false)
  594. moving = true
  595. moveOffset = false
  596. --moveOffsetX, moveOffsetY = 0, 0
  597. playSound("files/sounds/open.mp3", false)
  598. else
  599. Tick = getTickCount()
  600. Elsolepes = false
  601. showAction = true
  602. setElementData(itemElement, "inUse", false)
  603. createEdit = true
  604. cursorinInventory = false
  605. progress = "OutBack"
  606. toggleControl ("fire", true)
  607. createEditFunction("remove")
  608. countText = ""
  609. isMove = false
  610. movedItem = 0
  611. newCount = 0
  612. statisztikaSzazaleka = 0
  613. movedSlot = -1
  614. movedCount = 0
  615. movedValue = 0
  616. selectedAmount = 0
  617. if getElementType(itemElement)=="vehicle" then
  618. triggerServerEvent("doorState", itemElement, itemElement, 0)
  619. setElementData(itemElement, "clickToVehicle", 0)
  620. setElementData(itemElement, "inUse", false)
  621. setElementData(localPlayer, "char:vehicle", false)
  622. end
  623. hasznaloSlot = -1
  624. hasznaloItem = -1
  625. hasznaloCount = -1
  626. hasznaloValue = -1
  627. playSound("files/sounds/close.mp3", false)
  628. end
  629. end)
  630.  
  631. addEventHandler( "onPlayerNetworkStatus", root,
  632. function( status, ticks )
  633. if status == 0 then
  634. outputDebugString( "(packets from " .. getPlayerName(source) .. ") interruption began " .. ticks .. " ticks ago" )
  635. elseif status == 1 then
  636. outputDebugString( "(packets from " .. getPlayerName(source) .. ") interruption began " .. ticks .. " ticks ago and has just ended" )
  637. end
  638. end
  639. )
  640.  
  641. function packetLossCheck()
  642. local loss = getNetworkStats()["messagesInSendBuffer"]
  643. if (loss > 0) then
  644. moving = false
  645. destroyItemMove()
  646. else
  647. --moving = true
  648. end
  649. end
  650. setTimer(packetLossCheck, 1000, 0) -- Ezt kell most kuhúzni de akkor majd lehet bugoltatni tesó.
  651.  
  652. local rovid = "#D24D57[Northen Life MTA]:#FFFFFF"
  653.  
  654.  
  655. local clickNumber = 0
  656. addEventHandler("onClientClick", getRootElement(), function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
  657. if (getPlayerPing(localPlayer) > 220) then return outputChatBox("#47a7df[Item figyelő] #ff0000FIGYELEM! #ffffffNagy ping érzékelve! Amíg nem kezdesz valamit a pingeddel az összes #3399ffitem műveletet#ffffff letiltottuk!", 255, 255, 255, true) end
  658. packetLossCheck()
  659. if(button=="right" and state=="down")then
  660. if(not cursorinInventory and not create and isElement(clickedElement) and tostring(getElementType(clickedElement))~=false)then
  661. if(getElementType(clickedElement)=="vehicle" and (getElementData(clickedElement, "veh:id") or -1)>0)then
  662. local x,y,z = getElementPosition(getLocalPlayer())
  663. local x2,y2,z2 = getElementPosition(clickedElement)
  664. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  665. if not getElementData(clickedElement, "inUse") or tonumber(getElementData(clickedElement, "clickToVehicle") or 0) ~= 0 then
  666. if not isPedInVehicle(localPlayer) then
  667. if not isVehicleLocked(clickedElement) then
  668. triggerServerEvent("checkVehicleInvenroty", localPlayer, localPlayer, clickedElement)
  669. else
  670. outputChatBox("#22A7F0[Northen Life MTA] #ffffffA jármű csomagtartója zárva#ffffff van!", 255, 255, 255, true)
  671. end
  672. else
  673. outputChatBox("#22A7F0[Northen Life MTA] #ffffffKocsiban nem nyithatod meg az inventory#ffffff-t.", 255, 255, 255, true)
  674. end
  675. else
  676. outputChatBox("#D24D57[Northen Life MTA] #ffffffMár használatban van a kiválasztott inventory!", 255, 255, 255, true)
  677. end
  678. end
  679. elseif(getElementType(clickedElement)=="object" and getElementModel(clickedElement) == 2332) then
  680. if hasItem(localPlayer, 37, getElementData(clickedElement, "safe->ID")) or (getElementData(localPlayer, "acc:admin") or 0) > 7 then
  681. show = true
  682. Elsolepes = true
  683. Tick = getTickCount()
  684. openInventory(clickedElement)
  685. progress = "OutBack"
  686. showAction = true
  687. toggleControl ("fire", false)
  688. setElementData(localPlayer, "char:vehicle", true)
  689. moving = true
  690. moveOffset = false
  691. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"belenéz egy széfbe.")
  692. else
  693. outputChatBox("#4183D7[Northen Life MTA] #ffffffSajnálom de nincs kulcsod a széfhez.", 255, 255, 255, true)
  694. end
  695. end
  696. end
  697.  
  698. if(clickedItem>-1) and (show) then
  699. hasznaloSlot = clickedSlot + 1
  700. hasznaloItem = clickedItem
  701. hasznaloCount = clickedCount
  702. hasznaloValue = clickedValue
  703. end
  704. elseif(button=="right" and state=="up") and (show) and (cursorinInventory) and moving and movedItem < 1 then
  705. if itemElement == localPlayer then
  706. if isTimer(timer) then return end
  707. timer = setTimer(function() end, 2000, 1) --- spam védelem
  708. useItem(item_table[hasznaloSlot][4], hasznaloSlot,hasznaloItem, hasznaloValue, hasznaloCount)
  709. end
  710. hasznaloSlot = -1
  711. hasznaloItem = -1
  712. hasznaloCount = -1
  713. hasznaloValue = -1
  714. elseif(button=="left" and state=="down" and moving)then
  715. if(clickedItem>-1) and (show) and (clickedItem ~= 59) and (clickedItem ~= 60) and (clickedItem ~= 61) and (clickedItem ~= 62) and (clickedItem ~= 139) then
  716. movedSlot = clickedSlot
  717. movedItem = clickedItem
  718. movedValue = clickedValue
  719. movedCount = clickedCount
  720. clickDown = getTickCount( )
  721. end
  722. if(cursorIsActionbar and clientActionSlot>-1) and moving then
  723. triggerServerEvent("deleteActionBar", localPlayer, localPlayer, item_table_action[clientActionSlot][1])
  724. item_table_action[clientActionSlot] = {-1, -1, -1}
  725. end
  726. sor, oszlop, margin = 5, 10, 5 -- 2 * 5 = 10 Slot
  727. width, height = item_size*oszlop + margin*(oszlop+1), item_size * sor + (1+sor)*margin
  728. if moving and show and dobozbaVan (panelX+width-65, panelY+5, 80, 15, absoluteX, absoluteY) then
  729. createEditFunction("create")
  730. if guiEditSetCaretIndex(btn_edit, string.len(guiGetText(btn_edit))) then
  731. guiBringToFront(btn_edit)
  732. end
  733. end
  734.  
  735. if(clickedItem>-1) and (show) then
  736. hasznaloSlot = clickedSlot + 1
  737. hasznaloItem = clickedItem
  738. hasznaloCount = clickedCount
  739. hasznaloValue = clickedValue
  740. end
  741. elseif(button=="right" and state=="up") and (show) and (cursorinInventory) and moving and movedItem < 1 then
  742. if itemElement == localPlayer then
  743. if isTimer(timer) then return end
  744. timer = setTimer(function() end, 2000, 1) --- spam védelem
  745. useItem(item_table[hasznaloSlot][4], hasznaloSlot,hasznaloItem, hasznaloValue, hasznaloCount)
  746. end
  747. hasznaloSlot = -1
  748. hasznaloItem = -1
  749. hasznaloCount = -1
  750. hasznaloValue = -1
  751. elseif(button=="left" and state=="down" and moving)then
  752. if(clickedItem>-1) and (show) then
  753. movedSlot = clickedSlot
  754. movedItem = clickedItem
  755. movedValue = clickedValue
  756. movedCount = clickedCount
  757. clickDown = getTickCount( )
  758. end
  759. if(cursorIsActionbar and clientActionSlot>-1) and moving then
  760. triggerServerEvent("deleteActionBar", localPlayer, localPlayer, item_table_action[clientActionSlot][1])
  761. item_table_action[clientActionSlot] = {-1, -1, -1}
  762. end
  763. sor, oszlop, margin = 5, 10, 5 -- 2 * 5 = 10 Slot
  764. width, height = item_size*oszlop + margin*(oszlop+1), item_size * sor + (1+sor)*margin
  765. if moving and show and dobozbaVan (panelX+width-65, panelY+5, 80, 15, absoluteX, absoluteY) then
  766. createEditFunction("create")
  767. if guiEditSetCaretIndex(btn_edit, string.len(guiGetText(btn_edit))) then
  768. guiBringToFront(btn_edit)
  769. end
  770. end
  771. elseif(button=="left" and state=="up") then
  772. currentSlot = clickedSlot
  773. currentActionSlot = clientActionSlot
  774. currentItem = clickedItem
  775. currentValue = clickedValue
  776. currentCount = clickedCount
  777. clickDown = getTickCount( )
  778. if(not cursorinInventory and cursorIsActionbar and movedItem >-1 and movedSlot>-1)then
  779. if itemElement == localPlayer then
  780. for k=1, actionbarSlot do
  781. if item_table_action[k][1] == movedSlot+1 or getElementData(localPlayer, "char:fishing"..movedSlot+1) or getElementData(localPlayer, "char:badge"..movedSlot+1)or getElementData(localPlayer, "char:weaponGettin"..movedSlot+1) then
  782. destroyItemMove()
  783. outputChatBox("#D24D57[Northen Life MTA]: #ffffffCsak akkor tudod húzni a tárgyat ha az nincs az actionbar-on vagy nincs használatban!",255,255,255,true)
  784. return
  785. end
  786. end
  787. item_table_action[currentActionSlot] = {movedSlot+1, movedItem, movedCount}
  788. triggerServerEvent("saveActionBar", localPlayer, localPlayer, currentActionSlot, movedItem, movedValue, movedCount, movedSlot)
  789. end
  790. elseif((activeWeaponSlot == -1) and( cursorinInventory) and movedSlot>-1 and movedItem>0 and currentItem<0 and currentItem~=movedItem and currentSlot~=movedSlot and currentSlot > -1 and selectedAmount < 1 and moving )then
  791. for k=1, actionbarSlot do
  792. if item_table_action[k][1] == movedSlot+1 or getElementData(localPlayer, "char:fishing"..movedSlot+1) or getElementData(localPlayer, "char:badge"..movedSlot+1)or getElementData(localPlayer, "char:weaponGettin"..movedSlot+1) then
  793. destroyItemMove()
  794. outputChatBox("#D24D57[Northen Life MTA]: #ffffffCsak akkor tudod húzni a tárgyat ha az nincs az actionbar-on vagy nincs használatban!",255,255,255,true)
  795. return
  796. end
  797. end
  798. setSlot(currentSlot, movedItem, movedValue, movedCount, item_table[movedSlot+1][7] or -1)
  799. delSlot(movedSlot)
  800. playSound("files/sounds/mozgat.mp3", false)
  801. elseif((activeWeaponSlot == -1) and(cursorinInventory) and movedSlot>-1 and movedItem>0 and currentSlot~=movedSlot and currentSlot > -1 and selectedAmount < movedCount and selectedAmount > 0 and currentItem~=movedItem and items[movedItem][4] and moving and item_table[movedSlot+1][7] ~= 1 )then
  802. newCount = movedCount - selectedAmount
  803. setSlotCount(movedSlot, newCount, item_table[movedSlot+1][7] or -1)
  804. setSlot(currentSlot, movedItem, movedValue, selectedAmount, item_table[movedSlot+1][7] or -1)
  805. setSlotValue(movedSlot, movedItem, movedValue, newCount, item_table[movedSlot+1][7] or -1)
  806. createEditFunction("remove")
  807. playSound("files/sounds/mozgat.mp3", false)
  808. elseif((activeWeaponSlot == -1) and(cursorinInventory) and movedSlot>-1 and currentSlot~=movedSlot and movedItem>0 and currentSlot > -1 and currentItem==movedItem and items[movedItem][4] and item_table[movedSlot+1][7] == item_table[currentSlot+1][7] and moving )then
  809. createEditFunction("remove")
  810. newCounts = currentCount + movedCount
  811. setSlotCount(currentSlot, newCounts, item_table[movedSlot+1][7] or -1)
  812. setSlotValue(currentSlot, movedItem, movedValue, newCounts, item_table[movedSlot+1][7] or -1)
  813. delSlot(movedSlot)
  814. playSound("files/sounds/mozgat.mp3", false)
  815. elseif((activeWeaponSlot == -1) and movedSlot>-1 and movedItem>0 and clickedElement~=itemElement and isElement(clickedElement) and tostring(getElementType( clickedElement))~="false" and not cursorinInventory and moving ) then
  816. if(getElementType(clickedElement)=="player" or getElementType(clickedElement)=="vehicle" or getElementType(clickedElement)=="object")then
  817. local x,y,z = getElementPosition(itemElement)
  818. local x2,y2,z2 = getElementPosition(clickedElement)
  819. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  820. if item_table[movedSlot+1] and tonumber(item_table[movedSlot+1][7]) == 1 then
  821. outputChatBox("#D24D57[Northen Life MTA] #ffffffDuty itemet nem tudsz áttadni.", 255, 255, 255, true)
  822. elseif item_table[movedSlot+1] and tonumber(item_table[movedSlot+1][7]) or -1 ~= 1 then
  823. for k=1, actionbarSlot do
  824. if item_table_action[k][1] == movedSlot+1 or getElementData(localPlayer, "char:fishing"..movedSlot+1) or getElementData(localPlayer, "char:badge"..movedSlot+1)or getElementData(localPlayer, "char:weaponGettin"..movedSlot+1) then
  825. destroyItemMove()
  826. outputChatBox("#D24D57[Northen Life MTA]: #ffffff Csak akkor tudod húzni a tárgyat ha az nincs az actionbar-on vagy nincs használatban!",255,255,255,true)
  827. return
  828. end
  829. end
  830. if getElementType(clickedElement)=="vehicle" then
  831. if not (isVehicleLocked(clickedElement)) then
  832. Elsolepes = false
  833. Tick = getTickCount()
  834. progress = "OutBack"
  835. setElementData(clickedElement, "clickToVehicle", 0)
  836. setElementData(localPlayer, "char:vehicle", false)
  837. end
  838. else
  839. Elsolepes = false
  840. Tick = getTickCount()
  841. progress = "OutBack"
  842. setElementData(itemElement, "clickToVehicle", 0)
  843. setElementData(localPlayer, "char:vehicle", false)
  844. end
  845. if getElementType(clickedElement)=="vehicle" and (getElementData(clickedElement, "veh:id") or -1)>0 and getElementType(clickedElement)~="Bike" and getElementType(clickedElement)~="BMX" then
  846. if not (isVehicleLocked(clickedElement)) then
  847. if getElementData(clickedElement, "inUse") or tonumber(getElementData(clickedElement, "clickToVehicle") or 0) ~= 0 then
  848. outputChatBox(rovid.." Addig nem tudsz belerakni tárgyat a csomagtartóba amíg azt valaki használja.", 255, 255, 255, true)
  849. return
  850. end
  851. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"berak egy tárgyat a jármű csomagtartójába. (".. getItemName(movedItem) ..")")
  852. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  853. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  854. else
  855. outputChatBox("#D24D57[Northen Life MTA]: #ffffff A jármű csomagtartója zárva van!",255,255,255,true)
  856. end
  857. elseif getElementType(clickedElement)=="player" and getElementType(itemElement)=="player" and not getElementData(clickedElement, "char:vehicle" ) then
  858. exports['mta_chat']:sendLocalMeMessage(localPlayer, "átad egy tárgyat ".. getPlayerName(clickedElement):gsub("_"," ").."-nak/nek (".. getItemName(movedItem)..")")
  859. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  860. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  861. elseif getElementType(itemElement)=="vehicle" and getElementType(clickedElement)=="player" and clickedElement == localPlayer then
  862. exports['mta_chat']:sendLocalMeMessage(localPlayer, "kivesz egy tárgyat a jármű csomagtartójából. (".. getItemName(movedItem) ..")")
  863. setElementData(itemElement, "inUse", false)
  864. setElementData(itemElement, "clickToVehicle", 0)
  865. show = false
  866. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  867. triggerServerEvent("moveItemToText", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  868. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  869. if getElementType(itemElement)=="vehicle" then
  870. triggerServerEvent("doorState", itemElement, itemElement, 0)
  871. showAction = true
  872. end
  873. elseif getElementType(clickedElement) =="object" and getElementModel(clickedElement) == 2332 and moving then
  874. if hasItem(localPlayer, 37, getElementData(clickedElement, "safe->ID")) then
  875. if movedItem ~= 37 and movedValue ~= getElementData(clickedElement, "safe->ID") then
  876. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"berak egy tárgyat a széfbe. (".. getItemName(movedItem) ..")")
  877. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  878. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  879. else
  880. outputChatBox("#D24D57[Northen Life MTA] #ffffffSzéfkulcsot nem tehetsz a széfbe.", 255, 255, 255, true)
  881. end
  882. end
  883. elseif getElementType(itemElement) =="object" and getElementModel(itemElement) == 2332 and getElementType(clickedElement)=="player" and clickedElement == localPlayer then
  884. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"kivett egy tárgyat a széfbe. (".. getItemName(movedItem) ..")")
  885. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  886. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  887. elseif(getElementType(clickedElement)=="object" and getElementModel(clickedElement)==1359 and moving ) then
  888. local x,y,z = getElementPosition(itemElement)
  889. local x2,y2,z2 = getElementPosition(clickedElement)
  890. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  891. delSlot(movedSlot)
  892. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"kidobott egy tárgyat a kukába. ("..getItemName(movedItem)..")")
  893.  
  894. if items[movedItem][5] or -1 > 0 then
  895. triggerServerEvent("weapons->BackToRoot", localPlayer, localPlayer)
  896. end
  897. end
  898. end
  899. end
  900. end
  901. end
  902. end
  903. destroyItemMove()
  904. end
  905. end)
  906.  
  907. function destroyItemMove()
  908. isMove = false
  909. movedItem = 0
  910. newCount = 0
  911. movedSlot = -1
  912. movedCount = 0
  913. movedValue = 0
  914. selectedAmount = 0
  915. currentActionSlot = 0
  916. end
  917.  
  918. function checkVehicleInvenrotyClient(player, element)
  919. local returnold = false
  920.  
  921. for i = 1, 50 do
  922. if getElementData(localPlayer, "char:fishing"..i) or getElementData(localPlayer, "char:weaponGettin"..i) or getElementData(localPlayer, "char:badge"..i) then
  923. returnold = true
  924. break
  925. end
  926. end
  927.  
  928. if returnold then
  929. outputChatBox(rovid.." Addig nem tudod megnyitni a csomagtartót még nem rakod el a fegyvert!", 255, 255, 255, true)
  930. setElementData(element, "clickToVehicle", getElementData(element, "clickToVehicle") - 1)
  931. return
  932. end
  933.  
  934. if getElementData(element, "inUse") then
  935. outputChatBox(rovid.." Addig nem tudod megnyitni a csomagtartót míg valaki más is megnyitotta!", 255, 255, 255, true)
  936. return
  937. end
  938.  
  939. setElementData(element, "inUse", true)
  940. show = true
  941. create = false
  942. showAction = false
  943. item_table = {}
  944. Elsolepes = true
  945. statisztikaSzazaleka = 0
  946. Tick = getTickCount()
  947. progress = "OutBack"
  948. openInventory(element)
  949. triggerServerEvent("triggerItemsByType", localPlayer, element)
  950. setElementData(localPlayer, "char:vehicle", true)
  951. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"belenézett egy " ..exports.exg_carshop:getVehicleRealName(getElementModel(element)).. " csomagtartójába.")
  952. triggerServerEvent("doorState", element, element, 1)
  953. end
  954. addEvent("checkVehicleInvenrotyClient", true)
  955. addEventHandler("checkVehicleInvenrotyClient", root, checkVehicleInvenrotyClient)
  956.  
  957. function createEditFunction(type)
  958. if type == "create" then
  959. if isElement(btn_edit) then destroyElement(btn_edit) end
  960. btn_edit = guiCreateEdit (-10000, -10000, 100, 20, "", false )
  961. guiEditSetMaxLength(btn_edit, 5)
  962. else
  963. if isElement(btn_edit) then destroyElement(btn_edit) end
  964. end
  965. end
  966.  
  967. function setSlotCount(slot, db, duty)
  968. slot = slot + 1
  969. item_table[slot] = {item_table[slot][1] or -1, item_table[2] or 0, db, -1, -1, -1, duty}
  970. triggerServerEvent("updateCount", itemElement, itemElement, slot, db, duty)
  971. end
  972.  
  973. function setSlot(slot, item, val, db, duty)
  974. slot = slot + 1
  975. if (not item) then item = 0 end
  976. if (not val) then val = 0 end
  977. if (not db) then db = 1 end
  978. item_table[slot] = {item, val, db, -1, -1, -1, duty}
  979. triggerServerEvent("setSlotItem", itemElement, itemElement, slot, item, val, db, duty)
  980. end
  981.  
  982. function removeDecimal(number)
  983. local num = number
  984. local num2 = tostring(num)
  985. local found = nil
  986. for i=1,100000 do
  987. if string.sub(num2,i,i) == "." then
  988. found = i
  989. end
  990. end
  991. if type(found) == "number" then
  992. num2 = string.sub(num2,1,found-1)
  993. end
  994. num = tonumber(num2)
  995. return num
  996. end
  997.  
  998. addEventHandler("onClientGUIChanged", getRootElement(),
  999. function()
  1000. if source == btn_edit then
  1001. local currentAmount = guiGetText (source)
  1002. if string.len(currentAmount) > 0 then
  1003. local am = tonumber(currentAmount)
  1004. if am then
  1005. selectedAmount = removeDecimal(am)
  1006. else
  1007. guiSetText(source, currentAmount)
  1008. end
  1009. else
  1010. guiSetText(source, 0)
  1011. selectedAmount = 0
  1012. end
  1013. end
  1014. end
  1015. )
  1016.  
  1017. function tooltip_items( text, text2 )
  1018. --if checkCursor() then
  1019. local x,y = getCursorPosition( )
  1020. local x,y = x * monitorSize[1], y * monitorSize[2]
  1021. text = tostring( text )
  1022. if text2 then
  1023. text2 = tostring( text2 )
  1024. end
  1025.  
  1026. if text == text2 then
  1027. text2 = nil
  1028. end
  1029.  
  1030. local width = dxGetTextWidth( text, 1, font ) + 20
  1031. if text2 then
  1032. width = math.max( width, dxGetTextWidth( text2, 1, font) + 20 )
  1033. text = text .. "\n" .. text2
  1034. end
  1035. local height = 10 * ( text2 and 5 or 3 )
  1036. x = math.max( 10, math.min( x, monitorSize[1] - width - 10 ) )
  1037. y = math.max( 10, math.min( y, monitorSize[2] - height - 10 ) )
  1038.  
  1039. roundedRectangle( x, y, width, height, tocolor(0, 0, 0, 200), false, true )
  1040. dxDrawText( text, x, y, x + width, y + height, tooltip_text_color, 1, font, "center", "center", false, false, true, true )
  1041. --end
  1042. end
  1043.  
  1044. function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
  1045. if (x and y and w and h) then
  1046. if (not borderColor) then
  1047. borderColor = tocolor(0, 0, 0, 200);
  1048. end
  1049.  
  1050. if (not bgColor) then
  1051. bgColor = borderColor;
  1052. end
  1053.  
  1054. --> Background
  1055. dxDrawRectangle(x, y, w, h, bgColor, postGUI);
  1056.  
  1057. --> Border
  1058. dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI, true); -- top
  1059. dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI, true); -- bottom
  1060. dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI, true); -- left
  1061. dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI, true); -- right
  1062. end
  1063. end
  1064.  
  1065. function showItemList()
  1066. if getElementData(localPlayer,"acc:admin") >= 5 then
  1067. if(isElement(gui))then
  1068. showCursor(false)
  1069. destroyElement(gui)
  1070. return
  1071. end
  1072. showCursor(true)
  1073. gui = guiCreateWindow(monitorSize[1]/2-230/2,monitorSize[2]/2-350/2,230,350,"Tárgy lista",false)
  1074. guiWindowSetMovable(gui, false)
  1075. guiWindowSetSizable(gui, false)
  1076.  
  1077. myGrid = guiCreateGridList(0, 25, 220, 280, false, gui)
  1078. guiGridListSetSortingEnabled(myGrid, false)
  1079. myIdColumn = guiGridListAddColumn(myGrid, "Item ID", 0.2)
  1080. myNameColumn = guiGridListAddColumn(myGrid, "Elnevezés", 0.7)
  1081.  
  1082.  
  1083. myGridRows = {}
  1084. for i, v in ipairs(items) do
  1085. myGridRows[i] = guiGridListAddRow(myGrid)
  1086. guiGridListSetItemText(myGrid, myGridRows[i], myIdColumn, i, false, false)
  1087. guiGridListSetItemText(myGrid, myGridRows[i], myNameColumn, v[1], false, false)
  1088. end
  1089.  
  1090. exitButton = guiCreateButton(10, 310, 280, 30, "Kilépés", false, gui)
  1091. addEventHandler("onClientGUIClick", exitButton, function()
  1092. if(source==exitButton)then
  1093. showCursor(false)
  1094. destroyElement(gui)
  1095. end
  1096. end)
  1097. end
  1098. end
  1099. addCommandHandler("is", showItemList)
  1100. addCommandHandler("itemlist", showItemList)
  1101. addCommandHandler("targylista", showItemList)
  1102.  
  1103. function clientPlayerToItem(slot)
  1104. slot = slot + 1
  1105. item_table[slot] = {-1, -1, -1}
  1106. end
  1107. addEvent("clientPlayerToItem", true)
  1108. addEventHandler("clientPlayerToItem", root, clientPlayerToItem)
  1109.  
  1110.  
  1111. --WEAPON
  1112. toggleControl("next_weapon", false)
  1113. toggleControl("previous_weapon", false)
  1114.  
  1115. setTimer(function()
  1116. if not toggleControl("next_weapon", false) then
  1117. toggleControl("next_weapon", false)
  1118. end
  1119.  
  1120. if not toggleControl("previous_weapon", false) then
  1121. toggleControl("previous_weapon", false)
  1122. end
  1123. end, 500, 1)
  1124.  
  1125. function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
  1126. if((getElementData(getLocalPlayer(), "char:weaponInHand") or {-1, -1, -1})[1]>-1)then
  1127. local weaponData = getElementData(getLocalPlayer(), "char:weaponInHand") or {-1, -1, -1}
  1128. local witem = tonumber(weaponData[1] or -1)
  1129. local wslot = tonumber(weaponData[2] or -1)
  1130. local weapon = tonumber(weaponData[3] or -1)
  1131. if(not items[witem][6])then return end
  1132. local slot = 0
  1133. local slots = 0
  1134. local allammo = 0
  1135. for i, v in ipairs(item_table_player) do
  1136. if(tonumber(v[1])==tonumber(items[witem][6]) and tonumber(v[3])>0)then
  1137. slot = i
  1138. slots = i-1
  1139. allammo = allammo + tonumber(v[3])
  1140. end
  1141. end
  1142.  
  1143. if(allammo<=0)then
  1144. triggerServerEvent("toggleGun", getLocalPlayer(), getLocalPlayer(), wslot, witem)
  1145.  
  1146. else
  1147. newCounts = item_table_player[slot][3] - 1
  1148. setSlotCount(slots, newCounts, item_table[slot][7] or -1)
  1149. if item_table_player[slot][3] < 2 then
  1150. delSlot(item_table_player[slots][6])
  1151. end
  1152. end
  1153. end
  1154. end
  1155. addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc )
  1156.  
  1157. addEvent("localMeMsg", true)
  1158. addEventHandler("localMeMsg", root, function(player, msg)
  1159. exports.mta_chat:sendLocalMeMessage(player, msg)
  1160. end)
  1161.  
  1162. function delSlot(slot)
  1163. slot = slot + 1
  1164. item_table[slot] = {-1, -1, -1}
  1165. triggerServerEvent("deleteSlot", itemElement, itemElement, slot)
  1166. end
  1167.  
  1168. --[[ Széf Rendszer --]]
  1169.  
  1170. addCommandHandler("delsafe", function(_, safeID)
  1171. if getElementData(localPlayer, "acc:admin") > 0 then return end
  1172. if not tonumber(safeID) then
  1173. outputChatBox("#F4D03F[Northen Life MTA]#ffffff /delsafe [ID]", 0, 0, 0, true)
  1174. return
  1175. end
  1176.  
  1177. safeID = tonumber(safeID)
  1178.  
  1179. for _, safe in ipairs(getElementsByType("object")) do
  1180. if tonumber(getElementData(safe,"safe->ID")) == safeID then
  1181. if hasItem(localPlayer, 37, getElementData(safe, "safe->ID")) then
  1182. local x,y,z = getElementPosition(getLocalPlayer())
  1183. local x2,y2,z2 = getElementPosition(safe)
  1184. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  1185. triggerServerEvent("Items-->DeleteSafes", localPlayer, localPlayer, safe, safeID)
  1186. for i=0,50 do
  1187. local items = getSlot(i)
  1188. local value = getSlotValue(i)
  1189. if tonumber(items) == tonumber(37) and tonumber(value) == safeID then
  1190. delSlot(i)
  1191. end
  1192. end
  1193. else
  1194. outputChatBox("#D24D57[Northen Life MTA] #ffffffTúl messze vagy az adott széftől." ,255, 255, 255, true)
  1195. end
  1196. end
  1197.  
  1198. end
  1199. end
  1200. end)
  1201.  
  1202. addCommandHandler("createsafe", function()
  1203. if getElementData(localPlayer, "acc:admin") < 6 then return end
  1204. triggerServerEvent("item->createSafe", localPlayer, localPlayer)
  1205. outputChatBox("#47a7df[Northen Life MTA] #ffffffSikeresen létrehoztál egy széfet." ,255, 255, 255, true)
  1206. end)
  1207.  
  1208. --[[ Fegyver a háton ]]
  1209.  
  1210. -- function getWeaponModel(weapon)
  1211. -- local m
  1212.  
  1213. -- if weapon > 1 and weapon < 9 then
  1214. -- m = 331 + weapon
  1215. -- elseif weapon == 9 then
  1216. -- m = 341
  1217. -- elseif weapon == 15 then
  1218. -- m = 326
  1219. -- elseif (weapon > 21 and weapon < 30) or (weapon > 32 and weapon < 39) or (weapon > 40 and weapon < 44) then
  1220. -- m = 324 + weapon
  1221. -- elseif weapon > 29 and weapon < 32 then
  1222. -- m = 325 + weapon
  1223. -- elseif weapon == 32 then
  1224. -- m = 372
  1225. -- end
  1226.  
  1227. -- return m
  1228. -- end
  1229.  
  1230. -- local leftSideWeapons = {
  1231. -- [352] = true, --uzi
  1232. -- [353] = true, --mp
  1233. -- [334] = true, --gumibot
  1234. -- }
  1235.  
  1236. -- local rightSideWeapons = {
  1237. -- [348] = true, --deagle
  1238. -- [372] = true, --tec
  1239. -- }
  1240.  
  1241. -- local backSideWeapons = {
  1242. -- [349] = true, --shotgun
  1243. -- [350] = true, --shothun
  1244. -- [351] = true, --shotgun
  1245.  
  1246. -- [355] = true, --ak
  1247. -- [356] = true, --m4
  1248.  
  1249. -- [357] = true, --rifle
  1250. -- [358] = true, --rifle
  1251. -- }
  1252.  
  1253. -- local handbackWeapons = {
  1254. -- [337] = true, --ásó
  1255. -- [336] = true, --bézbóz
  1256. -- [338] = true, --billiárd
  1257. -- [339] = true, --katana
  1258. -- }
  1259.  
  1260. -- local playerWeapons = {}
  1261. -- playerWeapons[getElementData(localPlayer, "acc:id")] = {}
  1262.  
  1263. -- addEvent("getPlayerInventory", true)
  1264. -- addEventHandler("getPlayerInventory", root, function(table)
  1265. -- currentInventory = {}
  1266. -- currentInventory = table
  1267. -- end)
  1268.  
  1269. -- addEventHandler("onClientPreRender", root, function()
  1270. -- if getElementData(localPlayer, "loggedin") then
  1271. -- for key, value in ipairs(getElementsByType("player", true)) do
  1272. -- if getElementData(value, "loggedin") then
  1273. -- local x, y, z = getPedBonePosition(value, 3)
  1274. -- local rot = math.rad(90-getPedRotation(value))
  1275. -- local i = 15
  1276. -- local j = 0
  1277. -- local wep = getPedWeaponSlot(value)
  1278. -- local ox, oy = math.cos(rot)*0.22, -math.sin(rot)*0.22
  1279. -- local alpha = getElementAlpha(value)
  1280.  
  1281. -- if playerWeapons[getElementData(value, "acc:id")] then
  1282. -- for index, weapon in ipairs(playerWeapons[getElementData(value, "acc:id")]) do
  1283. -- if isElement(weapon) then
  1284. -- --if getElementData(value, "char:weaponInHand")[1] or -1 > 0 then
  1285. -- -- if getWeaponModel(items[getElementData(value, "char:weaponInHand")[1]][5]) ~= getElementModel(weapon) then
  1286. -- setElementRotation(weapon, 0, 70, getPedRotation(value)+90)
  1287. -- setElementAlpha(weapon, alpha)
  1288.  
  1289. -- if rightSideWeapons[getElementModel(weapon)] then
  1290. -- local px, py, pz = getPedBonePosition(value, 51)
  1291. -- local qx, qy = math.sin(rot)*0.11, math.cos(rot)*0.11
  1292.  
  1293. -- setElementPosition(weapon, px+qx, py+qy, pz)
  1294. -- elseif leftSideWeapons[getElementModel(weapon)] then
  1295. -- local px, py, pz = getPedBonePosition(value, 41)
  1296. -- local qx, qy = math.sin(rot)*0.06, math.cos(rot)*0.06
  1297.  
  1298. -- setElementPosition(weapon, px-qx, py-qy, pz)
  1299.  
  1300. -- if getElementModel(weapon) == 334 then
  1301. -- local rx, ry, rz = getElementRotation(weapon)
  1302. -- setElementRotation(weapon, rx, ry+110, rz)
  1303. -- end
  1304. -- elseif backSideWeapons[getElementModel(weapon)] then
  1305. -- setElementPosition(weapon, x+ox, y+oy, z-0.2)
  1306. -- setElementRotation(weapon, -17, -(50+i), getPedRotation(value))
  1307.  
  1308. -- i = i + 15
  1309. -- elseif handbackWeapons[getElementModel(weapon)] then
  1310. -- if j % 2 == 0 then
  1311. -- setElementPosition(weapon, x+ox, y+oy, z-0.2)
  1312. -- setElementRotation(weapon, -17, -30, getPedRotation(value))
  1313. -- else
  1314. -- setElementPosition(weapon, x+ox, y+oy, z-0.2)
  1315. -- setElementRotation(weapon, -17, 30, getPedRotation(value))
  1316. -- end
  1317.  
  1318. -- j = j + 1
  1319. -- end
  1320. -- -- end
  1321. -- --end
  1322. -- end
  1323. -- end
  1324. -- end
  1325. -- end
  1326. -- end
  1327. -- end
  1328. -- end)
  1329.  
  1330. -- function streamedIn(source)
  1331. -- if isElement(source) and getElementType(source) == "player" then
  1332. -- local currentPlayer = source
  1333.  
  1334. -- streamedOut(source)
  1335.  
  1336. -- playerWeapons[getElementData(currentPlayer, "acc:id")] = {}
  1337.  
  1338. -- triggerServerEvent("getPlayerItems", localPlayer, currentPlayer)
  1339. -- setTimer(function ()
  1340. -- if not currentInventory then return end
  1341. -- for key, value in ipairs(currentInventory) do
  1342. -- if value and value[1] and (value or {-1, -1})[1] > 0 and items[value[1]][5] or -1 > 0 then
  1343. -- if leftSideWeapons[getWeaponModel(items[value[1]][5])] or rightSideWeapons[getWeaponModel(items[value[1]][5])] or backSideWeapons[getWeaponModel(items[value[1]][5])] or handbackWeapons[getWeaponModel(items[value[1]][5])] then
  1344. -- for index, weapon in ipairs(playerWeapons[getElementData(currentPlayer, "acc:id")]) do
  1345. -- if isElement(weapon) and getElementModel(weapon) == getWeaponModel(items[value[1]][5]) then
  1346. -- destroyElement(weapon)
  1347. -- end
  1348. -- end
  1349.  
  1350. -- local x, y, z = getElementPosition(currentPlayer)
  1351.  
  1352. -- playerWeapons[getElementData(currentPlayer, "acc:id")][#playerWeapons[getElementData(currentPlayer, "acc:id")] + 1] =
  1353. -- createObject(getWeaponModel(items[value[1]][5]), x, y, z)
  1354.  
  1355. -- setElementCollisionsEnabled(playerWeapons[getElementData(currentPlayer, "acc:id")][#playerWeapons[getElementData(currentPlayer, "acc:id")]], false)
  1356.  
  1357. -- outputDebugString(getWeaponModel(items[value[1]][5]) .. " weapon created -> " .. getPlayerName(currentPlayer))
  1358. -- end
  1359. -- end
  1360. -- end
  1361. -- end, 100, 1)
  1362. -- end
  1363. -- end
  1364. -- addEvent("streamedIn", true)
  1365. -- addEventHandler("streamedIn", root, streamedIn)
  1366. -- addEventHandler("onClientElementStreamIn", root, streamedIn)
  1367.  
  1368. -- addEventHandler("onClientVehicleExit", root, function(source)
  1369. -- streamedIn(source)
  1370. -- end)
  1371.  
  1372. -- function streamedOut(source)
  1373. -- if source then
  1374. -- local currentPlayer = source
  1375.  
  1376. -- if playerWeapons[getElementData(currentPlayer, "acc:id")] then
  1377. -- for key, value in ipairs(playerWeapons[getElementData(currentPlayer, "acc:id")]) do
  1378. -- if isElement(value) then
  1379. -- outputDebugString(getElementModel(value) .. " weapon destroyed")
  1380. -- destroyElement(value)
  1381. -- end
  1382. -- end
  1383. -- end
  1384. -- end
  1385. -- end
  1386. -- addEventHandler("onClientElementStreamOut", root, streamedOut)
  1387.  
  1388. -- addEventHandler("onClientPlayerQuit", root, function()
  1389. -- if playerWeapons[getElementData(source, "acc:id")] then
  1390. -- for key, value in ipairs(playerWeapons[getElementData(source, "acc:id")]) do
  1391. -- if isElement(value) then
  1392. -- outputDebugString(getElementModel(value) .. " weapon destroyed")
  1393. -- destroyElement(value)
  1394. -- end
  1395. -- end
  1396. -- end
  1397. -- end)
  1398.  
  1399. -- addEventHandler("onClientPlayerWasted", root, function()
  1400. -- streamedOut(source)
  1401. -- end)
  1402.  
  1403. -- addEventHandler("onClientVehicleEnter", root, function(source)
  1404. -- streamedOut(source)
  1405. -- end)
  1406.  
  1407. -- function loadNearbyWeapons()
  1408. -- setTimer(function()
  1409. -- for key, player in ipairs(getElementsByType("player")) do
  1410. -- setTimer(function()
  1411. -- streamedIn(player)
  1412. -- end, key * 150, 1)
  1413. -- end
  1414. -- end, 200, 1)
  1415. -- end
  1416. -- addEventHandler("onClientResourceStart", resourceRoot, loadNearbyWeapons)
  1417. -- addEventHandler("onClientPlayerSpawn", root, loadNearbyWeapons)
  1418.  
  1419.  
  1420.  
  1421. function ChangeObjectModel (filename,id)
  1422. if id and filename then
  1423. if fileExists("files/" .. filename..".txd") then
  1424. txd = engineLoadTXD( "files/" .. filename..".txd" )
  1425. engineImportTXD( txd, id )
  1426. end
  1427. if fileExists("files/" .. filename..".dff") then
  1428. dff = engineLoadDFF( "files/" .. filename..".dff", 0 )
  1429. engineReplaceModel( dff, id )
  1430. end
  1431. if fileExists("files/" .. filename..".col") then
  1432. col = engineLoadCOL( "files/" .. filename..".col" )
  1433. engineReplaceCOL( col, id )
  1434. end
  1435. engineSetModelLODDistance(id,300)
  1436. end
  1437. end
  1438.  
  1439. ChangeObjectModel("villogo",903)
  1440. ChangeObjectModel("taxitable",2061)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement