Jump to content

Enargy,

Members
  • Posts

    1,102
  • Joined

Everything posted by Enargy,

  1. if (string.len(regUsernameBox:getText()) >= 3) then confirmMailPanel:setVisible(true) registerPanel:setVisible(false) else outputChatBox ("Your username most be longer then...") end
  2. Eso es en el caso de que si la variable 'sp' fuese global ahí si habria conflicto con los timers. En este caso como la variable está dentro de un bloque se asigna solo a esa parte de la memoria. Por otro lado concuerdo contigo en usar getDistanceBetweenPoints3D
  3. Aprendes mejor editando scripts de otras personas siempre y cuando no digas que no son totalmente tuyos, así vas aprendiendo la estructura del código que construye el programador. Ya cuando te familiarices dicha estructura la puedes mezclar con otro tipo de scripts y sin darte cuenta ya tienes algo armado. En mi caso yo aprendí así xd. La teoría es útil pero no suficiente y no aprendes muy bien que digamos. Aprendes que si la estructura de programación, sentencias, tipos de datos, ciclos, recursividad, etc. Toma el ejemplo de las Matemáticas, tu no aprendes hacer derivadas leyendo libros sino haciendo cientos de ejercicios tomando en cuenta la teoría. Con la programación es igual, hay miles de ejercicios de programación que puedes hacer. Comienza desde lo más fácil hasta lo mas difícil.
  4. function sendData(userLogin, userPassword) outputServerLog("Data sent") local userLogin = userLogin:gsub("%\n", "") local userPassword = userPassword:gsub("%\n", "") outputServerLog(userLogin) local qh = exports.sql:_Query('SELECT * FROM users WHERE playerAccount=? and playerPass=?', userLogin, userPassword) local results = qh and exports.sql:_QueryResult(qh) if type(results) == "table" and #results > 0 then outputServerLog(results[1]["playerAccount"]) outputServerLog(results[1]["playerPass"]) end end
  5. You can use the split function to separate a string into several sub-strings. local sep = "_" -- This character will be your separator local var1 = split("Bobby_Bob", sep) print(var1[1]) -- Result: Bobby print(var1[2]) -- Result: Bob
  6. Para crear el grupo del acl tienes que irte a la carpeta deathmatch de tu MTA y abrir el archivo acl.xml, agregas un nuevo grupo y luego las cuentas que podrán utilizar el comando. Ej: <object name="user.Enargy"></object> addCommandHandler("canspray", function(player) local aclGroup = aclGetGroup("NombreGrupo") local account = getPlayerAccount(player) if account then local accName = getAccountName(account) if isObjectInACLGroup("user." .. accName, aclGroup) then -- -- -- Funcion que abre el panel. end end end
  7. Me tomé la libertad de organizar mejor tu código, no está probado pero el código se ve "bien". local elements = { } local function loadText(id, text, x, y, z, interior, dimension, saveInDB) if id and elements[id] then return false end if type(x) ~= "number" or type(y) ~= "number" or type(z) ~= "number" then return false end if saveInDB then if not handler then return false end dbExec(handler, "INSERT INTO `3dtext`(`textID`, `text`, `x`, `y`, `z`, `interior`, `dimension`) VALUES (?,?,?,?,?,?,?)", id, text, x, y, z, interior, dimension) end interior = interior or 0 dimension = dimension or 0 elements[id] = createElement("3dtext") setElementPosition(elements[id], x, y, z) setElementInterior(elements[id], interior) setElementDimension(elements[id], dimension) setElementData(elements[id], "text", tostring(text)) return elements[id] end addEventHandler("onResourceStart", resourceRoot, function() local qh = dbQuery(handler, "SELECT * FROM 3dtext ORDER BY textID ASC") local result = qh and dbPoll(qh, -1) if result then for key, data in ipairs(result) do loadText(data.textID, data.text, data.x, data.y, data.z, data.interior, data.dimension, false) end end end ) local function createxto(player, cmd, textID, ...) if textID then if ((getElementData(player, "NivelAdmin", 5) or 0) == 5) then if textID and elements[textID] then outputChatBox( "Esta ID ya existe!", player, 255, 0, 0 ) return end local text = table.concat({ ... }, " ") local x, y, z = getElementPosition(player) loadText(textID, text, x, y, z, getElementInterior(player), getElementDimension(player), true) outputChatBox("Texto creado. (ID " .. textID .. ")", player, 0, 255, 0) else outputChatBox("No tienes permiso para usar este comando!", player, 255, 255, 255) end else outputChatBox("Comando: /" .. cmd .. " [ID] [texto]", player, 255, 255, 255) end end addCommandHandler("creartextoentorno", createxto)
  8. https://community.multitheftauto.com/index.php?p=resources&s=details&id=10673
  9. I think you are looking for something like this.
  10. O mapeas en una dimension normal y editas el archivo .map cambiando los valores del atributo dimension al numero que te parezca, o editas el archivo WORKING_DIMENSION del mapeditor.
  11. I did not see that lol. Anyways you're welcome.
  12. That's weird... the code is right. Are you typing the command after you get logged in?
  13. function SetearDatas() local KD = getElementData(source, "KD") or 0 if (KD < 1) then setElementData(source, "ranking", "Bronze") --Bronce elseif (KD >= 1 and KD < 2.5) then setElementData(source, "ranking", "Silver") --Plata elseif (KD >= 2.5 and KD < 4) then setElementData(source, "ranking", "Gold") --Oro elseif (KD >= 4 and KD < 7) then setElementData(source, "ranking", "Platinum") --Platino elseif (KD >= 7 and KD < 10) then setElementData(source, "ranking", "Diamond") --Diamante elseif (KD >= 10) then setElementData(source, "ranking", "Master") --Challenger end end addEventHandler ("onPlayerLogin", getRootElement(), SetearDatas) function statsss () outputChatBox("Your rank is: ".. (getElementData (source, "ranking") or "None"), source,0,255,0) end addCommandHandler ( "statinfo", statsss )
  14. Enargy,

    Dx Rotation

    Cuando iteras un elemento dx es importante el orden en que está establecido en tu código. Por ejemplo: -- La ultima funcion en iterarse va ser la que va a superponerse a la otra. addEventHandler("onClientRender", root, function() dxDrawImage(0, 0, 50, 50, "imagen.png", 0, 0, 0, tocolor(255, 0, 0, 255), false) dxDrawImage(0, 0, 50, 50, "imagen.png", 0, 0, 0, tocolor(0, 255, 0, 255), false) end ) En el caso de usar el argumento POSTGUI: -- La primera funcion en iterarse va ser la que va a superponerse a todas las demás que las siguen. addEventHandler("onClientRender", root, function() dxDrawImage(0, 0, 50, 50, "imagen.png", 0, 0, 0, tocolor(255, 0, 0, 255), true) dxDrawImage(0, 0, 50, 50, "imagen.png", 0, 0, 0, tocolor(0, 255, 0, 255), false) end ) Ahora con el caso de adaptarse DX Image a todas las resoluciones, al igual que con guiCreateStaticImage, puedes utilizar los porcentajes para que se adapten de igual manera que los static-image. -- Se busca la resolución. local sx, sy = guiGetScreenSize() -- Calcular las posiciones utilizando porcentajes. ejemplo: x=0.5, y=0.5 crea la imagen a partir de la mitad de la pantalla. dxDrawImage(sx * 0.5, sy * 0.5, sx * 0.3, sy * 0.1, "imagen.png") Una forma más accesible sería re definir la misma función dxDrawImage para que se adapte a los porcentajes sin realizar los cálculos uno y otra vez. -- Primero redefinir la función. _dxDrawImage = dxDrawImage local function dxDrawImage(x, y, w, h, ...) local sx, sy = guiGetScreenSize() return _dxDrawImage(x * sx, y * sy, w * sx, h * sy, ...) end -- Luego dibujar addEventHandler("onClientRender", root, function() dxDrawImage(0.5, 0.5, 0.05, 0.05, "imagen.png", 0, 0, 0, tocolor(0, 255, 0, 255), false) dxDrawImage(0.3, 0.5, 0.05, 0.05, "imagen.png", 0, 0, 0, tocolor(255, 255, 0, 255), false) -- Ya como vez no haces el calculo una y otra vez ya que está realizandolo directamente cuando llamas a la función. end ) Puedes utilizar las posiciones del static-image como guía para usarlos en dx-image.
  15. Enargy,

    getElementData

    Change data[2] to data only
  16. When OnClientColShapeLeave is triggered you could check if the player is in any other colshape.
  17. Lmao. I'm not being negative. Clearly it says it does not tested. The gamemode concept as well is pretty good. Keep it going dude :)
  18. Why would you share your gamemode if it is not tested ?
  19. Ese error me pasaba cuando abría el MTA sin Internet. Trata de abrir el San Andreas, luego si notas que no abre.. abres el MTA.
  20. Por que el -2? Debería ser el total de dígitos menos uno. local n = tostring(digitos) return tonumber(n:sub(1, n:len()-1))
  21. function ConsoleEliminarMarker ( thePlayer, commandName ) if isElement(theMarker) then destroyElement(theMarker) theMarker = nil else outputConsole( "Failed to delete marker", thePlayer ) end end addCommandHandler( "deletetema", ConsoleEliminarMarker ) Cuando creas un elemento y lo guardas en una variable asegúrate de limpiar esa variable para liberar memoria.
  22. Enargy,

    createWater

    Lo calculas de la misma forma como se calculan los poligonos, por puntos que en este caso son las coordenadas en el juego. -- Son coordenadas inventadas. local PUNTOS = { [1] = {x = 1232.123, y = -6235.232}, -- POSICION EN LOS SANTOS [2] = {x = 2523.123, y = -5953.56}, -- POSICION EN LAS VENTURAS [3] = {x = 1513.123, y = -1933.234}, -- POSICION EN SAN FIERRO [4] = {x = 2313.123, y = -1123.112}, -- POSICION EN MOUNT CHILLIAD (opcional) } local ALTURA = 50 createWater(PUNTOS[1].x, PUNTOS[1].y, ALTURA, PUNTOS[2].x, PUNTOS[2].y, ALTURA, PUNTOS[3].x, PUNTOS[3].y, ALTURA, PUNTOS[4].x, PUNTOS[4].y, ALTURA)
×
×
  • Create New...