Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hatarO = {
- [1] = {
- {64.406036376953,-1527.3177490234,4.9088416099548},
- {64.406036376953,-1528.3177490234,4.9088416099548},
- {64.406036376953,-1529.3177490234,4.9088416099548},
- {64.406036376953,-153.3177490234,4.9088416099548},
- {64.406036376953,-1526.3177490234,4.9088416099548},
- {64.406036376953,-1525.3177490234,4.9088416099548},
- }
- }
- local col = {
- [1] = {67.351470947266, -1527.501953125, 2.0141353607178}
- }
- addEventHandler("onResourceStart", resourceRoot,
- function ()
- for id, datas in pairs(hatarO) do
- for _, values in pairs(datas) do
- local x, y, z = unpack(values)
- local hatar = createObject(1214, x, y, z-1)
- setElementFrozen(hatar, true)
- setElementData(hatar, "hatar.id", id)
- setElementData(hatar, "hatar.state", true)
- end
- local x, y, z = unpack(col[id])
- local col = createColSphere(x, y, z, 5)
- setElementData(col, "hatar.id", id)
- setElementData(col, "hatar.state", true)
- end
- end
- )
- function changeHatarState(id, state)
- local objs = {}
- for k,v in pairs(getElementsByType("object", resourceRoot)) do
- local objID = (getElementData(v, "hatar.id") or -1)
- if objID > 0 and objID == id then
- table.insert(objs,v)
- end
- end
- for key, element in pairs(objs) do
- local x, y, z = getElementPosition(element)
- if state then
- moveObject(element,2000, x, y, z-1.4)
- else
- moveObject(element ,2000, x, y, z+1.4)
- end
- end
- end
- addEvent("hatar.open", true)
- addEventHandler("hatar.open", resourceRoot,
- function(player, element)
- local id = getElementData(element,"hatar.id")
- local state = getElementData(element , "hatar.state") or true
- if state then
- changeHatarState(id, false)
- setElementData(element, "hatar.state", false)
- setTimer(function()
- changeHatarState(id, true)
- setElementData(element, "border.state", true)
- end , 5000, 1)
- end
- end
- )
- addEvent("removePay", true)
- addEventHandler("removePay", resourceRoot,
- function()
- local pMoney = getPlayerMoney(client)
- setPlayerMoney(client, pMoney-150)
- end
- )
- Client oldal:
- local sx, sy = guiGetScreenSize()
- local relX, relY = sx/1920, sy/1080
- local panelPos = {0.36, 0.4}
- local buttonColor = {
- [1] = tocolor(39, 227, 61, 230),
- [2] = tocolor(220, 0, 0, 230)
- }
- local panelActive = false
- addEventHandler("onClientRender", root,
- function()
- if panelActive then
- dxDrawRectangle(sx*panelPos[1], sy*panelPos[2], sx*0.25, sy*0.2, tocolor(0, 0, 0, 230), false) -- alap felület
- 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
- dxDrawRectangle(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.15), sx*0.15, sy*0.035, buttonColor[2], false)
- 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
- dxDrawRectangle(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.1), sx*0.15, sy*0.035, buttonColor[1], false)
- 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
- end
- end
- )
- addEventHandler("onClientColShapeHit", root,
- function(hitElement, dimension)
- if (getElementData(source, "hatar.id") or -1) > 0 then
- if hitElement == localPlayer and dimension then
- local veh = getPedOccupiedVehicle(localPlayer)
- if veh then
- panelActive = true
- end
- end
- end
- end
- )
- addEventHandler("onClientColShapeLeave", root,
- function(hitElement, dimension)
- if (getElementData(source, "hatar.id") or -1) > 0 then
- if hitElement == localPlayer and dimension then
- panelActive = false
- end
- end
- end
- )
- addEventHandler("onClientCursorMove", root,
- function ()
- if showCursor then
- if panelActive then
- if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.15), sx*0.15, sy*0.035)) then
- buttonColor[2] = tocolor(200, 0, 0, 230)
- else
- buttonColor[2] = tocolor(220, 0, 0, 230)
- end
- if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.1), sx*0.15, sy*0.035)) then
- buttonColor[1] = tocolor(39, 207, 61, 230)
- else
- buttonColor[1] = tocolor(39, 227, 61, 230)
- end
- end
- end
- end
- )
- addEventHandler("onClientClick", root,
- function(btn, state)
- if showCursor then
- if ((btn == "left") and (state == "down")) then
- if panelActive then
- if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.1), sx*0.15, sy*0.035)) then
- if (getPlayerMoney(localPlayer) < 150) then
- outputChatBox("Nincs elég pénzed hogy átkelj a határon")
- else
- triggerServerEvent("removePay", resourceRoot)
- triggerServerEvent("hatar.open", localPlayer, localPlayer, panelActive)
- end
- else
- if (isMouseInPosition(sx*(panelPos[1]+0.05), sy*(panelPos[2]+0.15), sx*0.15, sy*0.035)) then
- panelActive = false
- end
- end
- end
- end
- end
- end
- )
- ------ usefules function -----
- function isMouseInPosition ( x, y, width, height )
- if ( not isCursorShowing( ) ) then
- return false
- end
- local sx, sy = guiGetScreenSize ( )
- local cx, cy = getCursorPosition ( )
- local cx, cy = ( cx * sx ), ( cy * sy )
- return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement