Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. local hatarO = {
  2. [1] = {
  3. {64.406036376953,-1527.3177490234,4.9088416099548},
  4. {64.406036376953,-1528.3177490234,4.9088416099548},
  5. {64.406036376953,-1529.3177490234,4.9088416099548},
  6. {64.406036376953,-153.3177490234,4.9088416099548},
  7. {64.406036376953,-1526.3177490234,4.9088416099548},
  8. {64.406036376953,-1525.3177490234,4.9088416099548},
  9. }
  10. }
  11.  
  12. local col = {
  13. [1] = {67.351470947266, -1527.501953125, 2.0141353607178}
  14. }
  15. addEventHandler("onResourceStart", resourceRoot,
  16. function ()
  17. for id, datas in pairs(hatarO) do
  18. for _, values in pairs(datas) do
  19. local x, y, z = unpack(values)
  20. local hatar = createObject(1214, x, y, z-1)
  21. setElementFrozen(hatar, true)
  22. setElementData(hatar, "hatar.id", id)
  23. setElementData(hatar, "hatar.state", true)
  24. end
  25. local x, y, z = unpack(col[id])
  26. local col = createColSphere(x, y, z, 5)
  27. setElementData(col, "hatar.id", id)
  28. setElementData(col, "hatar.state", true)
  29. end
  30. end
  31. )
  32.  
  33. function changeHatarState(id, state)
  34. local objs = {}
  35. for k,v in pairs(getElementsByType("object", resourceRoot)) do
  36. local objID = (getElementData(v, "hatar.id") or -1)
  37. if objID > 0 and objID == id then
  38. table.insert(objs,v)
  39. end
  40. end
  41. for key, element in pairs(objs) do
  42. local x, y, z = getElementPosition(element)
  43. if state then
  44. moveObject(element,2000, x, y, z-1.4)
  45. else
  46. moveObject(element ,2000, x, y, z+1.4)
  47. end
  48. end
  49. end
  50. addEvent("hatar.open", true)
  51. addEventHandler("hatar.open", resourceRoot,
  52. function(player, element)
  53. local id = getElementData(element,"hatar.id")
  54. local state = getElementData(element , "hatar.state") or true
  55. if state then
  56. changeHatarState(id, false)
  57. setElementData(element, "hatar.state", false)
  58. setTimer(function()
  59. changeHatarState(id, true)
  60. setElementData(element, "border.state", true)
  61. end , 5000, 1)
  62. end
  63. end
  64. )
  65. addEvent("removePay", true)
  66. addEventHandler("removePay", resourceRoot,
  67. function()
  68. local pMoney = getPlayerMoney(client)
  69. setPlayerMoney(client, pMoney-150)
  70. end
  71. )
  72.  
  73.  
  74.  
  75.  
  76. Client oldal:
  77.  
  78. local sx, sy = guiGetScreenSize()
  79. local relX, relY = sx/1920, sy/1080
  80.  
  81. local panelPos = {0.36, 0.4}
  82. local buttonColor = {
  83. [1] = tocolor(39, 227, 61, 230),
  84. [2] = tocolor(220, 0, 0, 230)
  85. }
  86.  
  87. local panelActive = false
  88.  
  89. addEventHandler("onClientRender", root,
  90. function()
  91. if panelActive then
  92. dxDrawRectangle(sx*panelPos[1], sy*panelPos[2], sx*0.25, sy*0.2, tocolor(0, 0, 0, 230), false) -- alap felület
  93. dxDrawText("A határ átkelés díja: 150$", sx*(panelPos[1]+0.175), sy*(panelPos[2]+0.05), sx*(panelPos[1]+0.175), sy*(panelPos[2]+0.05), tocolor(255, 255, 255, 255), relX*1.4, relY*1.5, "sans", "right", "center", false, false, false ) -- money
  94.  
  95. dxDrawRectangle(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.15), sx*0.15, sy*0.035, buttonColor[2], false)
  96. dxDrawText("mégsem", sx*(panelPos[1]+0.1), sy*(panelPos[2]+0.185), sx*(panelPos[1]+0.15), sy*(panelPos[2]+0.15), tocolor(255, 255, 255, 255), relX*2.1, relY*2.2, "sans", "right", "center", false, false, false ) -- money
  97.  
  98. dxDrawRectangle(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.1), sx*0.15, sy*0.035, buttonColor[1], false)
  99. dxDrawText("átkelés", sx*(panelPos[1]+0.12), sy*(panelPos[2]+0.085), sx*(panelPos[1]+0.145), sy*(panelPos[2]+0.15), tocolor(255, 255, 255, 255), relX*2.1, relY*2.2, "sans", "right", "center", false, false, false ) -- money
  100.  
  101.  
  102. end
  103. end
  104. )
  105.  
  106. addEventHandler("onClientColShapeHit", root,
  107. function(hitElement, dimension)
  108. if (getElementData(source, "hatar.id") or -1) > 0 then
  109. if hitElement == localPlayer and dimension then
  110. local veh = getPedOccupiedVehicle(localPlayer)
  111. if veh then
  112. panelActive = true
  113. end
  114. end
  115. end
  116. end
  117. )
  118.  
  119. addEventHandler("onClientColShapeLeave", root,
  120. function(hitElement, dimension)
  121. if (getElementData(source, "hatar.id") or -1) > 0 then
  122. if hitElement == localPlayer and dimension then
  123. panelActive = false
  124. end
  125. end
  126. end
  127. )
  128.  
  129.  
  130. addEventHandler("onClientCursorMove", root,
  131. function ()
  132. if showCursor then
  133. if panelActive then
  134. if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.15), sx*0.15, sy*0.035)) then
  135. buttonColor[2] = tocolor(200, 0, 0, 230)
  136.  
  137. else
  138. buttonColor[2] = tocolor(220, 0, 0, 230)
  139. end
  140.  
  141. if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.1), sx*0.15, sy*0.035)) then
  142. buttonColor[1] = tocolor(39, 207, 61, 230)
  143. else
  144. buttonColor[1] = tocolor(39, 227, 61, 230)
  145. end
  146. end
  147. end
  148. end
  149. )
  150.  
  151. addEventHandler("onClientClick", root,
  152. function(btn, state)
  153. if showCursor then
  154. if ((btn == "left") and (state == "down")) then
  155. if panelActive then
  156. if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.1), sx*0.15, sy*0.035)) then
  157. if (getPlayerMoney(localPlayer) < 150) then
  158. outputChatBox("Nincs elég pénzed hogy átkelj a határon")
  159. else
  160. triggerServerEvent("removePay", resourceRoot)
  161. triggerServerEvent("hatar.open", localPlayer, localPlayer, panelActive)
  162. end
  163. else
  164. if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.15), sx*0.15, sy*0.035)) then
  165. panelActive = false
  166. end
  167.  
  168. end
  169. end
  170. end
  171. end
  172. end
  173. )
  174. ------ usefules function -----
  175.  
  176. function isMouseInPosition ( x, y, width, height )
  177. if ( not isCursorShowing( ) ) then
  178. return false
  179. end
  180. local sx, sy = guiGetScreenSize ( )
  181. local cx, cy = getCursorPosition ( )
  182. local cx, cy = ( cx * sx ), ( cy * sy )
  183.  
  184. return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
  185. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement