Sucrilhex Posted June 6, 2020 Posted June 6, 2020 Olá, estou com uma concessionaria e nela tem uma garagem, na garagem mostra o nome dos veiculos originais, exemplo "Infernus", eu gostaria que mostrasse o nome personalizado "Ferrari", ja tentei varias vezes e todas sem sucesso, por isso vim aqui para pedir ajuda. Parte de comprar o carro local screenW, screenH = guiGetScreenSize() local x, y = (screenW/1024), (screenH/768) local Font_1 = dxCreateFont("font/font.ttf", y*11) local Font_2 = dxCreateFont("font/font1.ttf", y*11) local Font_3 = dxCreateFont("font/fontNick.ttf", y*10) local Font_4 = dxCreateFont("font/OpenSans-Bold.ttf", y*15) triggerServerEvent("DNL:OpenInventory", localPlayer) function Dx_Concessionaria () exports["Res_blur"]:dxDrawBluredRectangle(screenW * 0.6348, screenH * 0.2786, screenW * 0.2813, screenH * 0.5846, tocolor(255, 255, 255, 255)) dxDrawRectangle(screenW * 0.6348, screenH * 0.2786, screenW * 0.2813, screenH * 0.5846, tocolor(0, 0, 0, 100), false) dxDrawRectangle(screenW * 0.6348, screenH * 0.2786, screenW * 0.2813, screenH * 0.0560, tocolor(220, 20, 60, 254), false) --dxDrawRectangle(screenW * 0.6445, screenH * 0.3581, screenW * 0.2617, screenH * 0.3099, tocolor(0, 0, 0, 254), false) dxDrawImage(screenW * 0.6445, screenH * 0.6979, screenW * 0.2607, screenH * 0.0664, "Img/botao2.png", 0, 0, 0, tocolor(23, 241, 23, 159), false) dxDrawImage(screenW * 0.6455, screenH * 0.7839, screenW * 0.2607, screenH * 0.0664, "Img/botao2.png", 0, 0, 0, tocolor(254, 9, 9, 159), false) dxDrawText("CONCESSIONARIA", screenW * 0.6348, screenH * 0.2786, screenW * 0.9160, screenH * 0.3346, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", false, false, false, false, false) dxDrawText("COMPRAR", screenW * 0.6445, screenH * 0.6979, screenW * 0.9063, screenH * 0.7643, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("FECHAR", screenW * 0.6455, screenH * 0.7839, screenW * 0.9072, screenH * 0.8503, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) --[[CorComprar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*1055, y*650, x*215, y*45) then CorComprar = tocolor(0, 60, 160, 150)]] end --addEventHandler("onClientRender", root, Dx_Concessionaria) addEventHandler("onClientResourceStart", resourceRoot, function () Lista_Veiculos = dxGridW:Create(879, 260, 350, 250) Lista_Veiculos:AddColumn("Nome", 122) -- Nome veiculo Lista_Veiculos:AddColumn("Preço", 118) -- PreçoS Lista_Veiculos:AddColumn("Id", 122) -- IDS Lista_Veiculos:SetVisible(false) end) MarkesTableCarros = {} -- Tabela vazia Carros () ------------- ADICIONE AQUI OS CARROS ------------- local ShopsCarros = { ------ LOJA CARRO LS ------ [1] = {IDCarros = { {"Pop 110cc", 462, 5000}, -- Nome, Id Preço {"Honda Biz 125cc", 586, 9000}, {"XJ6", 521, 26000}, {"Ducati 999R", 522, 45000}, {"Caravan", 479, 15000}, {"Celta", 560, 19000}, {"Gol GTI", 589, 24000}, {"Fiesta", 436, 40000}, {"Civic", 585, 87000}, {"Sonata", 421, 90000}, {"Tesla", 405, 120000}, {"S10", 400, 150000}, {"Jeep Cherokee", 529, 200000}, {"BMW M3", 558, 280000}, {"Dodge Charger", 542, 320000}, {"Dodge Viper", 429, 390000}, {"Mazda RX8", 602, 465000}, {"GTR-R32", 562, 530000}, {"Porshe", 480, 850000}, {"Ferrari", 506, 1000000}, {"McLaren", 541, 1500000}, {"Lamborghini", 411, 3000000}, }, -- frente marker 1264.341, -1830.56, 13.627 -- Posição do Veiculo Quando For Comprar Veh_X = 1264.539, Veh_Y = -1821.843, Veh_Z = 13.627, -- Posição da Camera Quando For Comprar CamX = 1264.091, CamY = -1830.435, CamZ = 13.627, -- Focamento da Camera Quando For Comprar Fock_X = 1264.091, Fock_Y = -1830.435, Fock_Z = 13.627 }, } ------------- MARKERS CARROS ------------- for i, v in ipairs(ShopsCarros) do MarkerCarros = createMarker(1264.122, -1833.906, 13.627 -1, "cylinder", 3, 0, 60, 160, 60) MarkesTableCarros[MarkerCarros] = true setElementID(MarkerCarros, tostring(i)) Blip = createBlipAttachedTo(MarkerCarros, 55, 2, 255, 255, 255, 255, 0, 500) ----- $@$@ BLIP DOS CARRO AQUI setBlipVisibleDistance(Blip , 150) end ------------- COLIDIR COM MARKERS CARROS ------------- function Ativar_LojaCarro (player) if getElementType(player) ~= "player" or player ~= localPlayer or isPedInVehicle(player) then return end if MarkesTableCarros[source] then i = tonumber(getElementID(source)) Lista_Veiculos:Clear() for i, v in ipairs(ShopsCarros[i]["IDCarros"]) do Lista_Veiculos:AddItem(1, tostring(v[1])) -- Name Lista_Veiculos:AddItem(3, tostring(v[2])) -- Preço Lista_Veiculos:AddItem(2, tostring(v[3])) -- ID end Lista_Veiculos:SetSelectedItem (1) setElementData(localPlayer, "Concessionaria", "Carro") setTimer(function() local SelectCar = Lista_Veiculos:GetSelectedItem() local ID_Car = Lista_Veiculos:GetItemDetails(3, SelectCar) local x, y, z = ShopsCarros[i]["Veh_X"], ShopsCarros[i]["Veh_Y"], ShopsCarros[i]["Veh_Z"] if isElement(veh) then destroyElement(veh) end if isTimer(timer) then killTimer(timer) end showCursor(true) showChat(false) setElementFrozen(localPlayer, true) setElementAlpha(localPlayer, 0) veh = createVehicle(ID_Car, x, y, z) setVehicleColor( veh, 255, 255, 255, 255, 255, 255 ) setVehicleDamageProof(veh, true) setElementFrozen(veh, true) Lista_Veiculos:SetVisible(true) addEventHandler("onClientRender", root, Dx_Concessionaria) setCameraMatrix(ShopsCarros[i]["CamX"], ShopsCarros[i]["CamY"], ShopsCarros[i]["CamZ"], ShopsCarros[i]["Fock_X"], ShopsCarros[i]["Fock_Y"], ShopsCarros[i]["Fock_Z"]) timer = setTimer(function() local x, y, z = getElementRotation(veh) setElementRotation(veh, x, y, z+3) end, 50, 0) end, 100, 1) end end addEventHandler("onClientMarkerHit", resourceRoot, Ativar_LojaCarro) --=============================-- ------------- CLICKS ------------ --=============================-- function Clicks ( _,state ) if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Concessionaria) then if state == "down" then if isCursorOnElement ( screenW * 0.6455, screenH * 0.7839, screenW * 0.2607, screenH * 0.0664 ) then -- Close Painel if isElement(veh) then destroyElement(veh) end if isTimer(timer) then killTimer(timer) end if getElementData(localPlayer, "Concessionaria") == "Carro" then setTimer(function() setElementPosition ( localPlayer, 1264.122, -1833.906, 13.627 ) end, 1000, 1) end showChat(true) showCursor(false) setElementFrozen(localPlayer, false) fadeCamera(false, 1.0) Lista_Veiculos:SetVisible(false) setElementData(localPlayer, "Concessionaria", nil) removeEventHandler("onClientRender", root, Dx_Concessionaria) setTimer(function() fadeCamera(true, 0.5) setCameraTarget(localPlayer) end, 1000, 1) setTimer(function() setElementAlpha(localPlayer, 255) end, 1000, 1) elseif isCursorOnElement ( screenW * 0.6445, screenH * 0.6979, screenW * 0.2607, screenH * 0.0664 ) then -- Comprar Veiculo local Name_Car = Lista_Veiculos:GetItemDetails(1, Lista_Veiculos:GetSelectedItem()) local Preco = Lista_Veiculos:GetItemDetails(2, Lista_Veiculos:GetSelectedItem()) local Carro = Lista_Veiculos:GetItemDetails(3, Lista_Veiculos:GetSelectedItem()) triggerServerEvent("DNL:ComprarVeiculo", root, localPlayer, Name_Car, Preco, Carro) showChat(true) showCursor(false) setElementFrozen( localPlayer, false) fadeCamera(false, 1.0) Lista_Veiculos:SetVisible(false) setElementData (localPlayer, "Carro", nil) removeEventHandler("onClientRender", root, Dx_Concessionaria) setTimer(function() fadeCamera(true, 0.5) setCameraTarget(localPlayer) end, 1000, 1) setTimer(function() setElementAlpha(localPlayer, 255) end, 1000, 1) if isElement(veh) then destroyElement(veh) end if isTimer(timer) then killTimer(timer) end elseif (Lista_Veiculos:IsVisible()) then local SelectCar = Lista_Veiculos:GetSelectedItem() local get_ID = Lista_Veiculos:GetItemDetails(3, SelectCar) if (SelectCar ~= -1) then if isElement(veh) then setElementModel(veh, get_ID) return end local x, y, z = ShopsCarros[i]["Veh_X"], ShopsCarros[i]["Veh_Y"], ShopsCarros[i]["Veh_Z"] veh = createVehicle(get_ID, x, y, z) setVehicleDamageProof(veh, true) setElementFrozen(veh, true) timer = setTimer(function() local x, y, z = getElementRotation(veh) setElementRotation(veh, x, y, z+3) end, 50, 0) else if isElement(veh) then destroyElement(veh) end if isTimer(timer) then killTimer(timer) end end end end end end addEventHandler ( "onClientClick", root, Clicks ) --=============================-- ------------- IGNORA ------------ --=============================-- AllKeys = { "arrow_l", "arrow_u", "arrow_r", "arrow_d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_mul", "num_add", "num_sep", "num_sub", "num_div", "num_dec", "num_enter", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "escape", "backspace", "tab", "lalt", "ralt", "enter", "space", "pgup", "pgdn", "end", "home", "insert", "delete", "lshift", "rshift", "lctrl", "rctrl", "[", "]", "pause", "capslock", "scroll", ";", ",", "-", ".", "/", "#", "\\", "=" } addEventHandler("onClientKey", root, function(button, press) for index, keys in pairs(AllKeys) do if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Concessionaria) then if button == keys then cancelEvent() end end end end ) function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) dxDrawText ( text, x - 1, y, w - 1, h, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 1, y, w + 1, h, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - 1, w, h - 1, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + 1, w, h + 1, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end function contornoRetangulo(absX, absY, sizeX, sizeY, color, ancho) dxDrawRectangle(absX, absY, sizeX, ancho, color) dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color) dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color) dxDrawRectangle(absX + sizeX - ancho, absY + ancho, ancho, sizeY - ancho*2, color) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end local x,y = guiGetScreenSize() function isCursorOnElement(x, y, w, h) if (not isCursorShowing()) then return false end local mx, my = getCursorPosition() local fullx, fully = guiGetScreenSize() cursorx, cursory = mx*fullx, my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end parte da garagem local screenW,screenH = guiGetScreenSize() local resW,resH = 1366,768 local x,y = (screenW/resW), (screenH/resH) DGS = exports.Res_dgs local Font_1 = dxCreateFont("font/font.ttf", y*11) local Font_2 = dxCreateFont("font/font1.ttf", y*11) local Font_3 = dxCreateFont("font/fontNick.ttf", y*11) local Font_4 = dxCreateFont("font/OpenSans-Bold.ttf", y*14) function Abrir_Garagem() if getElementInterior(localPlayer) == 0 and getElementDimension(localPlayer) == 0 then if not isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then showCursor(true) DGS:dgsSetVisible(SeusCarros, true) addEventHandler("onClientRender", root, Dx_Garagem) end end end addEvent("DNL:Abrir(Garagem)", true) addEventHandler("DNL:Abrir(Garagem)", root, Abrir_Garagem) function Fechar_Garagem() if getElementInterior(localPlayer) == 0 and getElementDimension(localPlayer) == 0 then if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then showCursor(false) DGS:dgsSetVisible(SeusCarros, false) removeEventHandler("onClientRender", root, Dx_Garagem) end end end addEvent("DNL:Fechar(Garagem)", true) addEventHandler("DNL:Fechar(Garagem)", root, Fechar_Garagem) --=============================-- ---------- Dx Garagem ----------- --=============================-- function Dx_Garagem() exports["Res_blur"]:dxDrawBluredRectangle(x*500, y*193, x*366, y*450, tocolor(255, 255, 255, 255)) dxDrawRectangle(x*500, y*193, x*366, y*450, tocolor(200, 200, 200, 180), false) dxDrawRectangle(x*500, y*193, x*366, y*58, tocolor(0, 0, 0, 222), false) dxDrawLine(x*500, y*251, x*866, y*251, tocolor(0, 60, 160, 200), 2, false) dxDrawLine(x*500, y*482, x*866, y*482, tocolor(0, 60, 160, 200), 2, false) contornoRetangulo(x*500, y*193, x*366, y*450, tocolor(0, 0, 0, 222), x*1) -- Line enfeite dxDrawText("Garagem", x*643, y*210, x*724, y*234, tocolor(255, 255, 255, 255), 1, Font_4, "left", "top", false, false, false, false, false) dxDrawImage(x*602, y*493, x*162, y*40, "Img/botao.png", 0, 0, 0, CorPuxar, false) dxDrawText("Puxar", x*665, y*503, x*702, y*521, tocolor(0, 0, 0, 255), 1, Font_3, "left", "top", false, false, false, false, false) CorPuxar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*602, y*493, x*162, y*40) then CorPuxar = tocolor(0, 60, 160, 255) end dxDrawImage(x*602, y*543, x*162, y*40, "Img/botao.png", 0, 0, 0, CorGuardar, false) dxDrawText("Guardar", x*658, y*553, x*710, y*571, tocolor(0, 0, 0, 255), 1, Font_3, "left", "top", false, false, false, false, false) CorGuardar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*602, y*543, x*162, y*40) then CorGuardar = tocolor(0, 60, 160, 255) end dxDrawImage(x*602, y*593, x*162, y*40, "Img/botao.png", 0, 0, 0, CorSpawnar, false) dxDrawText("Spawnar", x*657, y*603, x*713, y*621, tocolor(0, 0, 0, 255), 1, Font_3, "left", "top", false, false, false, false, false) CorSpawnar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*602, y*593, x*162, y*40) then CorSpawnar = tocolor(0, 60, 160, 255) end dxDrawText("X", x*835, y*210, x*724, y*234, CorClose, 1, Font_4, "left", "top", false, false, false, false, false) CorClose = tocolor(100, 100, 100, 255) if isCursorOnElement(x*835, y*210, x*17, y*17) then CorClose = tocolor(255, 0, 0, 255) end end --addEventHandler("onClientRender", root, Dx_Garagem) --=============================-- ---------- AddCar_List ---------- --=============================-- SeusCarros = DGS:dgsCreateGridList(x*500, y*231, x*366, y*232,false) DGS:dgsGridListAddColumn(SeusCarros,"", 1) DGS:dgsSetVisible(SeusCarros, false) function Refresh_Lista() local data = getElementData(localPlayer, "VehicleInfo") if data then DGS:dgsGridListClearRow(SeusCarros) for i, data in ipairs (data) do local NameCarro = getVehicleNameFromModel(data["Model"]) local ID = data["ID"] local row = DGS:dgsGridListAddRow(SeusCarros) DGS:dgsGridListSetItemText(SeusCarros, row, 1, NameCarro, false, true) DGS:dgsGridListSetItemData(SeusCarros, row, 1, ID) end end end addEventHandler("onClientElementDataChange", root, function(dd) if getElementType(source) == "player" and source == localPlayer and dd == "VehicleInfo" then local data = getElementData(source, dd) if data then Refresh_Lista() end end end) --=============================-- ---------- ClickListCar --------- --=============================-- function Clicks_Garagem ( _,state ) local id = DGS:dgsGridListGetSelectedItem(SeusCarros) local ID = DGS:dgsGridListGetItemData(SeusCarros, id, 1) if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then if isCursorOnElement ( x*835, y*210, x*17, y*17 ) then playSoundFrontEnd(8) Fechar_Garagem () end if state == "down" then if (id ~= -1) then if isCursorOnElement ( x*602, y*493, x*162, y*40 ) then playSoundFrontEnd(2) triggerServerEvent("DNL:Trazer_Veh", root, localPlayer, ID) elseif isCursorOnElement ( x*602, y*543, x*162, y*40 ) then playSoundFrontEnd(2) triggerServerEvent("DNL:Guardar_Veh", root, localPlayer, ID) elseif isCursorOnElement ( x*602, y*593, x*162, y*40 ) then playSoundFrontEnd(2) triggerServerEvent("DNL:Spawnar_Veh", root, localPlayer, ID) end end end end end addEventHandler ( "onClientClick", root, Clicks_Garagem ) --=============================-- ------------- IGNORA ------------ --=============================-- AllKeys = { "arrow_l", "arrow_u", "arrow_r", "arrow_d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_mul", "num_add", "num_sep", "num_sub", "num_div", "num_dec", "num_enter", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "escape", "backspace", "tab", "lalt", "ralt", "enter", "space", "pgup", "pgdn", "end", "home", "insert", "delete", "lshift", "rshift", "lctrl", "rctrl", "[", "]", "pause", "capslock", "scroll", ";", ",", "-", ".", "/", "#", "\\", "=" } addEventHandler("onClientKey", root, function(button, press) for index, keys in pairs(AllKeys) do if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then if button == keys then cancelEvent() end end end end ) function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) dxDrawText ( text, x - 1, y, w - 1, h, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 1, y, w + 1, h, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - 1, w, h - 1, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + 1, w, h + 1, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end function contornoRetangulo(absX, absY, sizeX, sizeY, color, ancho) dxDrawRectangle(absX, absY, sizeX, ancho, color) dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color) dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color) dxDrawRectangle(absX + sizeX - ancho, absY + ancho, ancho, sizeY - ancho*2, color) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end local x,y = guiGetScreenSize() function isCursorOnElement(x, y, w, h) if (not isCursorShowing()) then return false end local mx, my = getCursorPosition() local fullx, fully = guiGetScreenSize() cursorx, cursory = mx*fullx, my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end
MrKAREEM Posted June 7, 2020 Posted June 7, 2020 crie tabela como este exemplo, que possui 2 colunas, a primeira é a sequência do nome do seu veículo personalizado e o segundo é o ID do veículo que você deseja alterar o nome vehicles = { {'Ferrari',577}, {'Lamborghini',519}, } Table e quando ele entrar na garagem, pegue a ID do veículo usando a função abaixo GetElementModel depois de obter a ID, verifique se a ID atual do veículo na tabela ou não local id = getElementModel(your car here) for i,v in ipairs(vehicles) do if v[2] == id then Text = v[1] else end end agora você pode usar o texto variável no desenho dxText
Sucrilhex Posted June 8, 2020 Author Posted June 8, 2020 On 07/06/2020 at 14:04, MrKAREEM said: crie tabela como este exemplo, que possui 2 colunas, a primeira é a sequência do nome do seu veículo personalizado e o segundo é o ID do veículo que você deseja alterar o nome vehicles = {{'Ferrari',577},{'Lamborghini',519},} Table e quando ele entrar na garagem, pegue a ID do veículo usando a função abaixo GetElementModel depois de obter a ID, verifique se a ID atual do veículo na tabela ou não local id = getElementModel(your car here)for i,v in ipairs(vehicles) doif v[2] == id thenText = v[1]elseendend agora você pode usar o texto variável no desenho dxText opa, tentei aqui e não consegui, não entendi muito bem a explicação
MrKAREEM Posted June 8, 2020 Posted June 8, 2020 35 minutes ago, Sucrilhex said: opa, tentei aqui e não consegui, não entendi muito bem a explicação mostre sua tentativa
Sucrilhex Posted June 8, 2020 Author Posted June 8, 2020 1 hour ago, MrKAREEM said: mostre sua tentativa ja apaguei a tentativa, eu copiei a parte da tabela e o outro ali, e fui tentando mudar já tentei pegar a base de outros mods, só que tá dificil
Sucrilhex Posted June 12, 2020 Author Posted June 12, 2020 (edited) On 08/06/2020 at 18:08, MrKAREEM said: mostre sua tentativa local screenW,screenH = guiGetScreenSize() local resW,resH = 1366,768 local x,y = (screenW/resW), (screenH/resH) DGS = exports.Res_dgs local Font_1 = dxCreateFont("font/font.ttf", y*11) local Font_2 = dxCreateFont("font/font1.ttf", y*11) local Font_3 = dxCreateFont("font/fontNick.ttf", y*11) local Font_4 = dxCreateFont("font/OpenSans-Bold.ttf", y*14) function Abrir_Garagem() if getElementInterior(localPlayer) == 0 and getElementDimension(localPlayer) == 0 then if not isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then showCursor(true) DGS:dgsSetVisible(SeusCarros, true) addEventHandler("onClientRender", root, Dx_Garagem) end end end addEvent("DNL:Abrir(Garagem)", true) addEventHandler("DNL:Abrir(Garagem)", root, Abrir_Garagem) function Fechar_Garagem() if getElementInterior(localPlayer) == 0 and getElementDimension(localPlayer) == 0 then if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then showCursor(false) DGS:dgsSetVisible(SeusCarros, false) removeEventHandler("onClientRender", root, Dx_Garagem) end end end addEvent("DNL:Fechar(Garagem)", true) addEventHandler("DNL:Fechar(Garagem)", root, Fechar_Garagem) --=============================-- ---------- Dx Garagem ----------- --=============================-- function Dx_Garagem() exports["Res_blur"]:dxDrawBluredRectangle(x*500, y*193, x*366, y*450, tocolor(255, 255, 255, 255)) dxDrawRectangle(x*500, y*193, x*366, y*450, tocolor(200, 200, 200, 180), false) dxDrawRectangle(x*500, y*193, x*366, y*58, tocolor(0, 0, 0, 222), false) dxDrawLine(x*500, y*251, x*866, y*251, tocolor(0, 60, 160, 200), 2, false) dxDrawLine(x*500, y*482, x*866, y*482, tocolor(0, 60, 160, 200), 2, false) contornoRetangulo(x*500, y*193, x*366, y*450, tocolor(0, 0, 0, 222), x*1) -- Line enfeite dxDrawText("Garagem", x*643, y*210, x*724, y*234, tocolor(255, 255, 255, 255), 1, Font_4, "left", "top", false, false, false, false, false) dxDrawImage(x*602, y*493, x*162, y*40, "Img/botao.png", 0, 0, 0, CorPuxar, false) dxDrawText("Puxar", x*665, y*503, x*702, y*521, tocolor(0, 0, 0, 255), 1, Font_3, "left", "top", false, false, false, false, false) CorPuxar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*602, y*493, x*162, y*40) then CorPuxar = tocolor(0, 60, 160, 255) end dxDrawImage(x*602, y*543, x*162, y*40, "Img/botao.png", 0, 0, 0, CorGuardar, false) dxDrawText("Guardar", x*658, y*553, x*710, y*571, tocolor(0, 0, 0, 255), 1, Font_3, "left", "top", false, false, false, false, false) CorGuardar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*602, y*543, x*162, y*40) then CorGuardar = tocolor(0, 60, 160, 255) end dxDrawImage(x*602, y*593, x*162, y*40, "Img/botao.png", 0, 0, 0, CorSpawnar, false) dxDrawText("Spawnar", x*657, y*603, x*713, y*621, tocolor(0, 0, 0, 255), 1, Font_3, "left", "top", false, false, false, false, false) CorSpawnar = tocolor(0, 60, 160, 200) if isCursorOnElement(x*602, y*593, x*162, y*40) then CorSpawnar = tocolor(0, 60, 160, 255) end dxDrawText("X", x*835, y*210, x*724, y*234, CorClose, 1, Font_4, "left", "top", false, false, false, false, false) CorClose = tocolor(100, 100, 100, 255) if isCursorOnElement(x*835, y*210, x*17, y*17) then CorClose = tocolor(255, 0, 0, 255) end end --addEventHandler("onClientRender", root, Dx_Garagem) --=============================-- ---------- AddCar_List ---------- --=============================-- local customCarNames = { {586, "Biz"}, {462, "Pop 100"}, {479, "Caravan"}, {560, "Celta"}, {585, "Civic"}, {542, "Dodge Charger"}, {506, "Ferrari"}, {436, "Fiésta"}, {589, "Gol GTI"}, {529, "Jeep Cherokee"}, {558, "Bmw M3"}, {602, "Mazda"}, {541, "McLaren"}, {480, "Porsche"}, {400, "S10"}, {562, "Skyline"}, {421, "Sonata"}, {405, "Tesla"}, {429, "Dodge Viper"}, {521, "XJ6"}, } function getVehicleRealName(model) for k, v in ipairs(customCarNames) do if v[1] == model then return v[2] end end return "Desconhecido" end SeusCarros = DGS:dgsCreateGridList(x*500, y*231, x*366, y*232,false) DGS:dgsGridListAddColumn(SeusCarros,"", 1) DGS:dgsSetVisible(SeusCarros, false) function Refresh_Lista() local data = getElementData(localPlayer, "VehicleInfo") if data then DGS:dgsGridListClearRow(SeusCarros) for i, data in ipairs (data) do local NameCarro = getElementModel(customCarNames) local ID = data["ID"] local row = DGS:dgsGridListAddRow(SeusCarros) DGS:dgsGridListSetItemText(SeusCarros, row, 1, NameCarro, false, true) DGS:dgsGridListSetItemData(SeusCarros, row, 1, ID) end end end addEventHandler("onClientElementDataChange", root, function(dd) if getElementType(source) == "player" and source == localPlayer and dd == "VehicleInfo" then local data = getElementData(source, dd) if data then Refresh_Lista() end end end) --=============================-- ---------- ClickListCar --------- --=============================-- function Clicks_Garagem ( _,state ) local id = DGS:dgsGridListGetSelectedItem(SeusCarros) local ID = DGS:dgsGridListGetItemData(SeusCarros, id, 1) if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then if isCursorOnElement ( x*835, y*210, x*17, y*17 ) then playSoundFrontEnd(8) Fechar_Garagem () end if state == "down" then if (id ~= -1) then if isCursorOnElement ( x*602, y*493, x*162, y*40 ) then playSoundFrontEnd(2) triggerServerEvent("DNL:Trazer_Veh", root, localPlayer, ID) elseif isCursorOnElement ( x*602, y*543, x*162, y*40 ) then playSoundFrontEnd(2) triggerServerEvent("DNL:Guardar_Veh", root, localPlayer, ID) elseif isCursorOnElement ( x*602, y*593, x*162, y*40 ) then playSoundFrontEnd(2) triggerServerEvent("DNL:Spawnar_Veh", root, localPlayer, ID) end end end end end addEventHandler ( "onClientClick", root, Clicks_Garagem ) --=============================-- ------------- IGNORA ------------ --=============================-- AllKeys = { "arrow_l", "arrow_u", "arrow_r", "arrow_d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_mul", "num_add", "num_sep", "num_sub", "num_div", "num_dec", "num_enter", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "escape", "backspace", "tab", "lalt", "ralt", "enter", "space", "pgup", "pgdn", "end", "home", "insert", "delete", "lshift", "rshift", "lctrl", "rctrl", "[", "]", "pause", "capslock", "scroll", ";", ",", "-", ".", "/", "#", "\\", "=" } addEventHandler("onClientKey", root, function(button, press) for index, keys in pairs(AllKeys) do if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Garagem) then if button == keys then cancelEvent() end end end end ) function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) dxDrawText ( text, x - 1, y, w - 1, h, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 1, y, w + 1, h, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - 1, w, h - 1, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + 1, w, h + 1, color, scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end function contornoRetangulo(absX, absY, sizeX, sizeY, color, ancho) dxDrawRectangle(absX, absY, sizeX, ancho, color) dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color) dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color) dxDrawRectangle(absX + sizeX - ancho, absY + ancho, ancho, sizeY - ancho*2, color) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end local x,y = guiGetScreenSize() function isCursorOnElement(x, y, w, h) if (not isCursorShowing()) then return false end local mx, my = getCursorPosition() local fullx, fully = guiGetScreenSize() cursorx, cursory = mx*fullx, my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end Edited June 12, 2020 by Sucrilhex
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now