Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 25/01/21 in all areas

  1. bengines provides custom engine sounds for vehicles. The resource is not focused to be ultra realistic, it is designed to use for casual servers. Not useful for me anymore so sharing with community. Used on old project. Sounds are copyrighted content not owned by me. Features: ready to use, chooses the best engine for vehicle depending on handling! easy to customize & expand for Lua programmers 30 soundpacks for vehicles (buses, bikes, sport cars etc.) stable code with quite high performance used on server with 600 players ALS effect (exhaust flames) Turbo (satisfying whistle and blow-off sounds) Videos: https://streamable.com/n7k40 https://streamable.com/lp14t https://streamable.com/q5e9g Download: Github: https://github.com/brzys/bengines (feel free to send pull requests) Community: to-do For programmers: --[[ Element datas used by resource [array] vehicle:engine - stores basic info about engine type, sound pack etc. (synced) [string] vehicle:type - used for engine calculation, useful for servers. Available: Bus, Truck, Sport, Casual, Muscle, Plane, Boat, Motorbike (synced) [string] vehicle:fuel_type - customized for each engine. Useful for servers. Available: "diesel", "petrol" (synced) You can use setElementData(vehicle, "vehicle:upgrades", {turbo=true, als=true}) to add turbo or ALS. --]] --[[ Exported functions --]] exports.bengines:getVehicleRPM(vehicle) -- returns RPM of given vehicle exports.bengines:getVehicleGear(vehicle) -- returns current gear of given vehicle exports.bengines:toggleEngines(bool) -- true / false, restore GTA engine sounds
    1 point
  2. pAttach Optimized bone attach thanks to the new MTA functions/events. This resource doesn't match with well known bone_attach, you can not use the same parameters! Documentation moved to GitHub! Go to GitHub...
    1 point
  3. A solução encontrada por vocês, é sim eficaz, porém podem haver sobrecargas no servidor, devido à função isObjectInACLGroup. Caso o servidor atinja uma quantidade considerável de jogadores - mais que 100 - essa função pode até causar um NETWORK TROUBLE no servidor. Claro que não é tão assim de forma exagerada, depende de vários fatores, incluindo o potencial de processamento do servidor - mas né, não vamos deixar algo mal feito. Você poderia definir um timer assim que o jogador entrar numa sessão (login). Dessa forma, cada um iria receber o prêmio (ou dinheiro, como vejo no exemplo acima), de acordo com a sessão. Ninguém iria receber ao mesmo tempo, o que já tiraria uma grande responsabilidade do servidor de processar várias informações de uma só vez. Porém, também tenho alguns contras sobre o setTimer. Infelizmente, terá vários timers dentro do resource rodando. O que pode ou não ser um problema - ao meu ver, não é tão prejudicial assim. Mas, venho com outra solução, que seria melhor! Assim que o jogador entrar na sessão, insira-o numa tabela e, ao invés de percorrer todos os jogadores usando o getElementsByType, você iria percorrer apenas a tabela, com alguns jogadores apenas. Isso sim já seria uma ótima solução e que causaria o mínimo de impacto no servidor. Pode parecer uma solução meio grande à primeira vista, mas é bem otimizada. O timer só irá se iniciar caso algum jogador Premium entre numa sessão - apenas uma vez, claro; O timer também irá se desfazer e ser destruído caso não haja mais jogadores premium no servidor; Concluindo, você evitou de percorrer todos os jogadores do servidor - que poderia ser acima de 100, 200 ou até 300 - para uma simples tabela que haverá alguns jogadores. Acredito eu que, menos de 50 jogadores. O importante é otimizar os timers e ser o mais específico e objetivo possível.
    1 point
  4. Isso mesmo!! Só tome cuidado com o element data pois quando o player desloga, esse dado se perde. Verifique se em alguma parte do código está salvando esse "gangue" pra conta com o setAccountData, e carregando novamente pro elemento quando o player logar.
    1 point
  5. Quase. Quando alguém tentar entrar na polícia ela NÃO pode ser de gang, certo? Então deve ser: if not getAccountData( account, 'MembroDeGang') then --OU-- if getAccountData( account, 'MembroDeGang') == false then --As duas condições são a mesma coisa. Fugindo um pouco do assunto só pra te explicar uma coisa: O not "inverte" a condição. Se a condição der true (ou seja, o player é membro de gang) ele inverte pra false e não executa o código dentro da condição. É semelhante a um == false. Se a condição der false (ou seja, o player NÃO é membro de gang) ele inverte pra true e executa a condição. É semelhante a um == true. No fim das contas uma condição pra executar deve ser if TRUE then.
    1 point
  6. Então você não pode passar o player por parâmetro, deve verificar dentro da função. local tempo = 10000 --tempo em milisegundos function vipBronze() for i, thePlayer in ipairs(getElementsByType('player')) do --Pega todos os players do servidor, joga dentro de um for (estrutura de repetição) local account = getPlayerAccount ( thePlayer ) --Pega conta do player da vez (vai verificar todos os players do servidor, um por um) local accName = getAccountName ( account ) if not isGuestAccount(account) then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Bronze" ) ) then givePlayerMoney(thePlayer, 5000) end end end end setTimer(vipBronze, tempo, 0) Testa aí e vê se funciona.
    1 point
  7. Você deve setar alguma coisa que diga que a pessoa é de gang ou de corp. Por exemplo: ------------------ENTRAR NA CORP------------------ if not getAccountData ( account, 'MembroDeGang') then setAccountData ( account, 'MembroDeCorp', true) -- SEMPRE QUE ENTRAR NA CORP, SETE ISSO. --RESTANTE --DO --CÓDIGO end ------------------ENTRAR NA GANG------------------ if not getAccountData ( account, 'MembroDeCorp') then setAccountData ( account, 'MembroDeGang', true) -- SEMPRE QUE ENTRAR NA GANG, SETE ISSO. --RESTANTE --DO --CÓDIGO end E quando a pessoa sair da corp ou da gang, não esqueça de setar os mesmos atributos acima como false.
    1 point
  8. Existe a função setAccountData. Tecnicamente ela também é um banco de dados, mas de uma forma bem mais simples. É como se fosse um setElementData, a diferença é que os dados do setElementData ficam armazenados enquanto o elemento ainda existe (ou seja, quando a pessoa desloga, esses dados somem). Já o setAccountData fica armazenado no banco de dados das contas cadastradas, ou seja, se o jogador deslogar, o dado continua salvo no banco de dados.
    1 point
  9. Sorry, I didn't know about the reply reactions It's working perfectly fine, I can't thank you enough
    1 point
  10. Before (without element): guiSetText(switchData.languages[language] or switchData.langauges[defaultLanguage] or select(2, next(switchData.languages)) or guiGetText(switchData.element)) After (with element): guiSetText(switchData.element, switchData.languages[language] or switchData.langauges[defaultLanguage] or select(2, next(switchData.languages)) or guiGetText(switchData.element)) Also please stop putting confusing reactions on most of my replies, it marks them as confusing in general while most of them are not. Sure, I do not mind, if my reply does not make sense at all. You could using emotions in your own replies instead, that makes more sense. @TorNix~|nR
    1 point
  11. Ofc it is, for MTA you can make your own objects and implement them in maps, here im just using samp objects to create interiors ( Walls etc ) because i dont have knowlage to make 3d objects in 3dmax etc..
    1 point
  12. Please create the object using Lua functions or map editor. Another thing that would explain the issue, is having poorly calculated collision boundings. If your collision boundings are not covering your DFF model, it will cause camera clipping issues. Please work on the above and reply back if the issues persists.
    1 point
  13. You could try this, not tested. But it is a start. local languageSwitch = {} local defaultLanguage = "nl" function guiSetLangaugeSupport (element, languages) languageSwitch[#languageSwitch + 1] = {element = element, languages = languages} guiSetText(element, languages[defaultLanguage] or guiGetText(element)) return element end function guiSetLanguageSwitch (language) for i=1, #languageSwitch do local switchData = languageSwitch[i] guiSetText(switchData.element, switchData[language] or switchData[defaultLanguage] or select(2, next(switchData)) or guiGetText(switchData.element)) end end switchData[language] or -- The option you want switchData[defaultLanguage] or -- default language select(2, next(switchData)) or -- First possible item guiGetText(switchData.element) -- previous text ;O local button = guiSetLangaugeSupport(guiCreateButton(0, 0, 0, 0, "", false, panel), {en = "Police", nl = "Politie"})
    1 point
  14. thePlayer é, de fato, o parâmetro da sua função que recebe o jogador? Você não está verificando se a função getPlayerAccount está retornando uma conta válida. Use isGuestAccount para verificar.
    1 point
  15. Hi. A solution if you give weight to items, so 1 weight = 1% chance. local totalWeight = 100 -- SUM of weights -- IMPORTANT, add items in ascending order by weights local choices = { {"Second item", 15}, {"Third item", 15}, {"First item", 70}, } function getRandomChoice() local randomWeight = math.random(totalWeight) -- get a random weight (between 1-100) -- loop trough table, and find which item is at the random weight. (for example, at the 20th position is "Third item") for i, choice in ipairs(choices) do if randomWeight <= choice[2] then return choice[1] end randomWeight = randomWeight - choice[2] end end I hope you understand it, but there is a video, it's C# but maybe helps: https://www.youtube.com/watch?v=OUlxP4rZap0
    1 point
  16. I'd rather see Python or C# implemented, as alternative scripting, before JS.
    1 point
  17. Events tutorial The reason why I created this topic, is that a lot of people are struckeling with them. In this tutorial I will only discus the very basic of them. If you want more, then there is a list of links at the end with more information. If I made any mistakes in the code, please let me know because I am not going to test every part. What are events? (basic description) Events are something custom added by MTA to make it easier to bring scripting(Lua) closer to our game. If we do not have events, then the only thing we can do is give instructions to our game. But our code will never detect changes in our game. The same question again: "So what are the events?" Events are a way to communicate changes in our game to our scripts (or from our scripts). So for example my little ped(cat) gets ran over by a car. Then I really want to know about that, don't I? When an event activates, I describe this as: triggered (from the word trigger) Full wiki information can be found here: Event_system Before we can use events, what do we need to know? There are two things we need to know: The reason why it is triggered. <What happens?/when something happens?> In MTA this is the eventName of the event. (Example: you <ran over> my ped) Who is the one using the event? The event system in MTA is using elements as base (baseElement). This makes it easier to combine the what/when happens? with the one who is related to it. In MTA this is the source of the event. (Example: you ran over my <ped>) Trigger an event A scripting example: (this is not an official event) local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped triggerEvent("onPedRanOver", ped) In this example, a custom event gets triggered to tell you that my new created ped has been ranOver. The eventName is "onPedRanOver" and the baseElement is ped. local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) In this SERVERSIDE example, I am also adding an extra argument drunkDriver to use the player that ran over the ped. This is not required, but it makes it more complete. See syntax. Syntax bool triggerEvent ( string eventName, element baseElement, [ var argument1, ... ] ) TriggerEvent Receiving triggers Receiving triggers is a bit more complicated, because there are a lot of options for it. You can receive events by listening to them. It is like: You know that something is going to happen but you do not know when. The first step that you have to take is related to this question: "Do I want to receive a custom or not custom event?" Custom events are self created events. They only exist when a scripter makes them. Two lists of NOT CUSTOM EVENTS but default MTA events, serverside and clientside: Server_Scripting_Events Client_Scripting_Events Do I want to receive a CUSTOM event? In case of a custom event, you have to register/enable it first. If you do not enable it and trigger it, you will receive a warning/error about that in your debug console. Syntax bool addEvent ( string eventName [, bool allowRemoteTrigger = false ] ) AddEvent The example below, shows you how to enable a custom event only for trigger events within the same server/client side. addEvent("eventName") -- Is the same as: addEvent("eventName", false) If you put the second argument to false or not fill it in, this means that you can't communicate from the other server/client-side. This option is most likely used for security reasons. Some events shouldn't be able to trigger by the other side For example, worst case scenario: (remote events enabled for a default MTA event) Serverside code: addEvent("onPlayerWasted", true) Clientside code: triggerServerEvent("onPlayerWasted", player, 0, localPlayer, 0, 9, false) OnPlayerWasted If this event is enabled for remote trigger events, then it might be possible to cheating kills/deaths score. Of course, it is not likely that players can run their own clientside code, but it is not impossible in case of not trust able community resources. Enable a custom event for trigger events that crossing sides (From clientside to serverside. From serverside to clientside). addEvent("eventName", true) This event can now be used by remote trigger event functions. See list: Client to server TriggerClientEvent TriggerLatentClientEvent Server to client TriggerServerEvent TriggerLatentServerEvent Enable the event from our previous example: addEvent("onPedRanOver", false) local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) If you do not use cross triggering, then I recommend to use the addEvent function in the same resource as where you are going to trigger from. This makes sure that the event is already added and that you will never receive this kind of error/warning "Event isn't added". If you put it in another resource which hasn't started yet, then after triggering you would still receive that error/warning. Start listening The next step is to add the addEventHandler. This function is used to listen to events. When an event is triggered, this handler(addEventHandler) will call the function you have attached to it, in MTA this function is called the handlerFunction. Syntax bool addEventHandler ( string eventName, element attachedTo, function handlerFunction [, bool getPropagated = true, string priority = "normal" ] ) AddEventHandler Resource 1 addEvent("onPedRanOver", false) local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) Resource 2 function handlerFunction () end addEventHandler("onPedRanOver", root, handlerFunction) The first 3 arguments, the require ones: eventName attachedTo handlerFunction Making sure that the addEventHandler options are correct set-up. Resource 1 addEvent("onPedRanOver", false) local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) Resource 2 function handlerFunction () end addEventHandler("onPedRanOver", root, handlerFunction) There are two conditions for an eventHandler to call the handlerFunction. 1. The event has to be exactly the same. In this case the event "onPedRanOver" is the same in both resources. 2. In both functions, triggerEvent and addEventHandler is an element being used. This element has to be exactly the same. (from where you trigger as well as where you receive) <OR> The triggered element from resource 1, has to be a CHILD of the element in resource 2. The root element is the very top layer of the MTA element structure. It will accept all elements you want to use for your events. See the element tree: If you do not understand the element tree please read this page: Element_tree Source variable The source of an event is the element that triggers the event. This variable isn't passed as an parameter, but it is predefined. This means that it is already created before hand. Some predefined variables do only exist under special conditions. The source variable is one of those, it is a hidden and local variable which is only available when a function is called by an event. List of predefined variables. addEvent("onPedRanOver", false) -- local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) function handlerFunction (drunkDriver) iprint(source) -- ped element end addEventHandler("onPedRanOver", resourceRoot, handlerFunction) In this example the ped is the source. See how those two code blocks are connected: addEvent("onPedRanOver", false) -- local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) function handlerFunction (drunkDriver) iprint(source) -- ped element end addEventHandler("onPedRanOver", resourceRoot , handlerFunction) resourceRoot In some examples, you see people use the resourceRoot instead of the root element for their addEventHandlers. The resourceRoot is an element created by a resource. This element holds all elements of that resource as (in)direct children. In the example above, the resourceRoot as baseElement will not work, because there are two resources. Each resource has it's own resourceRoot element. The resourceRoot is accessible with the same keyword: resourceRoot, but if you were to inspect the element in multiple resources, then the user data (element identifier) value is not the same. outputChatBox(inspect(resourceRoot)) If we were to put everything in one resource, then it would work: ? addEvent("onPedRanOver", false) -- function handlerFunction () end addEventHandler("onPedRanOver", resourceRoot, handlerFunction) -- local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) In case of remote triggering, the resourceRoot in serverside and clientside is considered the same.(As long as they are part of the same resource) Why/when would we use resourceRoot? 1. Limit eventHandlers to the resource elements If you have 1000 markers in your server. One of the resources is for example a trucker mission, where you can get money by hitting markers. The resourceRoot element will make sure that the onMarkerHit event will only trigger for markers created by that resource. addEventHandler("onMarkerHit", resourceRoot, function () -- source element is the marker end) OnMarkerHit 2. Another benefit is that you are able to re-use the same eventNames. Resource 1 addEvent("onPedRanOver", false) function handlerFunction () end addEventHandler("onPedRanOver", resourceRoot, handlerFunction) -- local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) Resource 2 addEvent("onPedRanOver", false) function handlerFunction () end addEventHandler("onPedRanOver", resourceRoot, handlerFunction) -- local ped = createPed( 120, 5540.6654, 1020.55122, 1240.545 ) -- my ped local drunkDriver = getRandomPlayer() triggerEvent("onPedRanOver", ped, drunkDriver) These two resources do use the same event, but will not trigger each other their addEventHandlers. Warning: If root was used, then they will!!!! ;@ Lets cross triggering with resourceRoot! Clientside triggerServerEvent("example", resourceRoot) Serverside addEvent("example", true) -- second argument is true! cross triggering enabled! addEventHandler("example", resourceRoot, function () end) getPropagated In this bigger example we will be talking about the option getPropagated. If this option is disabled, it will not detect children any more. Keep reading! After that start code scanning from A, to B and then to C. Syntax addEventHandler bool addEventHandler ( string eventName, element attachedTo, function handlerFunction [, bool getPropagated = true, string priority = "normal" ] ) Example: Clientside -- A triggerServerEvent("onClientPlayerLoaded", resourceRoot) -- trigger an event to serverside --------------------------------------- -- C addEvent("onResponseServer", true) -- first listener addEventHandler("onResponseServer", resourceRoot, function () outputChatBox("getPropagated enabled") end, true) -- getPropagated true by default. -- second listener addEventHandler("onResponseServer", resourceRoot, function () outputChatBox("getPropagated disabled") end, false) -- getPropagated is false. Serverside -- B addEvent("onClientPlayerLoaded", true) -- second argument is true! cross triggering enabled! addEventHandler("onClientPlayerLoaded", resourceRoot, function () --[[ client is a predefined variable, which represents the client/player that communicates with the server More information about predefined variables: https://forum.multitheftauto.com/topic/33407-list-of-predefined-variables/ ]] triggerClientEvent(client, "onResponseServer", resourceRoot) -- first trigger event local element = createElement("randomElement") -- making a randomElement triggerClientEvent(client, "onResponseServer", element) -- second trigger event end) How does this this code works? A. When a client his code has been started, it will execute a triggerServerEvent. (It doesn't wait for any other clientside files to be loaded) B. The server receives the event. And sends two triggerClientEvents back: The first one is using the resourceRoot as baseElement. The second one is using a randomElement as baseElement. Both are using the event "onResponseServer" C. There are two addEventHandlers listening to the event: "onResponseServer" The first one is using getPropagated and the second one is not using getPropagated. The randomElement that is created, is by default an indirect child of the resourceRoot of the same resource. What will happen? When firing the first trigger event, both listeners will call their handlerFunction. But when firing the second trigger event, only the first listener will call it's handlerFunction. The randomElement is an indirect child of resourceRoot, but because getPropagated is disabled it will not call it's handlerFunction. Other tutorials related to this one: See also this tutorial about deeper limiting event ranges within your resource and reducing addEventHandlers https://forum.multitheftauto.com/topic/100069-tut-addeventhandler-on-a-group-of-elements-small-tutorial/ More information Full wiki information: Event_system A list of more information about triggering events: (Client to client / server to server) TriggerEvent Client to server TriggerClientEvent TriggerLatentClientEvent Server to client TriggerServerEvent TriggerLatentServerEvent A list of more information about receiving events: AddEvent AddEventHandler RemoveEventHandler Two lists of MTA events, serverside and clientside: (warning: not custom events) Server_Scripting_Events Client_Scripting_Events Cancel events CancelEvent WasEventCancelled (warning: custom events ONLY) GetCancelReason (Server only) Cancel latent events and their status GetLatentEventHandles CancelLatentEvent GetLatentEventStatus
    1 point
  18. Check this out : https://forum.multitheftauto.com/viewtopic.php?f=91&t=53562 I hope it help .
    1 point
  19. To get it to work in MS Notepad (and anything else), do \r\n instead of just \n
    1 point
×
×
  • Create New...