Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.68 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. if(clickedItem>-1) and (show) then
  698. hasznaloSlot = clickedSlot + 1
  699. hasznaloItem = clickedItem
  700. hasznaloCount = clickedCount
  701. hasznaloValue = clickedValue
  702. end
  703. elseif(button=="right" and state=="up") and (show) and (cursorinInventory) and moving and movedItem < 1 then
  704. if itemElement == localPlayer then
  705. if isTimer(timer) then return end
  706. timer = setTimer(function() end, 2000, 1) --- spam védelem
  707. useItem(item_table[hasznaloSlot][4], hasznaloSlot,hasznaloItem, hasznaloValue, hasznaloCount)
  708. end
  709. hasznaloSlot = -1
  710. hasznaloItem = -1
  711. hasznaloCount = -1
  712. hasznaloValue = -1
  713. elseif(button=="left" and state=="down" and moving)then
  714. if(clickedItem>-1) and (show) then
  715. movedSlot = clickedSlot
  716. movedItem = clickedItem
  717. movedValue = clickedValue
  718. movedCount = clickedCount
  719. clickDown = getTickCount( )
  720. end
  721. if(cursorIsActionbar and clientActionSlot>-1) and moving then
  722. triggerServerEvent("deleteActionBar", localPlayer, localPlayer, item_table_action[clientActionSlot][1])
  723. item_table_action[clientActionSlot] = {-1, -1, -1}
  724. end
  725. sor, oszlop, margin = 5, 10, 5 -- 2 * 5 = 10 Slot
  726. width, height = item_size*oszlop + margin*(oszlop+1), item_size * sor + (1+sor)*margin
  727. if moving and show and dobozbaVan (panelX+width-65, panelY+5, 80, 15, absoluteX, absoluteY) then
  728. createEditFunction("create")
  729. if guiEditSetCaretIndex(btn_edit, string.len(guiGetText(btn_edit))) then
  730. guiBringToFront(btn_edit)
  731. end
  732. end
  733. elseif(button=="left" and state=="up") then
  734. currentSlot = clickedSlot
  735. currentActionSlot = clientActionSlot
  736. currentItem = clickedItem
  737. currentValue = clickedValue
  738. currentCount = clickedCount
  739. clickDown = getTickCount( )
  740. if(not cursorinInventory and cursorIsActionbar and movedItem >-1 and movedSlot>-1)then
  741. if itemElement == localPlayer then
  742. for k=1, actionbarSlot do
  743. 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
  744. destroyItemMove()
  745. 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)
  746. return
  747. end
  748. end
  749. item_table_action[currentActionSlot] = {movedSlot+1, movedItem, movedCount}
  750. triggerServerEvent("saveActionBar", localPlayer, localPlayer, currentActionSlot, movedItem, movedValue, movedCount, movedSlot)
  751. end
  752. 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
  753. for k=1, actionbarSlot do
  754. 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
  755. destroyItemMove()
  756. 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)
  757. return
  758. end
  759. end
  760. setSlot(currentSlot, movedItem, movedValue, movedCount, item_table[movedSlot+1][7] or -1)
  761. delSlot(movedSlot)
  762. playSound("files/sounds/mozgat.mp3", false)
  763. 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
  764. newCount = movedCount - selectedAmount
  765. setSlotCount(movedSlot, newCount, item_table[movedSlot+1][7] or -1)
  766. setSlot(currentSlot, movedItem, movedValue, selectedAmount, item_table[movedSlot+1][7] or -1)
  767. setSlotValue(movedSlot, movedItem, movedValue, newCount, item_table[movedSlot+1][7] or -1)
  768. createEditFunction("remove")
  769. playSound("files/sounds/mozgat.mp3", false)
  770. 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
  771. createEditFunction("remove")
  772. newCounts = currentCount + movedCount
  773. setSlotCount(currentSlot, newCounts, item_table[movedSlot+1][7] or -1)
  774. setSlotValue(currentSlot, movedItem, movedValue, newCounts, item_table[movedSlot+1][7] or -1)
  775. delSlot(movedSlot)
  776. playSound("files/sounds/mozgat.mp3", false)
  777. 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
  778. if(getElementType(clickedElement)=="player" or getElementType(clickedElement)=="vehicle" or getElementType(clickedElement)=="object")then
  779. local x,y,z = getElementPosition(itemElement)
  780. local x2,y2,z2 = getElementPosition(clickedElement)
  781. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  782. if item_table[movedSlot+1] and tonumber(item_table[movedSlot+1][7]) == 1 then
  783. outputChatBox("#D24D57[Northen Life MTA] #ffffffDuty itemet nem tudsz áttadni.", 255, 255, 255, true)
  784. elseif item_table[movedSlot+1] and tonumber(item_table[movedSlot+1][7]) or -1 ~= 1 then
  785. for k=1, actionbarSlot do
  786. 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
  787. destroyItemMove()
  788. 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)
  789. return
  790. end
  791. end
  792. if getElementType(clickedElement)=="vehicle" then
  793. if not (isVehicleLocked(clickedElement)) then
  794. Elsolepes = false
  795. Tick = getTickCount()
  796. progress = "OutBack"
  797. setElementData(clickedElement, "clickToVehicle", 0)
  798. setElementData(localPlayer, "char:vehicle", false)
  799. end
  800. else
  801. Elsolepes = false
  802. Tick = getTickCount()
  803. progress = "OutBack"
  804. setElementData(itemElement, "clickToVehicle", 0)
  805. setElementData(localPlayer, "char:vehicle", false)
  806. end
  807. if getElementType(clickedElement)=="vehicle" and (getElementData(clickedElement, "veh:id") or -1)>0 and getElementType(clickedElement)~="Bike" and getElementType(clickedElement)~="BMX" then
  808. if not (isVehicleLocked(clickedElement)) then
  809. if getElementData(clickedElement, "inUse") or tonumber(getElementData(clickedElement, "clickToVehicle") or 0) ~= 0 then
  810. outputChatBox(rovid.." Addig nem tudsz belerakni tárgyat a csomagtartóba amíg azt valaki használja.", 255, 255, 255, true)
  811. return
  812. end
  813. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"berak egy tárgyat a jármű csomagtartójába. (".. getItemName(movedItem) ..")")
  814. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  815. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  816. else
  817. outputChatBox("#D24D57[Northen Life MTA]: #ffffff A jármű csomagtartója zárva van!",255,255,255,true)
  818. end
  819. elseif getElementType(clickedElement)=="player" and getElementType(itemElement)=="player" and not getElementData(clickedElement, "char:vehicle" ) then
  820. exports['mta_chat']:sendLocalMeMessage(localPlayer, "átad egy tárgyat ".. getPlayerName(clickedElement):gsub("_"," ").."-nak/nek (".. getItemName(movedItem)..")")
  821. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  822. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  823. elseif getElementType(itemElement)=="vehicle" and getElementType(clickedElement)=="player" and clickedElement == localPlayer then
  824. exports['mta_chat']:sendLocalMeMessage(localPlayer, "kivesz egy tárgyat a jármű csomagtartójából. (".. getItemName(movedItem) ..")")
  825. setElementData(itemElement, "inUse", false)
  826. setElementData(itemElement, "clickToVehicle", 0)
  827. show = false
  828. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  829. triggerServerEvent("moveItemToText", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  830. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  831. if getElementType(itemElement)=="vehicle" then
  832. triggerServerEvent("doorState", itemElement, itemElement, 0)
  833. showAction = true
  834. end
  835. elseif getElementType(clickedElement) =="object" and getElementModel(clickedElement) == 2332 and moving then
  836. if hasItem(localPlayer, 37, getElementData(clickedElement, "safe->ID")) then
  837. if movedItem ~= 37 and movedValue ~= getElementData(clickedElement, "safe->ID") then
  838. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"berak egy tárgyat a széfbe. (".. getItemName(movedItem) ..")")
  839. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  840. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  841. else
  842. outputChatBox("#D24D57[Northen Life MTA] #ffffffSzéfkulcsot nem tehetsz a széfbe.", 255, 255, 255, true)
  843. end
  844. end
  845. elseif getElementType(itemElement) =="object" and getElementModel(itemElement) == 2332 and getElementType(clickedElement)=="player" and clickedElement == localPlayer then
  846. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"kivett egy tárgyat a széfbe. (".. getItemName(movedItem) ..")")
  847. triggerServerEvent("moveItemToPlayer", itemElement, itemElement, clickedElement, movedSlot, movedItem, movedValue, movedCount)
  848. triggerServerEvent("MoveItemToAnimation", itemElement, itemElement, clickedElement)
  849. elseif(getElementType(clickedElement)=="object" and getElementModel(clickedElement)==1359 and moving ) then
  850. local x,y,z = getElementPosition(itemElement)
  851. local x2,y2,z2 = getElementPosition(clickedElement)
  852. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  853. delSlot(movedSlot)
  854. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"kidobott egy tárgyat a kukába. ("..getItemName(movedItem)..")")
  855.  
  856. if items[movedItem][5] or -1 > 0 then
  857. triggerServerEvent("weapons->BackToRoot", localPlayer, localPlayer)
  858. end
  859. end
  860. end
  861. end
  862. end
  863. end
  864. end
  865. destroyItemMove()
  866. end
  867. end)
  868.  
  869. function destroyItemMove()
  870. isMove = false
  871. movedItem = 0
  872. newCount = 0
  873. movedSlot = -1
  874. movedCount = 0
  875. movedValue = 0
  876. selectedAmount = 0
  877. currentActionSlot = 0
  878. end
  879.  
  880. function checkVehicleInvenrotyClient(player, element)
  881. local returnold = false
  882.  
  883. for i = 1, 50 do
  884. if getElementData(localPlayer, "char:fishing"..i) or getElementData(localPlayer, "char:weaponGettin"..i) or getElementData(localPlayer, "char:badge"..i) then
  885. returnold = true
  886. break
  887. end
  888. end
  889.  
  890. if returnold then
  891. outputChatBox(rovid.." Addig nem tudod megnyitni a csomagtartót még nem rakod el a fegyvert!", 255, 255, 255, true)
  892. setElementData(element, "clickToVehicle", getElementData(element, "clickToVehicle") - 1)
  893. return
  894. end
  895.  
  896. if getElementData(element, "inUse") then
  897. outputChatBox(rovid.." Addig nem tudod megnyitni a csomagtartót míg valaki más is megnyitotta!", 255, 255, 255, true)
  898. return
  899. end
  900.  
  901. setElementData(element, "inUse", true)
  902. show = true
  903. create = false
  904. showAction = false
  905. item_table = {}
  906. Elsolepes = true
  907. statisztikaSzazaleka = 0
  908. Tick = getTickCount()
  909. progress = "OutBack"
  910. openInventory(element)
  911. triggerServerEvent("triggerItemsByType", localPlayer, element)
  912. setElementData(localPlayer, "char:vehicle", true)
  913. exports['mta_chat']:sendLocalMeMessage(localPlayer ,"belenézett egy " ..exports.exg_carshop:getVehicleRealName(getElementModel(element)).. " csomagtartójába.")
  914. triggerServerEvent("doorState", element, element, 1)
  915. end
  916. addEvent("checkVehicleInvenrotyClient", true)
  917. addEventHandler("checkVehicleInvenrotyClient", root, checkVehicleInvenrotyClient)
  918.  
  919. function createEditFunction(type)
  920. if type == "create" then
  921. if isElement(btn_edit) then destroyElement(btn_edit) end
  922. btn_edit = guiCreateEdit (-10000, -10000, 100, 20, "", false )
  923. guiEditSetMaxLength(btn_edit, 5)
  924. else
  925. if isElement(btn_edit) then destroyElement(btn_edit) end
  926. end
  927. end
  928.  
  929. function setSlotCount(slot, db, duty)
  930. slot = slot + 1
  931. item_table[slot] = {item_table[slot][1] or -1, item_table[2] or 0, db, -1, -1, -1, duty}
  932. triggerServerEvent("updateCount", itemElement, itemElement, slot, db, duty)
  933. end
  934.  
  935. function setSlot(slot, item, val, db, duty)
  936. slot = slot + 1
  937. if (not item) then item = 0 end
  938. if (not val) then val = 0 end
  939. if (not db) then db = 1 end
  940. item_table[slot] = {item, val, db, -1, -1, -1, duty}
  941. triggerServerEvent("setSlotItem", itemElement, itemElement, slot, item, val, db, duty)
  942. end
  943.  
  944. function removeDecimal(number)
  945. local num = number
  946. local num2 = tostring(num)
  947. local found = nil
  948. for i=1,100000 do
  949. if string.sub(num2,i,i) == "." then
  950. found = i
  951. end
  952. end
  953. if type(found) == "number" then
  954. num2 = string.sub(num2,1,found-1)
  955. end
  956. num = tonumber(num2)
  957. return num
  958. end
  959.  
  960. addEventHandler("onClientGUIChanged", getRootElement(),
  961. function()
  962. if source == btn_edit then
  963. local currentAmount = guiGetText (source)
  964. if string.len(currentAmount) > 0 then
  965. local am = tonumber(currentAmount)
  966. if am then
  967. selectedAmount = removeDecimal(am)
  968. else
  969. guiSetText(source, currentAmount)
  970. end
  971. else
  972. guiSetText(source, 0)
  973. selectedAmount = 0
  974. end
  975. end
  976. end
  977. )
  978.  
  979. function tooltip_items( text, text2 )
  980. --if checkCursor() then
  981. local x,y = getCursorPosition( )
  982. local x,y = x * monitorSize[1], y * monitorSize[2]
  983. text = tostring( text )
  984. if text2 then
  985. text2 = tostring( text2 )
  986. end
  987.  
  988. if text == text2 then
  989. text2 = nil
  990. end
  991.  
  992. local width = dxGetTextWidth( text, 1, font ) + 20
  993. if text2 then
  994. width = math.max( width, dxGetTextWidth( text2, 1, font) + 20 )
  995. text = text .. "\n" .. text2
  996. end
  997. local height = 10 * ( text2 and 5 or 3 )
  998. x = math.max( 10, math.min( x, monitorSize[1] - width - 10 ) )
  999. y = math.max( 10, math.min( y, monitorSize[2] - height - 10 ) )
  1000.  
  1001. roundedRectangle( x, y, width, height, tocolor(0, 0, 0, 200), false, true )
  1002. dxDrawText( text, x, y, x + width, y + height, tooltip_text_color, 1, font, "center", "center", false, false, true, true )
  1003. --end
  1004. end
  1005.  
  1006. function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
  1007. if (x and y and w and h) then
  1008. if (not borderColor) then
  1009. borderColor = tocolor(0, 0, 0, 200);
  1010. end
  1011.  
  1012. if (not bgColor) then
  1013. bgColor = borderColor;
  1014. end
  1015.  
  1016. --> Background
  1017. dxDrawRectangle(x, y, w, h, bgColor, postGUI);
  1018.  
  1019. --> Border
  1020. dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI, true); -- top
  1021. dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI, true); -- bottom
  1022. dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI, true); -- left
  1023. dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI, true); -- right
  1024. end
  1025. end
  1026.  
  1027. function showItemList()
  1028. if getElementData(localPlayer,"acc:admin") >= 5 then
  1029. if(isElement(gui))then
  1030. showCursor(false)
  1031. destroyElement(gui)
  1032. return
  1033. end
  1034. showCursor(true)
  1035. gui = guiCreateWindow(monitorSize[1]/2-230/2,monitorSize[2]/2-350/2,230,350,"Tárgy lista",false)
  1036. guiWindowSetMovable(gui, false)
  1037. guiWindowSetSizable(gui, false)
  1038.  
  1039. myGrid = guiCreateGridList(0, 25, 220, 280, false, gui)
  1040. guiGridListSetSortingEnabled(myGrid, false)
  1041. myIdColumn = guiGridListAddColumn(myGrid, "Item ID", 0.2)
  1042. myNameColumn = guiGridListAddColumn(myGrid, "Elnevezés", 0.7)
  1043.  
  1044.  
  1045. myGridRows = {}
  1046. for i, v in ipairs(items) do
  1047. myGridRows[i] = guiGridListAddRow(myGrid)
  1048. guiGridListSetItemText(myGrid, myGridRows[i], myIdColumn, i, false, false)
  1049. guiGridListSetItemText(myGrid, myGridRows[i], myNameColumn, v[1], false, false)
  1050. end
  1051.  
  1052. exitButton = guiCreateButton(10, 310, 280, 30, "Kilépés", false, gui)
  1053. addEventHandler("onClientGUIClick", exitButton, function()
  1054. if(source==exitButton)then
  1055. showCursor(false)
  1056. destroyElement(gui)
  1057. end
  1058. end)
  1059. end
  1060. end
  1061. addCommandHandler("is", showItemList)
  1062. addCommandHandler("itemlist", showItemList)
  1063. addCommandHandler("targylista", showItemList)
  1064.  
  1065. function clientPlayerToItem(slot)
  1066. slot = slot + 1
  1067. item_table[slot] = {-1, -1, -1}
  1068. end
  1069. addEvent("clientPlayerToItem", true)
  1070. addEventHandler("clientPlayerToItem", root, clientPlayerToItem)
  1071.  
  1072.  
  1073. --WEAPON
  1074. toggleControl("next_weapon", false)
  1075. toggleControl("previous_weapon", false)
  1076.  
  1077. setTimer(function()
  1078. if not toggleControl("next_weapon", false) then
  1079. toggleControl("next_weapon", false)
  1080. end
  1081.  
  1082. if not toggleControl("previous_weapon", false) then
  1083. toggleControl("previous_weapon", false)
  1084. end
  1085. end, 500, 1)
  1086.  
  1087. function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
  1088. if((getElementData(getLocalPlayer(), "char:weaponInHand") or {-1, -1, -1})[1]>-1)then
  1089. local weaponData = getElementData(getLocalPlayer(), "char:weaponInHand") or {-1, -1, -1}
  1090. local witem = tonumber(weaponData[1] or -1)
  1091. local wslot = tonumber(weaponData[2] or -1)
  1092. local weapon = tonumber(weaponData[3] or -1)
  1093. if(not items[witem][6])then return end
  1094. local slot = 0
  1095. local slots = 0
  1096. local allammo = 0
  1097. for i, v in ipairs(item_table_player) do
  1098. if(tonumber(v[1])==tonumber(items[witem][6]) and tonumber(v[3])>0)then
  1099. slot = i
  1100. slots = i-1
  1101. allammo = allammo + tonumber(v[3])
  1102. end
  1103. end
  1104.  
  1105. if(allammo<=0)then
  1106. triggerServerEvent("toggleGun", getLocalPlayer(), getLocalPlayer(), wslot, witem)
  1107.  
  1108. else
  1109. newCounts = item_table_player[slot][3] - 1
  1110. setSlotCount(slots, newCounts, item_table[slot][7] or -1)
  1111. if item_table_player[slot][3] < 2 then
  1112. delSlot(item_table_player[slots][6])
  1113. end
  1114. end
  1115. end
  1116. end
  1117. addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc )
  1118.  
  1119. addEvent("localMeMsg", true)
  1120. addEventHandler("localMeMsg", root, function(player, msg)
  1121. exports.mta_chat:sendLocalMeMessage(player, msg)
  1122. end)
  1123.  
  1124. function delSlot(slot)
  1125. slot = slot + 1
  1126. item_table[slot] = {-1, -1, -1}
  1127. triggerServerEvent("deleteSlot", itemElement, itemElement, slot)
  1128. end
  1129.  
  1130. --[[ Széf Rendszer --]]
  1131.  
  1132. addCommandHandler("delsafe", function(_, safeID)
  1133. if getElementData(localPlayer, "acc:admin") > 0 then return end
  1134. if not tonumber(safeID) then
  1135. outputChatBox("#F4D03F[Northen Life MTA]#ffffff /delsafe [ID]", 0, 0, 0, true)
  1136. return
  1137. end
  1138.  
  1139. safeID = tonumber(safeID)
  1140.  
  1141. for _, safe in ipairs(getElementsByType("object")) do
  1142. if tonumber(getElementData(safe,"safe->ID")) == safeID then
  1143. if hasItem(localPlayer, 37, getElementData(safe, "safe->ID")) then
  1144. local x,y,z = getElementPosition(getLocalPlayer())
  1145. local x2,y2,z2 = getElementPosition(safe)
  1146. if getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5 then
  1147. triggerServerEvent("Items-->DeleteSafes", localPlayer, localPlayer, safe, safeID)
  1148. for i=0,50 do
  1149. local items = getSlot(i)
  1150. local value = getSlotValue(i)
  1151. if tonumber(items) == tonumber(37) and tonumber(value) == safeID then
  1152. delSlot(i)
  1153. end
  1154. end
  1155. else
  1156. outputChatBox("#D24D57[Northen Life MTA] #ffffffTúl messze vagy az adott széftől." ,255, 255, 255, true)
  1157. end
  1158. end
  1159.  
  1160. end
  1161. end
  1162. end)
  1163.  
  1164. addCommandHandler("createsafe", function()
  1165. if getElementData(localPlayer, "acc:admin") < 6 then return end
  1166. triggerServerEvent("item->createSafe", localPlayer, localPlayer)
  1167. outputChatBox("#47a7df[Northen Life MTA] #ffffffSikeresen létrehoztál egy széfet." ,255, 255, 255, true)
  1168. end)
  1169.  
  1170. --[[ Fegyver a háton ]]
  1171.  
  1172. -- function getWeaponModel(weapon)
  1173. -- local m
  1174.  
  1175. -- if weapon > 1 and weapon < 9 then
  1176. -- m = 331 + weapon
  1177. -- elseif weapon == 9 then
  1178. -- m = 341
  1179. -- elseif weapon == 15 then
  1180. -- m = 326
  1181. -- elseif (weapon > 21 and weapon < 30) or (weapon > 32 and weapon < 39) or (weapon > 40 and weapon < 44) then
  1182. -- m = 324 + weapon
  1183. -- elseif weapon > 29 and weapon < 32 then
  1184. -- m = 325 + weapon
  1185. -- elseif weapon == 32 then
  1186. -- m = 372
  1187. -- end
  1188.  
  1189. -- return m
  1190. -- end
  1191.  
  1192. -- local leftSideWeapons = {
  1193. -- [352] = true, --uzi
  1194. -- [353] = true, --mp
  1195. -- [334] = true, --gumibot
  1196. -- }
  1197.  
  1198. -- local rightSideWeapons = {
  1199. -- [348] = true, --deagle
  1200. -- [372] = true, --tec
  1201. -- }
  1202.  
  1203. -- local backSideWeapons = {
  1204. -- [349] = true, --shotgun
  1205. -- [350] = true, --shothun
  1206. -- [351] = true, --shotgun
  1207.  
  1208. -- [355] = true, --ak
  1209. -- [356] = true, --m4
  1210.  
  1211. -- [357] = true, --rifle
  1212. -- [358] = true, --rifle
  1213. -- }
  1214.  
  1215. -- local handbackWeapons = {
  1216. -- [337] = true, --ásó
  1217. -- [336] = true, --bézbóz
  1218. -- [338] = true, --billiárd
  1219. -- [339] = true, --katana
  1220. -- }
  1221.  
  1222. -- local playerWeapons = {}
  1223. -- playerWeapons[getElementData(localPlayer, "acc:id")] = {}
  1224.  
  1225. -- addEvent("getPlayerInventory", true)
  1226. -- addEventHandler("getPlayerInventory", root, function(table)
  1227. -- currentInventory = {}
  1228. -- currentInventory = table
  1229. -- end)
  1230.  
  1231. -- addEventHandler("onClientPreRender", root, function()
  1232. -- if getElementData(localPlayer, "loggedin") then
  1233. -- for key, value in ipairs(getElementsByType("player", true)) do
  1234. -- if getElementData(value, "loggedin") then
  1235. -- local x, y, z = getPedBonePosition(value, 3)
  1236. -- local rot = math.rad(90-getPedRotation(value))
  1237. -- local i = 15
  1238. -- local j = 0
  1239. -- local wep = getPedWeaponSlot(value)
  1240. -- local ox, oy = math.cos(rot)*0.22, -math.sin(rot)*0.22
  1241. -- local alpha = getElementAlpha(value)
  1242.  
  1243. -- if playerWeapons[getElementData(value, "acc:id")] then
  1244. -- for index, weapon in ipairs(playerWeapons[getElementData(value, "acc:id")]) do
  1245. -- if isElement(weapon) then
  1246. -- --if getElementData(value, "char:weaponInHand")[1] or -1 > 0 then
  1247. -- -- if getWeaponModel(items[getElementData(value, "char:weaponInHand")[1]][5]) ~= getElementModel(weapon) then
  1248. -- setElementRotation(weapon, 0, 70, getPedRotation(value)+90)
  1249. -- setElementAlpha(weapon, alpha)
  1250.  
  1251. -- if rightSideWeapons[getElementModel(weapon)] then
  1252. -- local px, py, pz = getPedBonePosition(value, 51)
  1253. -- local qx, qy = math.sin(rot)*0.11, math.cos(rot)*0.11
  1254.  
  1255. -- setElementPosition(weapon, px+qx, py+qy, pz)
  1256. -- elseif leftSideWeapons[getElementModel(weapon)] then
  1257. -- local px, py, pz = getPedBonePosition(value, 41)
  1258. -- local qx, qy = math.sin(rot)*0.06, math.cos(rot)*0.06
  1259.  
  1260. -- setElementPosition(weapon, px-qx, py-qy, pz)
  1261.  
  1262. -- if getElementModel(weapon) == 334 then
  1263. -- local rx, ry, rz = getElementRotation(weapon)
  1264. -- setElementRotation(weapon, rx, ry+110, rz)
  1265. -- end
  1266. -- elseif backSideWeapons[getElementModel(weapon)] then
  1267. -- setElementPosition(weapon, x+ox, y+oy, z-0.2)
  1268. -- setElementRotation(weapon, -17, -(50+i), getPedRotation(value))
  1269.  
  1270. -- i = i + 15
  1271. -- elseif handbackWeapons[getElementModel(weapon)] then
  1272. -- if j % 2 == 0 then
  1273. -- setElementPosition(weapon, x+ox, y+oy, z-0.2)
  1274. -- setElementRotation(weapon, -17, -30, getPedRotation(value))
  1275. -- else
  1276. -- setElementPosition(weapon, x+ox, y+oy, z-0.2)
  1277. -- setElementRotation(weapon, -17, 30, getPedRotation(value))
  1278. -- end
  1279.  
  1280. -- j = j + 1
  1281. -- end
  1282. -- -- end
  1283. -- --end
  1284. -- end
  1285. -- end
  1286. -- end
  1287. -- end
  1288. -- end
  1289. -- end
  1290. -- end)
  1291.  
  1292. -- function streamedIn(source)
  1293. -- if isElement(source) and getElementType(source) == "player" then
  1294. -- local currentPlayer = source
  1295.  
  1296. -- streamedOut(source)
  1297.  
  1298. -- playerWeapons[getElementData(currentPlayer, "acc:id")] = {}
  1299.  
  1300. -- triggerServerEvent("getPlayerItems", localPlayer, currentPlayer)
  1301. -- setTimer(function ()
  1302. -- if not currentInventory then return end
  1303. -- for key, value in ipairs(currentInventory) do
  1304. -- if value and value[1] and (value or {-1, -1})[1] > 0 and items[value[1]][5] or -1 > 0 then
  1305. -- 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
  1306. -- for index, weapon in ipairs(playerWeapons[getElementData(currentPlayer, "acc:id")]) do
  1307. -- if isElement(weapon) and getElementModel(weapon) == getWeaponModel(items[value[1]][5]) then
  1308. -- destroyElement(weapon)
  1309. -- end
  1310. -- end
  1311.  
  1312. -- local x, y, z = getElementPosition(currentPlayer)
  1313.  
  1314. -- playerWeapons[getElementData(currentPlayer, "acc:id")][#playerWeapons[getElementData(currentPlayer, "acc:id")] + 1] =
  1315. -- createObject(getWeaponModel(items[value[1]][5]), x, y, z)
  1316.  
  1317. -- setElementCollisionsEnabled(playerWeapons[getElementData(currentPlayer, "acc:id")][#playerWeapons[getElementData(currentPlayer, "acc:id")]], false)
  1318.  
  1319. -- outputDebugString(getWeaponModel(items[value[1]][5]) .. " weapon created -> " .. getPlayerName(currentPlayer))
  1320. -- end
  1321. -- end
  1322. -- end
  1323. -- end, 100, 1)
  1324. -- end
  1325. -- end
  1326. -- addEvent("streamedIn", true)
  1327. -- addEventHandler("streamedIn", root, streamedIn)
  1328. -- addEventHandler("onClientElementStreamIn", root, streamedIn)
  1329.  
  1330. -- addEventHandler("onClientVehicleExit", root, function(source)
  1331. -- streamedIn(source)
  1332. -- end)
  1333.  
  1334. -- function streamedOut(source)
  1335. -- if source then
  1336. -- local currentPlayer = source
  1337.  
  1338. -- if playerWeapons[getElementData(currentPlayer, "acc:id")] then
  1339. -- for key, value in ipairs(playerWeapons[getElementData(currentPlayer, "acc:id")]) do
  1340. -- if isElement(value) then
  1341. -- outputDebugString(getElementModel(value) .. " weapon destroyed")
  1342. -- destroyElement(value)
  1343. -- end
  1344. -- end
  1345. -- end
  1346. -- end
  1347. -- end
  1348. -- addEventHandler("onClientElementStreamOut", root, streamedOut)
  1349.  
  1350. -- addEventHandler("onClientPlayerQuit", root, function()
  1351. -- if playerWeapons[getElementData(source, "acc:id")] then
  1352. -- for key, value in ipairs(playerWeapons[getElementData(source, "acc:id")]) do
  1353. -- if isElement(value) then
  1354. -- outputDebugString(getElementModel(value) .. " weapon destroyed")
  1355. -- destroyElement(value)
  1356. -- end
  1357. -- end
  1358. -- end
  1359. -- end)
  1360.  
  1361. -- addEventHandler("onClientPlayerWasted", root, function()
  1362. -- streamedOut(source)
  1363. -- end)
  1364.  
  1365. -- addEventHandler("onClientVehicleEnter", root, function(source)
  1366. -- streamedOut(source)
  1367. -- end)
  1368.  
  1369. -- function loadNearbyWeapons()
  1370. -- setTimer(function()
  1371. -- for key, player in ipairs(getElementsByType("player")) do
  1372. -- setTimer(function()
  1373. -- streamedIn(player)
  1374. -- end, key * 150, 1)
  1375. -- end
  1376. -- end, 200, 1)
  1377. -- end
  1378. -- addEventHandler("onClientResourceStart", resourceRoot, loadNearbyWeapons)
  1379. -- addEventHandler("onClientPlayerSpawn", root, loadNearbyWeapons)
  1380.  
  1381.  
  1382.  
  1383. function ChangeObjectModel (filename,id)
  1384. if id and filename then
  1385. if fileExists("files/" .. filename..".txd") then
  1386. txd = engineLoadTXD( "files/" .. filename..".txd" )
  1387. engineImportTXD( txd, id )
  1388. end
  1389. if fileExists("files/" .. filename..".dff") then
  1390. dff = engineLoadDFF( "files/" .. filename..".dff", 0 )
  1391. engineReplaceModel( dff, id )
  1392. end
  1393. if fileExists("files/" .. filename..".col") then
  1394. col = engineLoadCOL( "files/" .. filename..".col" )
  1395. engineReplaceCOL( col, id )
  1396. end
  1397. engineSetModelLODDistance(id,300)
  1398. end
  1399. end
  1400.  
  1401. ChangeObjectModel("villogo",903)
  1402. ChangeObjectModel("taxitable",2061)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement