Jump to content

Vazern

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by Vazern

  1. Sim, mas em um servidor com média de 100 players, que por exemplo a cada 2/3 minutos um jogador saísse, ou efetue login, acabaria consumindo? Usando um servidor MySQL tornaria o processo mais leve, ou daria no mesmo?
  2. Olá! Alguém pode me informar, se um arquivo .db fosse consultado de alguns em alguns segundos, em um servidor com mais de 100 jogadores, e que toda vez que ele logasse, fosse consultado o SQLite para carregar os dados, consumiria muito do cliente/servidor?
  3. Desculpem pelo erro, meu PC está horrível. Então, acho que se ele utilizasse um loop, com getElementsByType("vehicle") e uma verificação de controller, ele consegue fazer isto. setTimer(function() for index, vehicle in ipairs(getElementsByType("vehicle") do if not vehicle:getController() then vehicle:destroy() end end end, 4000, 0) Não sei se isto faz lógica, só testando. Acho que a forma que ajuda, vai de cada um, ele passou o código, mas também explicou, sendo assim, cabe ao criador do tópico, e a quem está vendo aquilo, absorver ou não o conhecimento. No entanto, o que você está fazendo é pior ainda, criticar um usuário, que de uma forma, ou de outra, o ajudou.
  4. Eu fiz isto, mas não sabia disso, por que não pode ser utilizado?
  5. Muito obrigado a todos! Entendi perfeitamente, e aprendi @brunob22, agradeço, mas não faz muito sentido essa explicação, o que o @Lord Henry fez por exemplo, é explicar, dando exemplos, e com isso compreendi. Mas se puderem me tirar uma dúvida, eu usei este loop com while, para caso a data esteja negativa, ele definir como 0, mas não da nada, o que fiz de errado? (Os loops não estão dentro de uma function. for index, p in ipairs(getElementsByType("player")) do while getElementData(p, "fome") < 0 do setElementData(p, "fome", 0) end end
  6. Olá! Tudo bom com vocês? Eu ainda sou amador, e utilizo alguns loops prontos, mas nunca montei um, na verdade, nem sequer sei como ele funciona. Alguém poderia me explicar como eu poderia utilizá-lo para obter a lista de jogadores, ou como utilizá-lo em uma tabela, ou seja, como utilizá-lo de maneira geral. Obrigado!
  7. Olá! Sei que já faz um tempo bom desde que postou o tópico, mas só gostaria de agradecer, comecei a aprender DB ontem, e graça a esse tutorial, e a outro gringo, me ajudou bastante, já consigo criar de tudo utilizando Database agora.
  8. Yesterday evening, I started my apprenticeship with db, I always wanted to learn, because with it, I can do mods, which I could not do without. My introduction with Database was done by adapting a System ID to the DB in the login panel. I did this using the server-side of my login panel. The first thing we do, is to use dbConnect (Wiki), which will make the connection to the db file. local db = dbConnect("sqlite", "db/royalusers.db") It will create the "db" folder, in the resource files, and inside the folder, the "royalusers.db" file. After that, we create a table using the SQL functions. local newTable = dbExec(db, "CREATE TABLE IF NOT EXISTS RoyalUsers (id INT, name TEXT, login TEXT, pass TEXT, serial TEXT)") RoyalUsers - Table-name id INT, name TEXT, login TEXT, pass TEXT, serial TEXT - columns of the table. INT - INTERNAL NUMBER Now the part of using the table defined in the database. function registerPlayer(user, pass, conf) if user == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if pass == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if conf == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if conf == pass then addAccount(tostring(user),tostring(pass)) triggerClientEvent(source, "onRoyalRegister", source) local query = dbPoll(dbQuery(db, "SELECT * FROM RoyalUsers WHERE login=?", user),-1) if #query == 0 then dbExec(db, "INSERT INTO RoyalUsers VALUES (?, ?, ?, ?, ?)", countIDs(), getPlayerName(source), user, pass, getPlayerSerial(source)) end outputLoginMsg(source, "Conta criada com sucesso! Aguarde...", "success") if not getAccount(user, pass) then outputLoginMsg(source, "Esta conta já está sendo utilizada!", "error") end else outputLoginMsg(source, "As senhas não estão iguais.", "error") end end end end end addEvent("onPlayerRequestRegister", true) addEventHandler("onPlayerRequestRegister", root, registerPlayer) function countIDs() local table = dbPoll(dbQuery(db, "SELECT * FROM RoyalUsers"), -1) local count = 1 for i, result in pairs(table) do count = count + 1 end return count end The login variable returns a table, it selects (SELECT) all the columns of the table, and checks if the login defined in the function does not exist in it, if it does not exist, it will add those information, the columns of the table RoyalUsers (INSERT INTO). VALUES (?, ?, ?, ?, ?) - "?" It is the amount of arguments that will be used to insert into the column. countIDs() - Function that returns the number of IDs in the table, and adds one more. getPlayerName(source) - Gets the player's name, and adds the "name" column of the table. user - Adds the user defined in the function, the column "login". pass - Adds the password set in the function, the "pass" column. getPlayerSerial(source) - Gets the player's serial, and adds the "serial" column of the table. Having the part in which the data that the player registers, are saved in the database, this part is ready. Now, just set the ID added to the database login, when the player logs in. function loginPlayer(source, user, pass) if user == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if pass == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else local account = getAccount(user, pass) if account then logIn(source, account, pass) local queryTable = dbPoll(dbQuery(db, "SELECT * FROM RoyalUsers WHERE login='"..getAccountName(getPlayerAccount(source)).."'"), -1) for i, id in pairs(queryTable) do setElementData(source, "ID", id["id"]) end setTimer(setCameraTarget, 3000, 1, source, source) setTimer(triggerClientEvent, 14000, 1, source, "renderRoyalID", source) triggerClientEvent(source, "onRoyalLogin", source) outputLoginMsg(source, "Logado com sucesso! Aguarde...", "success") else outputLoginMsg(source, "Usuário ou senha incorretos!", "error") end end end end addEvent("onPlayerRequestLogin", true) The queryTable gets all the columns of the table, where the login = login of the player. After that, we loop the tables returned by the queryTable, and set the date "ID" to the player, according to the ID returned from the table defined in the loop. I want to make it clear that the tutorial did not go well explained, I just want to share, what I learned yesterday, and if I did something wrong, please let me know.
  9. » Feature in which allows the player to make purchases in the Extra Supermarket on my server. The player enters, goes to a pratileira, or freezer of the Coke, picks the selected item according to the instructions left in the menu, and after this, goes to the box, which informs the item name, quantity, value and the button to buy. * Contains textures. Download: No Click to watch the video Mods for MTA
  10. Boa noite, bom dia, boa tarde! Pessoal, lembrei que há uma função, que meio que mostra a área que o col tá preenchendo, mas faz anos que não a uso, não consegui encontrá-la. Poderiam quebrar esse galho?
  11. Amigo, respeito sua opinião, mas acredito que seja muito ignorante de sua parte dizer isto. O programador deve usar as funções de acordo com a sua criatividade, elementos Dx básicos de criação de interfaces, são bem optimizados, pelo menos comigo, nunca houve problema algum em relação a queda de FPS. O GUI nativo do MTA, já é muito ultrapassado, os programadores adaptarem Dx para fazer painéis com todos os tipos de elementos, só prova o poder da criatividade. Eu por exemplo, utilizo todos os elementos GUI, em Dx. https://imgur.com/a/uddULt4 https://imgur.com/a/Oa8WEyK
  12. Good night, good morning, or good afternoon! I am a beginner on the moon, I would like to know how to use string.find, or some other method, to start a mod that has a particular tag. In my case, I put the tag "[VZR]" in my mods. Thank you.
  13. Hello! I need to use attachElements with an object in a player's gun, but from what I noticed the player's weapon is not recognized as "element". Code: function customM4(source) if getPedWeapon(source) == 31 then local gunModel = createObject(1487, 1, 2, 3) attachElements(gunModel, getPedWeapon(source)) end end addCommandHandler("m4skin", customM4)
  14. I already got the textures. Thank you! If anyone needs, just contact me via facebook: https://www.facebook.com/filipe.santos234
  15. Well, I basically need an "invisible" (TXD and DFF) model, to replace the weapons model. (Sorry if it's complicated to understand, I use Google Translate)
  16. Hello community! I'm developing a "different textures in the same gun" project, but I need to replace the original model with a transparent DFF and TXD, but I do not have it. Could any of you pass me the transparent DFF and TXD so I can replace it with the weapons model?
  17. Se ler o resto, isso aí oculta os componentes na tela (como a hud), mas eu o desativei pois com ele o Blur que uso não funciona.
  18. Não funcionou (fiz algo errado no caso). Eu não sei dizer se fui eu que utilizei de má forma o código que me mandou, mas não funcionou aqui, e o debug não da nenhum erro. Prints: Código (client-side): local sX, sY = guiGetScreenSize () -- Qualquer coisa que envolva paineis, usa-se isso para receber a resolução atual do usuário. objectID = 356 -- Start vehicle. function createObjectViewer() local x1, y1, z1 = getCameraMatrix() myElement = createObject(objectID, x1, y1, z1 + 10) contador = 0 -- O veículo começa com rotação Z sendo 0. thePreview = exports.object_preview:createObjectPreview (myElement, 0, 0, contador, 0.3, (0.2 - 0.1), 0.4, 0.6, true, true, false) -- Cria o veículo na tela. exports.object_preview:setPositionOffsets (thePreview, 0, 4, -2) -- Configura posição do veículo em relação a câmera. rotator = setTimer (function () -- Timer que faz o objeto rotacionar na tela. Ao fechar o painel, este timer é destruído. exports.object_preview:setRotation (thePreview, 0, 0, contador) contador = contador + 1 if contador >= 360 then -- Contador é a rotação Z atual do objeto. contador = 0 end end, 50, 0) -- Rotaciona o objeto 1 grau sentido anti-horário a cada 50 milisegundos. (quase um onClientRender) end local l_0_1 = false local l_0_2, l_0_3 = guiGetScreenSize() local l_0_4 = dxCreateScreenSource(l_0_2, l_0_3) addEventHandler("onClientRender", root, function() if l_0_1 then dxUpdateScreenSource(l_0_4) dxDrawImage(0, 0, l_0_2, l_0_3, l_0_4) end end ) local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 10) local screenW, screenH = guiGetScreenSize() local resW, resH = 1360,768 local x, y = (screenW/resW), (screenH/resH) 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 function menu() color = tocolor(0, 0, 0, 185) if isCursorOnElement(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495) then -- M4 color = tocolor(16, 102, 231, 100) end color2 = tocolor(0, 0, 0, 185) if isCursorOnElement(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495) then -- Desert color2 = tocolor(16, 102, 231, 100) end color3 = tocolor(0, 0, 0, 185) if isCursorOnElement(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495) then -- Cacetete color3 = tocolor(16, 102, 231, 100) end color4 = tocolor(0, 0, 0, 185) if isCursorOnElement(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495) then -- Vida e colete color4 = tocolor(16, 102, 231, 100) end color5 = tocolor(0, 0, 0, 185) if isCursorOnElement(screenW * 0.3294, screenH * 0.5292, screenW * 0.3360, screenH * 0.0495) then -- Uniforme color5 = tocolor(16, 102, 231, 100) end colorF = tocolor(0, 0, 0, 0) if isCursorOnElement(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469) then colorF = tocolor(255, 0, 0, 150) end dxDrawRectangle(screenW * 0.3221, screenH * 0.2656, screenW * 0.3551, screenH * 0.3390, tocolor(0, 0, 0, 185), false) dxDrawRectangle(screenW * 0.3221, screenH * 0.2656, screenW * 0.3551, screenH * 0.0469, tocolor(0, 0, 0, 185), false) dxDrawText("Menu de itens - #1066E7PMESP", screenW * 0.3294, screenH * 0.2786, screenW * 0.4971, screenH * 0.3242, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawRectangle(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469, colorF, false) dxDrawText("X", screenW * 0.6618, screenH * 0.2786, screenW * 0.8294, screenH * 0.3242, tocolor(255, 255, 255, 200), x*1.30, "default-bold", "left", "top", false, false, false, true, false) dxDrawRectangle(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495, color, false) dxDrawText("(#1066E7Arma#FFFFFF) M4", screenW * 0.3368, screenH * 0.3438, screenW * 0.5044, screenH * 0.3893, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawRectangle(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495, color2, false) dxDrawText("(#1066E7Arma#FFFFFF) Desert Eagle", screenW * 0.3368, screenH * 0.3932, screenW * 0.5044, screenH * 0.4388, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawRectangle(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495, color3, false) dxDrawText("(#1066E7Arma#FFFFFF) Cacetete", screenW * 0.3368, screenH * 0.4427, screenW * 0.5044, screenH * 0.4883, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawRectangle(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495, color4, false) dxDrawText("(#1066E7Itens#FFFFFF) Vida e Colete", screenW * 0.3368, screenH * 0.4922, screenW * 0.5044, screenH * 0.5378, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawRectangle(screenW * 0.3294, screenH * 0.5292, screenW * 0.3360, screenH * 0.0495, color5, false) dxDrawText("(#1066E7Itens#FFFFFF) Uniforme", screenW * 0.3368, screenH * 0.5417, screenW * 0.5044, screenH * 0.5378, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) end function disableBlur() setElementData(localPlayer, "showBlur", false) end addEventHandler("onClientResourceStop", resourceRoot, disableBlur) function render() if not isTimer (rotator) then if not isEventHandlerAdded("onClientRender", root, menu) then addEventHandler("onClientRender", root, menu) showCursor(true) showChat(false) createObjectViewer() -- l_0_1 = true setElementData(localPlayer, "showBlur", true) end end end addEvent("openMenuPM", true) addEventHandler("openMenuPM", root, render) function close(_,state) if isEventHandlerAdded("onClientRender", root, menu) then if state == "down" then if isCursorOnElement(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469) then showCursor(false) showChat(true) playSound("sfx/hit.mp3", false) removeEventHandler("onClientRender", root, menu) setElementData(localPlayer, "showBlur", false) killTimer (rotator) exports.object_preview:destroyObjectPreview (thePreview) destroyElement (myElement) myElement = nil if l_0_1 then l_0_1 = false end end end end end addEventHandler("onClientClick", root, close) function m4(_,state) if isEventHandlerAdded("onClientRender", root, menu) then if state == "down" then if isCursorOnElement(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495) then triggerServerEvent("m4", localPlayer) removeEventHandler("onClientRender", root, menu) setElementData(localPlayer, "showBlur", false) killTimer (rotator) exports.object_preview:destroyObjectPreview (thePreview) destroyElement (myElement) myElement = nil showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) if l_0_1 then l_0_1 = false end end end end end addEventHandler("onClientClick", root, m4) function deagle(_,state) if isEventHandlerAdded("onClientRender", root, menu) then if state == "down" then if isCursorOnElement(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495) then triggerServerEvent("deagle", localPlayer) removeEventHandler("onClientRender", root, menu) setElementData(localPlayer, "showBlur", false) killTimer (rotator) exports.object_preview:destroyObjectPreview (thePreview) destroyElement (myElement) myElement = nil showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) if l_0_1 then l_0_1 = false end end end end end addEventHandler("onClientClick", root, deagle) function cacetete(_,state) if isEventHandlerAdded("onClientRender", root, menu) then if state == "down" then if isCursorOnElement(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495) then triggerServerEvent("cacetete", localPlayer) removeEventHandler("onClientRender", root, menu) setElementData(localPlayer, "showBlur", false) killTimer (rotator) exports.object_preview:destroyObjectPreview (thePreview) destroyElement (myElement) myElement = nil showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) if l_0_1 then l_0_1 = false end end end end end addEventHandler("onClientClick", root, cacetete) function vidaC(_,state) if isEventHandlerAdded("onClientRender", root, menu) then if state == "down" then if isCursorOnElement(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495) then triggerServerEvent("vidaC", localPlayer) removeEventHandler("onClientRender", root, menu) setElementData(localPlayer, "showBlur", false) killTimer (rotator) exports.object_preview:destroyObjectPreview (thePreview) destroyElement (myElement) myElement = nil showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) if l_0_1 then l_0_1 = false end end end end end addEventHandler("onClientClick", root, vidaC) function setUniforme(_,state) if isEventHandlerAdded("onClientRender", root, menu) then if state == "down" then if isCursorOnElement(screenW * 0.3294, screenH * 0.5292, screenW * 0.3360, screenH * 0.0495) then setElementModel(localPlayer, 280) removeEventHandler("onClientRender", root, menu) setElementData(localPlayer, "showBlur", false) killTimer (rotator) exports.object_preview:destroyObjectPreview (thePreview) destroyElement (myElement) myElement = nil showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) if l_0_1 then l_0_1 = false end end end end end addEventHandler("onClientClick", root, setUniforme) function isCursorOnElement( posX, posY, width, height ) if isCursorShowing( ) then local mouseX, mouseY = getCursorPosition( ) local clientW, clientH = guiGetScreenSize( ) local mouseX, mouseY = mouseX * clientW, mouseY * clientH if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then return true end end return false end
  19. Obrigado @DNL291 e Lord Henry pela ajuda! <3
×
×
  • Create New...