beast99 Posted July 25, 2019 Share Posted July 25, 2019 Boa Tarde, estava fazendo uma script para meu servidor, e tentei fazer o seguinte. Queria que aparecesse o painel no marker, mas ele não aparece, conseguir colocar bindKey no F2 mas pelo marker não consigo, alguem pode ajudar? Client: local monitorSize = {guiGetScreenSize()} local panelSize = {330, 550} local panelX, panelY = monitorSize[1]/2-panelSize[1]/2, monitorSize[2]/2-panelSize[2]/2 local buttonSize = {320, 25} local render = false local font = dxCreateFont("font.ttf", 14) function togPanel(button, press) if button=="F2" and press and not render then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) elseif button=="F2" and press and render then removeEventHandler("onClientRender", root, renderPanel) render = false showCursor(false) end end addEventHandler("onClientKey", root, togPanel) function renderPanel() dxDrawText("Shop #1c86eeArmas", panelX+panelSize[1]/2, panelY+10, panelX+panelSize[1]/2, panelY+10, tocolor(255, 255, 255, 255), 0.7, font, "center", "center", false, false, true, true) dxDrawRectangle(panelX, panelY, panelSize[1], panelSize[2]+50, tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX, panelY, panelSize[1], 20, tocolor(0, 0, 0, 150)) for i, v in ipairs(guns) do if isInBox(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2]) then dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(28, 134, 238, 200)) else dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(0, 0, 0, 100)) end dxDrawText(v[1], panelX+15, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) dxDrawText("Comprar", panelX+235, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) end end function panelClick( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if button == "left" and state == "down" and render then for i, v in ipairs(guns) do if dobozbaVan(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], absoluteX, absoluteY) then triggerServerEvent("buyWeapon", localPlayer, localPlayer, v[1], v[2], v[3], v[4]) end end end end addEventHandler ("onClientClick", getRootElement(), panelClick ) function dobozbaVan(dX, dY, dSZ, dM, eX, eY) if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then return true else return false end end function isInBox(xS,yS,wS,hS) if(isCursorShowing()) then XY = {guiGetScreenSize()} local cursorX, cursorY = getCursorPosition() cursorX, cursorY = cursorX*XY[1], cursorY*XY[2] if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then return true else return false end end end Server: addEvent("buyWeapon", true) addEventHandler("buyWeapon", root, function(thePlayer, name, gunid, price, ammo) if getPlayerMoney(thePlayer)>=price then giveWeapon(thePlayer, gunid, ammo, true) outputChatBox("#1c86ee[SERVER] #FFFFFF Você comprou com sucesso #1c86eeR$ #FFFFFF" .. price, thePlayer, 255, 255, 255, true) else outputChatBox("#1c86ee[SERVER] #FFFFFF Você não tem dinheiro suficiente", thePlayer, 255, 255, 255, true) end end) Shared: guns = { --Name, id, price, ammo {"Colt 45", 22, 2000, 17}, {"Silenced", 23, 3000, 17}, {"Deagle", 24, 4000, 7}, {"Shotgun", 25, 6000, 10}, {"Sawed-off", 26, 6500, 20}, {"Combat shotgun", 27, 8000, 7}, {"Uzi", 28, 10000, 50}, {"Tec9", 32, 12000, 30}, {"MP5", 29, 20000, 50}, {"AK47", 30, 25000, 30}, {"M4", 30, 25000, 50}, {"Rifle", 33, 30000, 10}, {"Sniper", 34, 35000, 10}, } Observação: O marker deve se localizar na seguinte localização: 2796.0712890625,-2373.5051269531,13.631641387939. Obrigado a Todos que poderem ajudar. Link to comment
Other Languages Moderators Lord Henry Posted July 25, 2019 Other Languages Moderators Share Posted July 25, 2019 (edited) 56 minutes ago, mesadown said: Observação: O marker deve se localizar na seguinte localização: 2796.0712890625,-2373.5051269531,13.631641387939. Não precisa ser coordenada exata. Use no máximo 3 decimais. Mais que isso é irrelevante. Tente isso: theMarker = createMarker (2796.071, -2373.505, 13.631, "cylinder", 1) function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) end end addEventHandler ("onClientMarkerHit", theMarker, markerPanel) Edited July 25, 2019 by Lord Henry Link to comment
beast99 Posted July 25, 2019 Author Share Posted July 25, 2019 58 minutes ago, Lord Henry said: Não precisa ser coordenada exata. Use no máximo 3 decimais. Mais que isso é irrelevante. Tente isso: theMarker = createMarker (2796.071, -2373.505, 13.631, "cylinder", 1) function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) end end addEventHandler ("onClientMarkerHit", theMarker, markerPanel) Lord, agora estou com um problema, coloquei no .client e agora nem no bindKey e nem no marker aparece nada, poderia ajudar? Link to comment
DNL291 Posted July 25, 2019 Share Posted July 25, 2019 /debugscript 3 Mostre como está seu código. Link to comment
beast99 Posted July 25, 2019 Author Share Posted July 25, 2019 https://imgur.com/a/bCR5cKC Print do erro com o debug script, código está assim: local monitorSize = {guiGetScreenSize()} local panelSize = {330, 550} local panelX, panelY = monitorSize[1]/2-panelSize[1]/2, monitorSize[2]/2-panelSize[2]/2 local buttonSize = {320, 25} local render = false local font = dxCreateFont("font.ttf", 14) theMarker = createMarker (2796.071, -2373.505, 13.631, "cylinder", 1) function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) end end addEventHandler ("onClientMarkerHit", theMarker, markerPanel) function togPanel(button, press) if button=="F2" and press and not render then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) elseif button=="F2" and press and render then removeEventHandler("onClientRender", root, renderPanel) render = false showCursor(false) end end addEventHandler("onClientKey", root, togPanel) function renderPanel() dxDrawText("Shop #1c86eeArmas", panelX+panelSize[1]/2, panelY+10, panelX+panelSize[1]/2, panelY+10, tocolor(255, 255, 255, 255), 0.7, font, "center", "center", false, false, true, true) dxDrawRectangle(panelX, panelY, panelSize[1], panelSize[2]+50, tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX, panelY, panelSize[1], 20, tocolor(0, 0, 0, 150)) for i, v in ipairs(guns) do if isInBox(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2]) then dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(28, 134, 238, 200)) else dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(0, 0, 0, 100)) end dxDrawText(v[1], panelX+15, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) dxDrawText("Comprar", panelX+235, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) end end function panelClick( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if button == "left" and state == "down" and render then for i, v in ipairs(guns) do if dobozbaVan(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], absoluteX, absoluteY) then triggerServerEvent("buyWeapon", localPlayer, localPlayer, v[1], v[2], v[3], v[4]) end end end end addEventHandler ("onClientClick", getRootElement(), panelClick ) function dobozbaVan(dX, dY, dSZ, dM, eX, eY) if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then return true else return false end end function isInBox(xS,yS,wS,hS) if(isCursorShowing()) then XY = {guiGetScreenSize()} local cursorX, cursorY = getCursorPosition() cursorX, cursorY = cursorX*XY[1], cursorY*XY[2] if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then return true else return false end end end Link to comment
Other Languages Moderators Lord Henry Posted July 25, 2019 Other Languages Moderators Share Posted July 25, 2019 Delete e reescreva a linha 8 em vez de copiar do fórum. Vc copiou um símbolo invisível. Link to comment
beast99 Posted July 27, 2019 Author Share Posted July 27, 2019 On 25/07/2019 at 22:23, Lord Henry said: Delete e reescreva a linha 8 em vez de copiar do fórum. Vc copiou um símbolo invisível. Bom dia Lord, fiz isso, apareceu o marker mas o painel não, segue o código: local monitorSize = {guiGetScreenSize()} local panelSize = {330, 550} local panelX, panelY = monitorSize[1]/2-panelSize[1]/2, monitorSize[2]/2-panelSize[2]/2 local buttonSize = {320, 25} local render = false local font = dxCreateFont("font.ttf", 14) theMarker = createMarker(2796.071, -2373.505, 13.631, "cylinder", 1) function markerPanel(hitPlayer, matchingdimension) if (hitplayer == localPlayer) then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) end end function togPanel(button, press) if button=="F2" and press and not render then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) elseif button=="F2" and press and render then removeEventHandler("onClientRender", root, renderPanel) render = false showCursor(false) end end addEventHandler("onClientKey", root, togPanel) function renderPanel() dxDrawText("Shop #1c86eeArmas", panelX+panelSize[1]/2, panelY+10, panelX+panelSize[1]/2, panelY+10, tocolor(255, 255, 255, 255), 0.7, font, "center", "center", false, false, true, true) dxDrawRectangle(panelX, panelY, panelSize[1], panelSize[2]+50, tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX, panelY, panelSize[1], 20, tocolor(0, 0, 0, 150)) for i, v in ipairs(guns) do if isInBox(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2]) then dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(28, 134, 238, 200)) else dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(0, 0, 0, 100)) end dxDrawText(v[1], panelX+15, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) dxDrawText("Comprar", panelX+235, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) end end function panelClick( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if button == "left" and state == "down" and render then for i, v in ipairs(guns) do if dobozbaVan(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], absoluteX, absoluteY) then triggerServerEvent("buyWeapon", localPlayer, localPlayer, v[1], v[2], v[3], v[4]) end end end end addEventHandler ("onClientClick", getRootElement(), panelClick ) function dobozbaVan(dX, dY, dSZ, dM, eX, eY) if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then return true else return false end end function isInBox(xS,yS,wS,hS) if(isCursorShowing()) then XY = {guiGetScreenSize()} local cursorX, cursorY = getCursorPosition() cursorX, cursorY = cursorX*XY[1], cursorY*XY[2] if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then return true else return false end end end Debug script não dá nenhum erro, o que pode ser? Link to comment
Other Languages Moderators Lord Henry Posted July 27, 2019 Other Languages Moderators Share Posted July 27, 2019 Está faltando o evento onClientMarkerHit. Além disso, na sua linha 11, vc escreveu hitPlayer errado. Link to comment
beast99 Posted July 27, 2019 Author Share Posted July 27, 2019 2 hours ago, Lord Henry said: Está faltando o evento onClientMarkerHit. Além disso, na sua linha 11, vc escreveu hitPlayer errado. Lord, quero colocar o painel e o marker para apenas 1 acl conseguir observar, teria como me ajudar? Link to comment
DNL291 Posted July 27, 2019 Share Posted July 27, 2019 Faça no lado server: createMarker, onMarkerHit, isPlayerInACL (função útil), triggerClientEvent. No client faça um evento para a função markerPanel para ser chamado pelo lado server. Link to comment
beast99 Posted July 27, 2019 Author Share Posted July 27, 2019 2 hours ago, DNL291 said: Faça no lado server: createMarker, onMarkerHit, isPlayerInACL (função útil), triggerClientEvent. No client faça um evento para a função markerPanel para ser chamado pelo lado server. Lord, consegui , mas quero fazer um "X" para fechar o painel, segue o código: local monitorSize = {guiGetScreenSize()} local panelSize = {330, 550} local panelX, panelY = monitorSize[1]/2-panelSize[1]/2, monitorSize[2]/2-panelSize[2]/2 local buttonSize = {320, 25} local render = false local font = dxCreateFont("font.ttf", 14) theMarker = createMarker(2796.071, -2373.505, 13.631, "cylinder", 1) function markerPanel(hitPlayer, matchingdimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, renderPanel) render = true showCursor(true) end end addEventHandler ("onClientMarkerHit", theMarker, markerPanel) function renderPanel() dxDrawText("Shop #1c86eeArmas", panelX+panelSize[1]/2, panelY+10, panelX+panelSize[1]/2, panelY+10, tocolor(255, 255, 255, 255), 0.7, font, "center", "center", false, false, true, true) dxDrawRectangle(panelX, panelY, panelSize[1], panelSize[2]+50, tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX, panelY, panelSize[1], 20, tocolor(0, 0, 0, 150)) for i, v in ipairs(guns) do if isInBox(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2]) then dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(28, 134, 238, 200)) else dxDrawRectangle(panelX+5, panelY+30+((i-1)*30), buttonSize[1], buttonSize[2], tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], tocolor(0, 0, 0, 100)) end dxDrawText(v[1], panelX+15, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) dxDrawText("Comprar", panelX+235, panelY-60+((i-1)*30), panelX+35+buttonSize[1]/2,panelY+130+((i-1)*30)+15, tocolor(255, 255, 255, 255), 0.9, font, "left", "center", false, false, true, true) end end function panelClick( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if button == "left" and state == "down" and render then for i, v in ipairs(guns) do if dobozbaVan(panelX+210, panelY+30+((i-1)*30), buttonSize[1]/2.8, buttonSize[2], absoluteX, absoluteY) then triggerServerEvent("buyWeapon", localPlayer, localPlayer, v[1], v[2], v[3], v[4]) end end end end addEventHandler ("onClientClick", getRootElement(), panelClick ) function dobozbaVan(dX, dY, dSZ, dM, eX, eY) if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then return true else return false end end function isInBox(xS,yS,wS,hS) if(isCursorShowing()) then XY = {guiGetScreenSize()} local cursorX, cursorY = getCursorPosition() cursorX, cursorY = cursorX*XY[1], cursorY*XY[2] if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then return true else return false end end end Link to comment
Other Languages Moderators Lord Henry Posted July 28, 2019 Other Languages Moderators Share Posted July 28, 2019 Você sabe criar botões DX, certo? Então qual a dificuldade de criar um botão pequeno com um X? Dai quando clicar nesse botão, vc cancela a renderização do painel com: removeEventHandler ("onClientRender", root, renderPanel) Link to comment
beast99 Posted July 29, 2019 Author Share Posted July 29, 2019 23 hours ago, Lord Henry said: Você sabe criar botões DX, certo? Então qual a dificuldade de criar um botão pequeno com um X? Dai quando clicar nesse botão, vc cancela a renderização do painel com: removeEventHandler ("onClientRender", root, renderPanel) Como eu posso saber as coordenadas no ecrã? Pois no isCursorOnElement preciso saber as coordenadas, tem alguma forma? Link to comment
Other Languages Moderators Lord Henry Posted July 29, 2019 Other Languages Moderators Share Posted July 29, 2019 Só pegar as coordenadas que vc usou pra criar o botão. No caso os parâmetros do DxDrawRectangle. Link to comment
Other Languages Moderators Lord Henry Posted July 29, 2019 Other Languages Moderators Share Posted July 29, 2019 Não se esqueça de deixar um Thanks nas respostas que lhe ajudaram. 1 Link to comment
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