AlexTMjugador

Members
  • Content Count

    147
  • Joined

  • Last visited

Everything posted by AlexTMjugador

  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.mtasa.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.
  16. I don't really know how to help you further properly. I could tell you what experiments I would do, but providing that HLSL documentation out there is rather misleading and that I do not have an advanced knowledge of the language I think that letting a more experienced person help you is more appropiate, unless you want to try countless modifications to your code until we find a working solution that will probably be not very efficient.
  17. I have tried with 6 and 12 seconds and the color transition works as expected: each and every color phase modifies its duration linearly. Can you describe the effect you want more precisely, please? In case you are referring to the abrupt color "jump" between red and violet, it can be fixed by inverting the progress value after each period (that is, the first period goes from 0-1, the second from 1-0, the third back from 0-1, and so on): local startTime = getTickCount() local lastProgress = 0 local alternateOrder = false local function rainbowColorVehicle() local progress = math.fmod(getTickCount() - startTime, 3000) / 3000 if lastProgress > progress then -- Flip interpolation targets after each "restart" alternateOrder = not alternateOrder end -- Save last progress to calculate the above lastProgress = progress -- Take alternateOrder into account to invert the progress progress = alternateOrder and 1 - progress or progress local length = interpolateBetween(400, 0, 0, 650 --[[ Reduced 50 nm here to make the apparent red color be visible less time ]], 0, 0, progress, "Linear") local r, g, b = wavelengthToRGBA(length) for _,v in pairs(getElementsByType("vehicle", root, true)) do if isElementOnScreen(v) and (getElementData(v,"rgb") == "on") then setVehicleColor(v, r, g, b, r, g, b, r, g, b, r, g, b) end end end addEventHandler("onClientPreRender", getRootElement(), rainbowColorVehicle)
  18. I remember playing race back in MTA: SA 1.3 while watching bugs like the one you said continuously. Actually, things like doing PIT maneuvers in MTA: SA have always been difficult because of this, so that's why I don't think this is a new issue which was introduced in MTA: SA 1.5. Maybe 1.5 did change a bit how sync works, but I have never experienced further issues with it so far. I would even say that I have seen various issues to disappear.
  19. The bugs you talk about were always present in MTA: SA. And they are not possible to fix, unless the developers make the server aware of the game world. Did the server owner made a change in the sync settings or something?
  20. A creative usage of the scripting functions I may say. Looks nice!
  21. I will answer your questions by the order you wrote them: Yes. You just need to use setPedControlState, givePedWeapon and setPedAimTarget. If you can't find that functions it's your own problem, because they are pretty well documented in the wiki. Even the setPedAimTarget article says how you can make a ped shoot. Yes. Even if you can't drag peds out of their vehicles by default, you can script your own ped dragging mechanic which can look like the one we all know and love. Besides that, I would not call a currently not implemented feature a "bug". No, but why do you need them? To manipulate memory, a practise which can entirely compromise the client's computer? To use opcodes which can already be scripted in MTA with enough work? I don't see how SCM is a "reference" to MTA: SA, providing that the former already has enough features to script almost anything and that they target a completely different use case scenario (I don't think SCM was ever meant to be a language to script the GTA: SA engine from the ground up). I would say it won't, and in the strange case it did it would crash everything, so it would not last long. Anyway, GTA: SA AI is pretty basic in most things and scripting it again in Lua is not a big deal. The CrystalMV's resource you mentioned is a good example of that: the peds created by that resource are as intelligent as they are in singleplayer. And with enough environment data gathered via processLineOfSight, physics and elements it could be vastly improved, at least conceptually. Last, but not least, there is the possibility that the MTA developers want to give us a function like createTrafficVehicle which syncs without any further scripting some day, and everything I said will be reduced to the use of that function. On top of that, if you think that MTA: SA has some important missing features which should be addressed inmediately, a good idea would be to learn C++, assembly and understand how does the GTA: SA engine work and get your own hands on that. We all will thank you for that, and it will rewarding, I promise
  22. You may need to set the texture state 0 to its default value instead of simply nil'ing it. To get the default texture for a certain state, use this (copied straight away from mta-helper.fx): texture gTexture0 < string textureState="0,Texture"; >; If you don't want your object to have a texture, you will probably need to create a dummy one which is all white or something like that.
  23. Change the line 51: local progress = math.fmod(getTickCount() - startTime, 3000) / 3000 To: local progress = math.fmod(getTickCount() - startTime, time) / time Being the time variable the time in milliseconds you want the transition from red to violet to last (of course, remember that you can replace time with a number like I did, or else you will have to define the variable somewhere in the code). To achieve the effect you want, I would try 6000 ms first and then change that value until it looks nice. Doing this kind of effects which need frequent updating in the server is definitely so SAMP-ish and unefficient. It will waste bandwidth by syncing the vehicle color each 50 ms, when the clients can already expect that color and apply it by themselves. And in the server you can't get elements by their type which are streamed in so easily, so it will introduce some CPU overhead too. However, if your server has unlimited bandwidth, a hell of CPU and you feel like doing this clientside will make people complain "HEY Y0UR S3RV3R IS SO LAG PLS FIX" only after knowing it is done on their PCs, computing it on the server is the way to go.
  24. My code does work, I have just tested it. I wouldn't want to waste the time of both of us with scripts which are wrong, don't you think? The problem with the script is that the code I posted is clientside only, and the command handler you added is designed for the serverside, so it won't obviously work because it assumes and requires different arguments to work. Other than that, the code is working like a charm. Here you have the fixed version of your own code: function rgbToggle(_,value) if not value then outputChatBox("Syntax: /rgb (on/off)",0,255,255) end if (value == "on") then setElementData(getPedOccupiedVehicle(localPlayer),"rgb","on") outputChatBox("Enabled.",0,255,255) elseif (value == "off") then setElementData(getPedOccupiedVehicle(localPlayer),"rgb","off") outputChatBox("Disabled.",0,255,255) else outputChatBox(value.." is not a valid argument!",0,255,255) end end addCommandHandler("rgb",rgbToggle) local function wavelengthToRGBA(length) local r, g, b, factor if (length >= 380 and length < 440) then r, g, b = -(length - 440)/(440 - 380), 0, 1 elseif (length < 489) then r, g, b = 0, (length - 440)/(490 - 440), 1 elseif (length < 510) then r, g, b = 0, 1, -(length - 510)/(510 - 490) elseif (length < 580) then r, g, b = (length - 510)/(580 - 510), 1, 0 elseif (length < 645) then r, g, b = 1, -(length - 645)/(645 - 580), 0 elseif (length < 780) then r, g, b = 1, 0, 0 else r, g, b = 0, 0, 0 end if (length >= 380 and length < 420) then factor = 0.3 + 0.7*(length - 380)/(420 - 380) elseif (length < 701) then factor = 1 elseif (length < 780) then factor = 0.3 + 0.7*(780 - length)/(780 - 700) else factor = 0 end return r*255, g*255, b*255, factor*255 end local startTime = getTickCount() local function rainbowColorVehicle() for _,v in pairs(getElementsByType("vehicle", root, true)) do if isElementOnScreen(v) and (getElementData(v,"rgb") == "on") then local progress = math.fmod(getTickCount() - startTime, 3000) / 3000 local length = interpolateBetween(400, 0, 0, 700, 0, 0, progress, "Linear") local r, g, b = wavelengthToRGBA(length) setVehicleColor(v, r, g, b, r, g, b, r, g, b, r, g, b) end end end addEventHandler("onClientPreRender", getRootElement(), rainbowColorVehicle) I have also optimized the onClientPreRender handler function loop, because looping through every vehicle created is insane and can generate pretty big slowdowns if your server if full of them and that optimization does not modify how the effect looks.
  25. AlexTMjugador

    Una pregunta

    No se puede hacer lo que propones, aunque teniendo en cuenta que hay 65536 dimensiones diferentes es factible meter a cada jugador en una diferente. En cuanto a posibles objetos que quieras que sean comunes a esas dimensiones, puedes hacer un script que haga coincidir la dimensión de esos objetos con la de cada jugador en el lado del cliente.