-
Posts
140 -
Joined
-
Last visited
Everything posted by AlexTMjugador
-
It is not possible to recreate a proper aiming animation because they use inverse kinematics, and currently there isn't any scripting functionality to control that. Therefore, you must use one of these workarounds: Forcing the aiming to be in first person. This is the simplest solution, and it looks alright if well executed. If you don't see your own arms, why bother in applying an aiming stance? However, you will disrupt players who like the 3rd person aiming of GTA. Applying a generic aiming stance and rotate the ped along its height according to where he aims. This doesn't look that nice, and another player won't be able to tell if the player aims to the sky or the floor, but it is another possibility nevertheless. This is not a difficult thing to do if you have some maths knowledge. Giving the player a default, invisible weapon to aim, but hide it and let the custom weapon operate instead. This will give you the most similar to GTA: SA 3rd person shooting experience, but I find it more difficult than the second workaround. You choose! Creating vertex shaders which replicate an IK system. I even doubt that this is possible, and I don't have enough knowledge to program something like this, but if you somehow manage to do it you will be able to create any animation for any character from stratch. So complex, but very powerful. About aiming animations already offered by GTA, you can check out this list of animations and try some until you find the one you like most.
-
Your GTA: SA may have some missing sound files. Try reinstalling GTA: SA again, and make sure that it installs well and launches in singleplayer first. *staff note: Also read here for solution: https://forum.multitheftauto.com/topic/100998-game-starts-and-then-crashes/?do=findComment&comment=886286
-
Just a heads-up: I have recently discovered that getPlayerMapBoundingBox returns the screen coordinates of the world coordinates (-3000, 3000) and (3000, -3000), not (-3000, -3000) and (3000, 3000). It seems that the wiki was wrong, so the code I posted is wrong too because it accounts for different reference points. To fix my code, you have to replace this calculation: local fMx, fMy = (x + 3000) / 6000, (y + 3000) / 6000 With this one: local fMx, fMy = (x + 3000) / 6000, -(y - 3000) / 6000 I strongly recommend you to change that if you wondered why my code did calculate wrong positions.
-
Do you guys know about the existence of getPlayerMapBoundingBox? It is a MTA: SA clientside function useful for this kind of calculations. By using that function you can simply and accurately get the absolute screen coordinates (i.e. pixel positions) from world coordinates as it follows: local x, y = getElementPosition(localPlayer) -- Could be any other world position. Note that we only need X and Y (map is 2D) local mx, my, Mx, My = getPlayerMapBoundingBox() -- Returns the screen coordinates of the world coordinates (-3000, -3000) and (3000, 3000) if not mx then -- Do not continue if map is not showing return end -- Calculate a factor in range [0, 1] which represents the relative distance to the max coords point from the min coords point of the given coordinates local fMx, fMy = (x + 3000) / 6000, (y + 3000) / 6000 -- Do the opposite thing for the min coords point local fmx, fmy = 1 - fMx, 1 - fMy -- Use the factors and given screen points to calculate the final screen coords of our element in the map local sx, sy = (fmx * mx) + (fMx * Mx), (fmy * my) + (fMy * My) Please note that the code snippet I posted does not account for out of bounds coordinates and off-screen positions.
-
CodyL has a good point there. The impact of having a database per resource is largely dependent of your hardware, resources and server configuration, so measuring it exactly is difficult. However, it is certainly more efficient to have only one database handle open at the time and share it with every resource. That way SQLite can make more optimizations, you avoid fragmenting your hard drive much (although that is not a problem in SSDs) and database backups are easier: just copy one file and you are set. By using only one database you are essentially reducing memory, CPU and I/O overhead, so it will always have less impact than multiple databases. About saving and loading data frequently, all databases are designed to perform well even if there are multiple queries per second, so they are suitable for busy servers. Queries usually just take a fraction of the 10th part of a second, and MTA: SA database scripting functions can be made asynchronous, so the impact is almost always neglible. You just need to make sure that you are not doing useless queries too often and you will be fine.
-
Depende de los gustos. Alguien puede estar de acuerdo en que llamar a unas funciones con un nombre diferente puede ser más fácil e intutivo que referirse a ellas por su propio nombre, bien sea porque es un ingenio propio, bien porque puede llegar a entorpecer el robo de scripts o bien por cualquier otro argumento. Sin embargo, también es posible encontrarse con alguien que piense que darle un nombre no estándar a una función es una pérdida de tiempo, por tener que mirar una tabla para entender el código; que piense que ni siquiera aporta una sintaxis más clara, por seguir siendo no orientado a objetos; y que piense que dar nombres abreviados solo tienen sentido en un contexto reducido y son equívocos (por ejemplo, "sAD" en un script de aviones podría referirse a una función del script llamada setAirplaneData, no a setAccountData). Personalmente, como creo que di a entender ya, prefiero llamar a las funciones de una manera normal porque todos los que hacen scripts la conocen, y eso hace que el código sea más fácil de mantener si el concepto de sentido común del autor cambia o varias personas trabajan en él. Aunque también tiene sentido que uno mismo quiera trabajar cómodo, ahorrando caracteres que teclear o copiar, y tampoco soy nadie para impedírselo. Al fin y al cabo, en la tecnología importa más la solución que los pasos intermedios
-
Those bushes are generated procedurally (i.e. in real time), so removeWorldObject doesn't work on them because they are non-static. According to my own testing, you can do two things to stop them from generating: Remove the world object they are being generated on and recreate it as a custom element. This will stop the bushes from appearing the next time you load that area. Apply a shader to the bushes' textures to render them invisible, so it looks like there are no bushes there. The texture names shader can help you.
-
[TOOL] LUACGUI (Lua Compiler) for MTA <= 1.3.3
AlexTMjugador replied to FabienWang's topic in Resources
luac.multitheftauto.com already has an API which can be used in Lua scripts to encrypt script files automatically. And there are some resources out there which take care of compiling another resources, so mass compiling should be as easy as pie. -
Usar una tabla que está en server-side para cliente
AlexTMjugador replied to aka Blue's topic in Scripting
El cliente no tiene telepatía de momento, así que veo difícil lograr pasar información del cliente a servidor y viceversa sin usar una función destinada a eso. -
return is a keyword which stops the execution of a function and returns a value to the caller. It can only be used at the end of a block (if .. then .. end, function .. end, for .. do .. end, do .. end, while .. do .. end, repeat .. until); that is, it must be the last thing you write on it. If no value is specified, then the return value will be nil. Every function has an implicit return in the end of its block, so the following examples are exactly the same thing: local function hey() outputChatBox("Hello!") end outputChatBox( "The return value is: " .. tostring( hey() ) ) -- Will output nil local function hey() outputChatBox("Hello!") return end outputChatBox( "The return value is: " .. tostring( hey() ) ) -- Will output nil local function hey() outputChatBox("Hello!") return nil end outputChatBox( "The return value is: " .. tostring( hey() ) ) -- Will output nil This code shows a bit more advanced stuff with return: local function hey() outputChatBox("Hello!") do -- Exit the function here and return the string "Hello!" return "Hello!" end outputChatBox("I will never be executed!") end outputChatBox( "The return value is: " .. tostring( hey() ) ) -- Will output "The return value is: Hello!" In the function you posted, return is used to give the caller a number containing the ped's max health, so he can use that value to proceed with the script: pedMaxHealth = getPedMaxHealth(ped) -- Because getPedMaxHealth returns a number, the pedMaxHealth variable will contain the max HP of the desired ped, so it won't be nil
-
That is actually true. Lua will always be slower than a language that compiles directly to asssembly code, just by definition. The virtual machine adds some overload, even if it is negible. However, the vast majority of the times Lua performance is enough to script things for MTA. Custom encryption, compression, hashing or similar algorithms written in pure Lua are orders of magnitude slower (and perhaps memory demanding) than their C++ counterparts, but it is possible to workaround that to a certain extent. For example, you can use coroutines to alleviate and distribute the CPU usage, and do expensive operations only when they are not much of a hassle for the user, so even if it is slow it won't actually "lag". I bet that entire gamemodes like race have more than 1000 lines of code, while they are smooth to play. The real problem here is that most people that makes scripts is happy if they just work, thinking like "if it ain't broke, don't fix it". They just don't care if they could save some memory by destroying textures when the element streams out, save CPU usage by using pairs instead of ipairs when order is unimportant and things like that. And even if more performance is needed for the language, LuaJIT is a pretty convincing Lua-alike solution which is almost like C in terms of performance. It sacrifices portability and some things, but the result is basically a faster Lua. You can compare C, Lua, LuaJIT and Java in articles like this one, and although Lua may seem slow, take this: 1 second is like no time if done correctly, and Lua can perform better in other situations.
-
tostring o toJSON, dependiendo de qué uso le des a la cadena de texto resultante. Sabía que alguien iba a decir eso Dependiendo de lo que quieras hacer debes de usar un evento u otro, pero ambos tienen en común que se pueden ejecutar cuando un jugador pone un comando (comando: texto que se escribe en la consola o bien texto precedido de / en el chat), así que ambos son una respuesta válida a la pregunta que has hecho. Si querías que onPlayerCommand fuese la única respuesta, tendrías que haber especificado características concretas del evento. @Tomas, la función era resetMapInfo. ¿Qué función se usa para cambiar los píxeles de una textura?
-
i wanna learn Lua in order to start scripting
AlexTMjugador replied to samosavo's question in Client
Firstly, you should read a bit about Lua syntax and basic concepts: variables, data types, magic words, loops (for .. end loop, while .. do .. end loop and repeat .. until loop), functions, logical operators and tables. MTA Wiki has some interesting links for that in its main page, lua.org has a very complete (but not very newbie-friendly) manual and Google should yield useful results for you when looking for understandable advice. In addition, you can write Lua code and execute it online in lua.org, so you can practice while you learn easily. For your information, MTA uses Lua version 5.1. Once you know what Lua is about and how to write working algorithms, you are ready to start with MTA scripting. You should be able to understand almost everything that the wiki says, and it will be your best ally, really. I would say that 85% of scripting questions are already answered there, if you know where to look at and are proficient in English. Some articles are translated to other languages, but I would not recommend you to even think about looking at them. The majority of them are terribly outdated, and sometimes the translation is so incomplete or bad that it is even more confusing. I also find analyzing other people's resources quite useful: read the source code, and then try to understand what each line does. When you do that, you are automatically revising and applying scripting concepts, you can track what you can't understand yet to learn it, you are viewing examples of how to solve scripting problems and you open your mind to different coding styles. Besides analyzing, you can also modify the resource to suit your expectations (but keep in mind that if you publish it on the Internet and claim that it is your own code it will likely be bad for you). You might be wondering: what kind of resources can I pick to learn? I would suggest you simple (no more than 500 lines per script file and not using advanced concepts like metatables) but powerful resources, which are both client and server side, so you can see how does the server interact with the client and viceversa. The gameplay (not gamemode!) resources bundled with the MTA: SA server are a good starting point. Nevertheless, if the wiki, Google, Stack Overflow, Lua Users and other people's code are not enough to solve your problems, you can ask for help in the scripting subforum, or join us on IRC to chat about it. -
Try using these functions (I didn't test them myself): getCamera -- To get the camera element attachElements -- To attach the camera element to the car (while hopefully allowing mouse free look) If they don't work, you will have to use maths to script the camera mouse look when the camera moves, like freecam resources do.
-
I think you are talking about the health bar that is part of a nametag, not the HUD. To disable that bar, you will have to hide MTA: SA default nametag and draw your own. You can use the following functions to do that: setPlayerNametagShowing -- To disable the whole nametag getPlayerNametagColor -- To get the color of the original nametag getPlayerNametagText -- To get the text of the original nametag getElementPosition -- To get the world coordinates the nametag is at getPedBonePosition -- To get the world coordinates the nametag is at getScreenFromWorldPosition -- To get screen coordinates from world coordinates dxDrawText -- To draw the original nametag text with the original color in the specified place
-
onConsole. ¿Con qué única función se deja a un jugador en el estado en el que se encuentra tras unirse al servidor?
-
It is not possible to add new object IDs yet, but there are a bunch of SAMP objects available for use in MTA that replace some existing ones. Just search in Google.
-
You can download the latest unofficial MTA 0.6 release by Project Redivivus in their webpage. In addition, you can also check other releases or arrange meetings with other players in the MTA 0.5r2 subforum. Anyway, keep in mind that MTA for GTA III and VC was never developed as far as MTA: SA and the player base is much, much smaller. You will be very lucky if you find more than 30 servers online and more than 20 players concurrently.
-
GTA SA not works, I need help as fast as you could for somet
AlexTMjugador replied to MadeInEgypt's question in Client
After downloading DirectX, what happened to MTADiag? Did it give you a Pastebin URL to paste here? -
GTA SA not works, I need help as fast as you could for somet
AlexTMjugador replied to MadeInEgypt's question in Client
The MSVCP120.dll file is related to Microsoft Visual C++ 2013 Redistributable, which is a software MTA: SA uses in order to run properly. Have you ever tried reinstalling Microsoft Visual C++ 2013 Redistributable or repairing it? You can download it from here. If that doesn't work, download and run MTADiag, and post any Pastebin URL MTADiag gives you. -
Por curiosidad, ¿todos los servidores que has puesto en el sondeo están en español?
-
Veo más simple y fácil utilizar el OOP (Object Oriented Programming, Programación Orientada a Objetos) que MTA: SA ofrece desde hace ya varias versiones. Con solo añadir esto al meta.xml del recurso en el que lo que quieres usar OOP: <oop>true</oop> Te evitas definir tablas, y trabajar con datos de un elemento es tan fácil como: elemento:setData(nombre, dato) dato = elemento:getData(nombre) Además, hay planes de implementar la siguiente sintaxis, que es todavía más intuitiva: elemento.data[nombre] = dato dato = elemento.data[nombre]
-
Double check that selectSkinFromStore is a global (i.e. not local) function in the GTIclothes resource. Exports won't work when trying to export a global function.
-
That's right, I have done something like that on a script I made for a server and it works pretty well. I would recommend encoding the actual files in a separate folder once, so the server doesn't have to encode requested files over and over again when players want them, saving CPU and RAM in the long term. To make sure that the encoded file cache is up-to-date with the original files, you can compute hashes of the data and store them in a file when the resource starts: if they change, the file has changed too. That is a fast operation if you use something like MD5, even if your mods take 100 MB or more. However, if you want more security that the TEA algorithm provides, you can use AES Lua libraries (which are slow) or, better yet, an asymmetric key algorithm like RSA.
-
Make sure that your GTIclothes meta.xml doesn't contain any trailing spaces after the function name. That is, instead of having: <meta> ... <export function="selectSkinFromStore " type="server" /> <export function="selectSkinFromStore " type="client" /> ... </meta> You should have: <meta> ... <export function="selectSkinFromStore" type="server" /> <export function="selectSkinFromStore" type="client" /> ... </meta>