Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 27/02/20 in all areas

  1. Hi! Following the community discussion in our forums, we have created an official Discord server quite a while ago, as an alternative (and maybe a full replacement in the future) to our current IRC channels. We kept it in under the radar while we were fine tuning things, but we believe we can now present it to you guys. All MTA players and fans are welcome to join our Discord server (though please behave while you are in there ). You can join it by using this link: https://discord.gg/mtasa What is Discord? Discord is a hybrid of IRC, an Instant Messenger and a Voice Chat software. It incorporates the most important features of these elements into a handy and multiplatform app which you can run on your desktops, smartphones or tablets. Why is it cool? Compared to IRC, it offers a built-in chat history buffer, so even if you are offline, you can still catch up with what happened in the channels then. IRC also offers that, but only through an IRC Bouncer that you either need to pay for, or have someone host it for you. It also has a modern look and features such as URL embedding (regular websites, but also pictures and videos), handy syntax colouring for pasted code snippets, emojis (also custom ones), chat messages reactions, Steam integration and more. What can I find while I am there? We currently have some channels created, including: #general - for general MTA and offtopic chats #scripting - for Lua scripting-related queries #support - for any problems related to MTA:SA client or server #announcements - for all important messages from us as well as some others. We are still thinking of how to put our Discord server into its full potential, so we may add more channels soon. Can I have Discord app installed and/or running on several of my devices concurrently? Can I use more than one server? Sure, absolutely. It will sync the messages automatically. And yes, you can add more servers than just our one. How do I join it? Hey, we have mentioned that already. Just click the link below and follow the instructions: https://discord.gg/mtasa I have a suggestion about the Discord... Okay, let us know. As usual, we are open for suggestions. Just post in this topic or hit us up directly on Discord. Hope to see you there! -- MTA Team
    1 point
  2. addEventHandler + group elements I noticed that some people like to add 10000000000000000 addEventHandlers for each element, while you probably only need 1 addEventHandler. Using ONE addEventHandler on a group of elements? Answer: local group = createElement("groupMyCutePeds") -- Create a custom element and save it in to the variable <group>. -- Create 3 peds. local ped1 = createPed(120, 5540.6654, 1020.55122, 1240.545) local ped2 = createPed(120, 5541.6654, 1021.55122, 1240.545) local ped3 = createPed(120, 5542.6654, 1022.55122, 1240.545) -- Set the parent of the 3 peds. setElementParent(ped1, group) setElementParent(ped2, group) setElementParent(ped3, group) -- Add an addEventHandler and use the <group> as <attachedTo> element. addEventHandler("onPedWasted", group, -- "onPedWasted" = serverside. "onClientPedWasted" = clientside. function () outputChatBox("One of my cute peds just died. ;'( No exceptions!") end) Code is untested, but the method is tested. Syntax for functions in example createElement syntax element createElement ( string elementType, [ string elementID = nil ] ) setElementParent syntax bool setElementParent ( element theElement, element parent ) addEventHandler syntax bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [ bool getPropagated = true, string priority = "normal" ] ) DO NOT disable getPropagated getPropagated: A boolean representing whether the handler will be triggered if the event was propagated down or up the element tree (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to false will only be triggered if source == this). If you disable this, children of the <group> element are not included. Make use of the element tree Element tree For applying addEventHandlers to elements created by the resource: Use: resourceRoot / getResourceRootElement For applying addEventHandlers to elements created by scripts of the resource: Use: getResourceDynamicElementRoot For applying addEventHandlers to elements created by maps of the resource: Use: getResourceMapRootElement I hope your code will be without... print(10^10^10^10) -- Print here: https://www.lua.org/cgi-bin/demo ...addEventHandlers in the future.
    1 point
  3. Custom chat box in MTA: SA for sale. https://www.youtube.com/watch?v=4c54Ff0aVLI What does it have? - Detection of commands - /me and /do commands - Anti spam - Wrapping poems - Scroll up/down chat messages - Alpha animation for new messages - Avatar system and more ... Discord: .WhiteBlue #1048
    1 point
  4. I caught trend and I'm working on optimize bone_attach. 1000 objects in stream:
    1 point
  5. Alright, I'll answer some of the questions. Why do you destroyElement before creating a new one? - Whenever a player shoots you delete the sound that was previously played and create a new one to avoid multiple sounds being created at once, basically overlapping each other when they shouldn't. What is sound3d, why do you play from it when you didn't define it? - Look in the function, the function is named Sound3D then a table with "weapons" is created in which he posted the weapon 22, in this case the colt as well as the co-responding sound path to it. Now once you use the weapons [ weapon ] in the Sound3D the function itself will read the file path from the table that OP has posted. Basically what he did was make a seperate function that is somewhat of a replacement for the "playSound3D" in a way that it is further extended to the point that it can actually read data from your table making it easier for you to just simply add new data to the table rather than editing the entire function with, let's say, for example, "elseif" statements where you'd check all possible weapons. He does not need to define the sound3d variable because he already did so as a function arguement - "function Sound3D ( shooterPed, sound3d )" pedSounds is empty because it creates a new table, this way you can actually attach the source (in this case the shooting player) to the table so that each sound definition is unique, meaning multiple sounds won't be created under 1 variable which would cause multiple sounds being stuck to 1 variable as "destroyElement" would just destroy the latest defined sound to it and ignore all the sounds that were previously added to it. (see Lua's table definitions here to learn more about tables: https://www.Lua.org/pil/3.6.html ) Basically all you need to do now to add more sounds is update the table that OP has posted, here's an example: local weapons = { [22] = "sounds/Colt45.wav", [30] = "sounds/AK-47.wav", } This basically adds the AK-47 sound to the table as well, obviously you'd need the file to load from. After that the script will check if the shooting player has weapon ID 30, if so, it'll read from the table and play the sound from ID 30 which is defined in the [ ] tags.
    1 point
  6. Feature showcase #2 - Impound System details are now live on the forums.
    1 point
  7. I also got good results, this is the performance I got with 100 objects: 100 objects (looking directly at them): 100 objects (without looking at them): (I didn't notice any apparent problems when using isElementOnScreen, maybe I'll be back to test it soon) I would like to thank you and everyone who commented here, as this topic inspired me to learn a little more about optimization in Lua :D
    1 point
  8. Dear Moony, here is a script that fixes both overlaid sounds and the volume of distant sounds: function Sound3D(shooterPed, sound3d) local wX, wY, wZ = getPedWeaponMuzzlePosition ( shooterPed ) local sound = playSound3D (sound3d,wX, wY, wZ, false ) attachElements (sound ,shooterPed , 0, 0, 2 ) setSoundMaxDistance(sound, 50) setElementDimension(sound,getElementDimension ( shooterPed )) setElementInterior(sound,getElementInterior( shooterPed )) return sound end local weapons = { [22] = "sounds/Colt45.wav", --[id] = "sound name", } local pedSounds = {}; setWorldSoundEnabled(5,false) function onClientPlayerWeaponFire ( weapon ) if weapons[weapon] then if isElement(pedSounds[source] ) then destroyElement(pedSounds[source] ) end pedSounds[source] = Sound3D(source, weapons[weapon] ) end end addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), onClientPlayerWeaponFire ) Sounds are not deleted if players leave the server. Implementing this is an exercise left for OP. P.S. Please understand that scripting is an effort that you can train. If you are having trouble with parameters like "source" or don't know about the function calls, it can be a good idea to script some random resources (exploding bottle attachment to players, weapon attachment to vehicles, etc).
    1 point
  9. You have misspelled detachElements, you typed detachElement without s. Does this solve your problem?
    1 point
  10. Então vc veio do SAMP. Excelente, vc já deve saber como o GTA SA funciona mais do que um jogador comum saberia. Seja muito bem-vindo ao Multi Theft Auto. De cara, vou lhe passar alguns links importantes: Regras deste fórum (caso ainda não tenha visto): Página inicial da Wiki do MTA (acesse os links de Scripting): https://wiki.multitheftauto.com/wiki/Página_Inicial Na Wiki vc aprende sobre as funções usadas pelo MTA, por exemplo o createVehicle que serve para criar um veículo tal, numa coordenada tal. Mas tenha em mente que pouquíssimas páginas estão disponíveis em português. É necessário conhecimento intermediário em inglês para entender (assim como qualquer coisa relacionada a tecnologia, sem inglês vc não vai longe). Também na Wiki existem exemplos mostrando como usar determinada função, seus parâmetros e a sintaxe dela. Uma coisa que vc vai perceber logo de cara de diferença quanto ao SAMP, é que aqui as funções estão separadas em tipo client, shared e server. As funções client só funcionam em scripts client-side. Elas afetam somente o cliente do jogador, nunca o servidor. Por exemplo: Funções que criam elementos de menu, são client-side. Funções que verificam a conta dos jogadores, são server-side. Funções de cálculos, geralmente são shared e funcionam em ambos os tipos de script. Isso está explicado nos links da Wiki. A primeira dica que eu dou pra quem está começando no MTA mas já sabe programar, é baixar resources (mods) gratuitos e descompilados do site da comunidade do MTA e estudar como eles funcionam. Experimente resources bem simples primeiro. A segunda dica é comentar cada linha dos códigos. (Em Lua, use dois traços para iniciar um comentário. function qualquerCoisa (thePlayer, cmd) -- Início de função, sendo thePlayer o parâmetro de função e cmd o segundo parâmetro de função. if (cmd == "teste") then -- Se o comando utilizado para ativar essa função for /teste então: outputChatBox ("Comando teste executado.") else outputChatBox ("Comando teste falhou.") end -- Finaliza e fecha o escopo da condição. end -- Finaliza e fecha o escopo da função. addCommandHandler ("teste", qualquerCoisa) -- Adiciona um comando /teste para ativar a função qualquerCoisa. --[[ Isso é um Bloco de comentários. O código acima funciona tanto em scripts server-side quanto em client-side. ]] Busque sempre comentar cada linha dos seus scripts, assim vc sabe exatamente pra que serve cada linha e o que está acontecendo nela. Outra coisa importante, indente sempre seus códigos. Não faça um texto ilegível onde vc mesmo se perde e não sabe onde uma coisa começa e onde termina. Se você é novato, busque primeiro deixar seu resource funcionando. Depois você se preocupa em otimizá-lo. Scripters avançados já fazem otimizando direto, mas é necessário conhecimento para isso. Não tente "dar um passo maior do que sua perna". Como mencionado anteriormente, crie um servidor local para começar a testar seus códigos lá. Tutorial de como criar um servidor local também está naqueles links. Nossa comunidade está aqui para ajudar e não para programar para você. Se tiver dúvidas enquanto está tentando criar seu script, podemos ajudá-lo a resolver os erros ou apontar falhas de lógica, podemos até mostrar a parte corrigida. Vale lembrar que não damos suporte para scripts roubados de terceiros, crie seus próprios. Sobre a parte de projetos em si: Na pasta do MTA, em server\mods\deathmatch\resources você tem algumas pastas por padrão. As pastas que estão entre colchetes indicam ao MTA que os resources estão dentro dela e não que ela é um resource em si. Se vc criar uma pasta sem colchetes, o MTA vai considerá-la como um resource. Normalmente os donos de servidores colocam os resources tudo de qualquer jeito ali e vira uma bagunça. Mas no meu caso, eu deixo os mods separados naquelas [pastas] e inclusive criei outras como [vehicles] [maps]. Também criei uma pasta de estudos. Eu crio um resource com nome teste e só movo ele posteriormente para uma [pasta] adequada somente se eu termino de desenvolver ele e de corrigir seus erros. As vezes acontece de eu desistir de finalizá-lo pois ele se tornou complexo demais ou muito pesado ou simplesmente seu objetivo exige algo que está além da capacidade do GTA. Nesses casos, dou um nome para o resource mas ele continua na pasta de estudos.
    1 point
  11. Primeiramente, vc sabe programar em Lua? Segundamente, vc sabe criar um servidor local para testar seus scripts? Sua dúvida é muito interessante e bem válida. A maioria não se interessa por esse detalhe e já querem sair fazendo scripts logo de cara, resultando em scripts horríveis, bugados e nada otimizados. Se sua resposta for positiva para minhas duas perguntas, dai sim poderei responder a sua dúvida.
    1 point
  12. HELP function of skill DX-HUD how to make a function of skill in arms showing (1-2) weapon in two hands on HUD DX local skills = getPlayerSkills(getLocalPlayer()) dxDrawText(skills.."", x*1262, y*153, x*1341, y*167, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, true, false, false) and local skills = getPlayerStas(getLocalPlayer()) dxDrawText(skills.."", x*1262, y*153, x*1341, y*167, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, true, false, false) - - - - - - - - - - - Result end
    1 point
  13. Thanks for the help Assinatura removida, sorry me
    1 point
  14. FAKE: https://community.multitheftauto.com/ind ... ls&id=9194 ORIGINAL: https://community.multitheftauto.com/ind ... mp;id=9004 This script original is of(Rocketman21) DONE
    0 points
×
×
  • Create New...