-
Posts
1,102 -
Joined
Posts posted by Enargy,
-
-
2 hours ago, MrKAREEM said:
¿Por qué creas coll? puedes recorrer todos los jugadores y usar GetDistanceBetweenPoints3D
+
al crear un objeto o una coll en el servidor de esa manera, debe usar la tabla porque si otro jugador envía un mensaje, la coll será destruida por él o causará algunos errores
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
-
On 06/04/2020 at 18:00, sthprk said:
estoy siguiendo unos tutoriales en videos de python y no me va tan bien no me salen la mayoria de los ejercicios soy un asco xd , me entero en teoria nadamas , por eso lo de 'no me va tan bien' ,aparte que me aburro , despues por otro lado edito algunos script Lua del mta , o puedo hacer uno pequeño como , crear un marker, al entrar al marker hace un sonido, abre una ventana, y hace una animacion , crea un objeto en la mano, al salir del marker tal cosa y asi... no se si gano mas viendo los tutoriales o creando editando scripts
porque tambien me lleva tiempo ponerme a hacer scripts xd
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.
-
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
- 1
-
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
-
On 17/01/2020 at 13:48, uvita said:
Hola, tenia una pequeña duda de como poner el comando del script grafitti, en este caso /canspray, quiero ponerlo privado para un grupo del acl, necesitaria saber como crear el grupo y como hacerlo privado solo para ese grupo, muchas gracias
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>
On 18/01/2020 at 08:42, uvita said:perdon, como pondria la condicional *
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
- 1
-
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)
- 1
-
-
Discord: Enargy#7907
-
On 05/06/2019 at 05:48, Cholewka said:
And how to do it? Map, model?
I think you are looking for something like this.
- 1
-
On 27/04/2019 at 17:39, Facundoz said:
Basicamente quiero hacer un mapa en otra dim pero no hay forma de que me deje hacerlo, es esto posible?
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.
- 1
-
14 hours ago, MatiMTA said:
I just fixed. Thank you very much for the help. It was a problem to change "player" to "source".
I did not see that lol. Anyways you're welcome.
-
3 minutes ago, MatiMTA said:
Basically the (getElementData (source, "KD")) results in the case of my account = 0.5 And in line 3 of the code should take effect, but it does not. Why could it be?
That's weird... the code is right. Are you typing the command after you get logged in?
- 1
-
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 )
- 1
-
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.
- 1
-
Change data[2] to data only
-
When OnClientColShapeLeave is triggered you could check if the player is in any other colshape.
- 1
-
15 hours ago, Peti said:
Why would you be such an as*hole?
Lmao.
I'm not being negative. Clearly it says it does not tested.
On 13/02/2019 at 06:31, Xendom said:The actual version is 1.0.2 (Beta - It was not tested with more than one player yet.)
The gamemode concept as well is pretty good. Keep it going dude :)
-
Why would you share your gamemode if it is not tested ?
-
That's really awesome.
- 1
-
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.
-
What kind of SAUR rpg is this lmao?
-
19 hours ago, aka Blue said:
Resuelto. Lo comparto por si alguien se calienta la cabeza alguna vez:
local digitos = 1234566 function quitarUnDigito( ) return tonumber( tostring(digitos):sub(1,-2) ) end
El problema era que quería un número y lo tenía que pasar a string para utilizar el :sub
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))
-
On 19/10/2018 at 19:19, MedicenMarcos said:
function ConsoleEliminarMarker ( thePlayer, commandName )
if ( thePlayer ) then
if ( theMarker ) then -- check if the marker was created successfully
destroyElement ( theMarker )
else
outputConsole ( "Failed to delete marker", thePlayer )
end
end
end
addCommandHandler ( "deletetema", ConsoleEliminarMarker )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.
-
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)
- 1
Count characters
in Scripting
Posted