Jump to content

AlexTMjugador

Members
  • Posts

    138
  • Joined

  • Last visited

About AlexTMjugador

  • Birthday 22/12/1998

Details

  • Location
    Spain
  • Occupation
    College student
  • Interests
    Engineering informatics, gaming

Recent Profile Visitors

1,226 profile views

AlexTMjugador's Achievements

Poot-butt

Poot-butt (14/54)

3

Reputation

  1. Por experiencia personal, entre los lenguajes que has mencionado, te recomendaría empezar con C# (se lee C sharp). En Google puedes encontrar muchos cursos para aprenderlo aún sin tener experiencia previa, ya que es bastante usado en la industria y, por ende, enseñado en contextos académicos. Además, su IDE (entorno de desarrollo integrado, donde se codifican los programas, para que te vaya sonando) llamado Visual Studio es bastante intuitivo y eficaz para todo tipo de programadores. Sin embargo, ya que estás aprendiendo algo por deseo personal, tampoco tienes por qué empezar por los lenguajes que todo el mundo dice que son importantes (no sin razón, por supuesto). Creo que como mejor puede aprender alguien a programar es planteándose un problema sencillo que quiera resolver con muchas ganas, independientemente del lenguaje que se use. Por ejemplo, ya que estamos en el foro de MTA, podrías intentar hacer un script sencillo para un servidor con amigos, que contribuya a hacer el freeroam más divertido, o modificar un script ya creado para tu uso personal (siempre que el autor lo permita). El material de calidad disponible para aprender Lua es más escaso, y es no es un lenguaje muy popular. Pero como lenguaje de script para extender MTA, funciona muy bien. Y no solo es útil para MTA: Lua combina diversos paradigmas de programación y tiene una sintaxis bastante análoga a lenguajes como C, aunque más sencilla. De hecho, su curva de aprendizaje es corta (es decir, se aprende más rápido). Así que lo que aprendas en Lua podrá hacerte más fácil aprender C#, Java, C, Python... Empieces por donde empieces, lo importante es ser tenaz, como en todo
  2. If that's what you want to do, you'll have to create an intermediate table with the account names as strings on it, and pass that to the table.concat function. table.concat expects a table with strings on its indexes, but does not convert any data in it to a string itself. This code should comply with your needs: addCommandHandler("myAccounts", function (player, cmd) local accounts = getAccountsBySerial(getPlayerSerial(player)) local accountNames = {} local accountNumber = 0 for _, acc in pairs(accounts) do accountNumber = accountNumber + 1 -- Why use the table length operator when you iterate over its elements and can do this? This seems more efficient accountNames[accountNumber] = getAccountName(acc) end outputChatBox("You have " .. accountNumber .. " accounts with these logins: ".. table.concat(accountNames, ", "), player) end ) If you have any doubt of why or how does that work you can add a reply to this post, so someone can help you out
  3. Mod note: the below explanation only applies to 'clean' luac files (non-obfuscated, but level 0 compilation) such as used in the wide LUA community in different applications. MTA (at https://luac.multitheftauto.com/) also offers obfuscation to additionally encrypt your bytecode LUA with a cryptographic salt, preventing decompilation by traditional methods found on the internet. Therefore, protected LUAC is safe from decompilation for aslong our alghoritm is safe (obviously, nothing in the tech world is uncrackable.. the key can get bruteforced somewhere in the future with some computing power, after which it will fit in the decompiler's keyhole and do its traditional job.. euphemism ). The use of Luac in MTA isn't focussed on the performance benefit of compiling into and executing from bytecode, but mostly motivated by securing your scripts against theft of source code, as MTA server owners can additionally encrypt said bytecode. Compiling to bytecode (what a standard .luac file contains) was never intended as any means of obfuscation to make things harder to reverse engineer, as the same way that compiling C code (for example) into assembly is not. However, because people who have an idea on how to translate bytecode back to more human readable Lua code in MTA: SA usually have better things to do than stealing that flashy new script of that DayZ server of yours, most server owners think that compilation is an anti-stealing measure. It just works, but from a security point of view it doesn't make much sense to assume that something is secure just because it's compiled and few people can understand it. There are ways to translate (mod note: non-obfuscated) MTA: SA .luac files back to standard .lua code, and the answer is lying on the Internet with only doing a quick search on Google and in these forums. However, you need to understand very well how does MTA load a compiled script, what features does Lua offer and how to make it work in a way that gives you the result you want (some code that, while being equivalent to the one you have first, can be translated directly to source code). That's probably what you haven't been able to realize yet, and to not scare server owners so much, don't transform this in a C++/Lua course and because I'm dubious about your intentions, you should continue the research for the answer yourself
  4. This is a clever usage of EXE file format specifications, indeed. Although I don't think the mature codebase of MTA: SA will benefit from this, the best use case scenario I can think of right now is total conversion mods or enthusiast GTA: SA versions with some game-fixing ASI mods embedded in them (SilentPatch, etc.), and that's indeed useful. Well done!
  5. Usa SQLite, MySQL o cualquier otro programa o método que escriba información en el disco duro para guardar datos que deben de perdurar aún tras reiniciar el servidor (debes de hacer esto si quieres que la selección de skin se recuerde para siempre). Usa tablas, datos de elementos y variables en general cuando guardes información volátil, que no necesita ser usada en futuros reinicios del servidor (haz esto si la selección de skin tiene carácter no permanente en el tiempo, porque va asociada a una selección de equipo o similares motivos). En general, es más eficiente usar variables y triggerClient/ServerEvent para este fin, pero dependiendo de la situación los datos de elementos pueden ser más sencillos e igual de eficientes. Sobre la pregunta que haces de SQLite, en efecto no es lo mismo que MySQL, pero se puede usar para un fin similar: guardar información en bases de datos, usando lenguaje SQL. La principal diferencia entre SQLite y MySQL radica en que el primero guarda todo lo relativo a una base de datos en un archivo, no está diseñado para ser concurrente, no requiere de un servidor y admite bases de datos de hasta 140 TB (que pueden limitarse por el sistema operativo a un valor menor como 4 GB), mientras que el segundo requiere de un servidor para funcionar, es concurrente y no tiene un límite de tamaño tan definido. MySQL es más fácil de mantener una vez que se configura su servidor, pero SQLite está diseñado específicamente para ser usado en aplicaciones como el servidor de MTA y, al no usar un servidor web, realiza su trabajo bastante más rápido, de manera más segura y no requiere configuración previa. La página web de SQLite usa su propio producto y explica cuándo debes (y no debes) usar SQLite, frente a alternativas como MySQL.
  6. Call me crazy, but the OP is not asking for just working code. He's asking how to improve or whether it is good the code he already has, in order to fix or ignore that warning. So I will try to answer your question: that kind of warning should never be ignored. It means that whatever your code does takes a long time to finish, and in slower servers it could also mean that your script gets aborted in the middle of its execution, throwing errors and not doing what you want it to do. You need to fix up your code, so it doesn't suck up all the limited CPU time the computer has. I hear you asking: "but if my code does really need that time, how can I avoid this?" In that case you can't make your code take less time, but you can distribute the total time it takes in slices by using coroutines. They allow to pause and resume execution of functions, so while they are paused the server can use that CPU time to take care of another things, and in turn don't freeze everything else. When using coroutines, you are basically letting the PC to take a break from time to time, to allow him to dedicate his resources to another pieces of code. So you should fix your code by making appropiate use of coroutines, in order to don't freeze your server and don't see warnings while it executes. But if for some reason you are lazy, you can't really get to coroutines usage or you simply want to do performance tests, you can disable the MTA: SA hook that throws that warnings: debug.sethook() But beware: disabling that hook is NOT a programming practice that should be used in production scripts. It is only intended for development purposes, not as a everyday solution to avoid coroutines. And it won't stop your server from freezing or even crashing; instead, it will make the problem worse, because if your script executes infinitely for some reason you will have to restart the entire server to stop it.
  7. If you still worry about wallhacks after disabling mods entirely, disable custom d3d9.dll by enabling the related SD. It would also help enabling the SD 14, 15, 16, 22 and 23, but that would probably start to kick out more legit players than hackers.
  8. Las metatablas son algo que se podría considerar más acertadamente como scripting avanzado, aunque no es necesario saber de su existencia a la hora de empezar a trabajar con tablas. En general, sus usos se limitan a simplificar código, conseguir programación orientada a objetos, modificar el comportamiento del colector de basura y el de los operadores. Y tales posibilidades no se las suele plantear alguien que empieza en Lua, que busca que su código simplemente funcione y haga algo que compense el esfuerzo vertido.
  9. Creo que nos harías un favor a todos si definieses más concretamente a qué te refieres con "script avanzado". A mí por lo menos lo que han dicho arriba de aprender a usar tablas (la única estructura de datos asociativa de Lua) no me parece muy avanzado que digamos.
  10. The maximap resource is what are you looking for. It also includes some improvements over the default F11 map which you can read on the description.
  11. It is already possible to try Lua 5.3 code in its own webpage, which is largely equal to Lua 5.1's. The downside of that page is that it doesn't use the custom MTA functions and its debug hooks, but it is still useful to test if some piece of code will likely function fine.
  12. This length variable definition should give you the desired result. It sacrifices a bit of prominence of hot colors to give it to blue-ish colors. local length = interpolateBetween(430, 0, 0, 670, 0, 0, progress, "InQuad") Just replace the previous line by this new one.
  13. The only thing you can do to effectively hide errors and warnings which originate from scripting errors is making your own debug view, hiding the default one and control which messages do you want to be output to the new debug view by using the onClientDebugMessage event. However, if that warnings and errors are caused by explicit calls to the outputDebugString function, you can disable that function (providing that scripts don't call it in a hacky manner, or overload it with another name) by using addDebugHook: local targetResource = getResourceFromName("resource-name") local function disableDebugOutput(sourceResource) if sourceResource == targetResource then -- Don't call the actual function if the call is from the resource we want to block return "skip" end -- Otherwise, continue normally end addDebugHook("preFunction", disableDebugOutput, { "outputDebugString" }) Keep in mind that addDebugHook and any other approaches to hide that warnings are not designed with performance and retail use in mind, so it is not a good practice to just hide the errors in the script. Fixing the errors which cause the debug spam is the thing that should be done instead.
  14. You can't apply most cutscene animations to players (only a subset of them), so it's not entirely possible. But of course you can replicate the rest of things pretty accurately.
  15. It is not possible to interact with Javascript when using a remote browser due to security reasons. You must use the local mode to do that.
×
×
  • Create New...