Leaderboard
Popular Content
Showing content with the highest reputation on 12/09/19 in all areas
-
Not sure if it's related to your case, but IIYAMA showed me how this could be done for onClientVehicleDamage. For important details, you would need to wait for his answer. In my case: Instead of triggering each hit, damage would be saved in table and after certain time, timer would execute triggerServerEvent, after data is cleared. This is called buffer/data reduction (probably?), as far i know. So, basically you reduce triggerServerEvent calls and you save bandwith. This might be helpful, it's also IIYAMA code local sendingDelay = 100 -- ms local fps = 60 local timeSlice = 1000/fps local dataReduction = sendingDelay/timeSlice print("~"..(dataReduction - 1 ).." x times LESS per "..sendingDelay.."ms") https://www.Lua.org/cgi-bin/demo edit: great timing2 points
-
There is no best way. Just be aware of the large amount of downsides of elementdata. Elementdata is nice for some functionalities, but do not use it when you have a scenario where it's features are not being used. Tables are pure for storing data on a player his computer. This data type only exist within a specific resource. It is very fast and clean. And cleans itself after the resource has stopped. Elementdata is a feature, that allows you to bind data on to an element. This data is available on all resources as it has left the Lua environment. Because the data leaves the Lua environment, it is not deleted when the resource stops. It is only deleted when the element is destroyed or when it is manually removed. By default this data is also shared with the server and all other players. Great! (if you want that) > Note: it can also quickly take over a large part of the network bandwidth when over using it. (results in Lag) But luckily it is possible to not share it with the server and the other players. bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] ) Turn that OFF, by set it to false. Be aware: by default it is ON. Another benefit as well as a disadvantage is that element data has it's own event: https://wiki.multitheftauto.com/wiki/OnElementDataChange https://wiki.multitheftauto.com/wiki/OnClientElementDataChange Which gets triggered when the data changes. It is a nice feature, but it also uses a lot of performance. My recommendation Do only pick elementdata when you specific need to bind data to an element to SHARE it with another resource or other players. Do not over use elementdata. Be aware that elementdata is not data stored in your resource, but bound to your elements. Use tables everywhere you do no have to rely of elementdata features. Most of the time a triggerServerEvent is enough to share data with the server. Elementdata is a wild card.1 point
-
1 point
-
Correction. It should be after LEFT JOIN. Because you need first the data and then you set the condition/filter. LEFT JOIN `Item` ON `Player`.serial = `Item`.serial WHERE true1 point
-
1 point
-
You can use "INNER JOIN" but you will need to practice it a little bit (columns with the same name will be prefixed with the table name)1 point
-
I would suggest this format: ID (auto incremented) INT | playerSerial TEXT | itemType TEXT | amount INT This allows you lot more flexibility. (based on your current structure) SELECT `Player`.*, `Item`.Bandage FROM `Player` LEFT JOIN `Item` ON `Player`.serial = `Item`.serial Getting all the info of the player and the bandage quantity. The keyword JOIN allows you to join another table. LEFT means that: `Player`.serial = `Item`.serial It will get all the data from the table on the left side. (MAX all the rows of the leftside) Attach data from the table on the right side where possible.1 point
-
There is 1 important reduction, which is in my opinion the most important one. "Don't tell the otherside what it already knows." So if you reply to my previous post with a confused reaction. Then I know you did that, but also you know that you did that yourself. Now we both know that it was a confused reaction and you do not have to tell me that again, because I already know. If we apply that same concept on a smart ped system. Ped move forwards. Ped move forwards -- do not repeat Ped move forwards -- do not repeat Ped move backwards Ped stop Ped stop -- do not repeat Ped stop -- do not repeat Ped stop -- do not repeat ---‐–––––————— If we want to fake something, we have to approach that a bit differently. For example we have a ped which we want to bounce his head up and down. And yes like this: Up and down while the car his driving. If you program this, the only data that should be used, is the on and off state. When ever the head is up or down, that is irrelevant. The data for the head orientation (up/down) is faked.1 point
-
1 point
-
Ja tentou tirar o convertnumber pra testar? caixa = getElementData(localPlayer, "Bank:Caixa") or 01 point
-
function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end joga isso na sua script1 point
-
1 point
-
when you declare functions inside something like that, they should not be given names (the exception is creation as a variable). addEventHandler("onClientRender", root, function() local vida = getElementHealth (localPlayer) local colete = getPedArmor (localPlayer) local dinheiro = getPlayerMoney (localPlayer) local vidatual = (screenW * 0.0932) * (vida/100) local coleteatual = (screenW * 0.0932) * (colete/100) local procurado = getPlayerWantedLevel(getLocalPlayer()) local bank = convertNumber(getElementData(localPlayer, "player:Banco") or "0") end) For questions about the code, there is a special section: https://forum.multitheftauto.com/forum/71-scripting/1 point
-
Mostrar mensagem no chat: outputChatBox Obter os players de uma ACL: getPlayersInACLGroup Veja o exemplo na página pra ver como funciona o loop.1 point
-
1 point
-
Try this addEvent("onSettingChange", true) addEventHandler("onSettingChange", localPlayer, function(variable, value) if variable == "draw_distance" then local state = not (value == "Off") draw.setVisible(state, true) end end) function draw.setVisible(visible, notifyDisplay) draw.visible = visible and true or false draw.changeDistance(draw.visible) if notifyDisplay then triggerEvent("notification:create", localPlayer, "Draw distance", "is now "..(draw.visible and "ON" or "OFF")) end end function draw.changeDistance(max) for i,object in pairs(getElementsByType("object")) do if isElement(object) then local elementID = getElementModel(object) engineSetModelLODDistance(elementID, max and 325 or 100) end end end function initialize() draw.setVisible(true, false) end addEventHandler("onClientResourceStart", resourceRoot, initialize) Your code had all sorts of logic errors, especially with the onClientResourceStart, which was only being added when you ran draw.setVisible, but also being attached for all resources, instead of just the current one. It would never run for the current resource that way.1 point
-
Thank you! I had to change some things up a little bit to match my needs and get it done correctly, it's working now just as I wanted to!1 point
-
addEventHandler("onPlayerLogin", root, function(_, account) if not getAccountData(account, "FirstTime") then outputChatBox("Voce está jogando pela primeira vez", source, 255, 255, 0) setAccountData(account, "FirstTime", true) else outputChatBox("Não é a sua primeira vez", source, 255, 255, 0) end end) use então = SERVER-SIDE local account = getPlayerAccount(source) if getAccountData(account, "FirstTime") then1 point
-
É só verificar quando o jogador chega sobre a marca e executa o mesmo evento de como se clicasse na letra (bindKey) para o evento de passar na marker (onMarkerHit).1 point
-
واصل وماشاء الله فكرة المود جميله والمود نفسه جميل الله يوفقك?1 point
-
حلووه الفكره شفتها كان كيلر مسويها فى سيرفره , بس معلش لقيتك خافي السيريال ومب خافي الاي بي بينما الاي بي اخطر , ? بيستخدم فى الدوس .. المهم .. عمل جيد وموفق ^^1 point
-
Hey, i reworked mta community webpage. I apologize in advance for my bad english Russia power!1 point
-
I Strongly like the current MTA Homepage I Choose to remake community: I ever liked MTA SA and started learning to code Lua last months, Been doing design by a time I know HTML, CSS but i dont have much experience, and JS. , Somehow i never created an portifolio But you can check my YT Channel and its my second time working on a website front end.1 point
-
I would choose tables, after that what @IIYAMA taught me, i use tables almost everywhere. I feel like tables are very efficient comparing to element data, yet they require more code to sync which imho gives an better control how do you send data.1 point
-
Hi all so nvidia and other companies are creating really strong tablet and gat sa is now on android and iOS so can u guys port mta sa or give us the source code and we port it so this all about the topic Thanks. android tablets could run it i thinks about1 point
-
Why not thinking about reduction and faking continuous effects? Instead of trying to solve the issue at the moment you already created too much data? If you are dealing with too much data, the latent trigger event can reduce impact on clients. It is send when the network is free. (+ you need to merge all data in to 1 triggerEvent) https://wiki.multitheftauto.com/wiki/TriggerLatentClientEvent Forcing 100ms is more or less killing your network. Better to check the status of the latent event, before sending the next payload of data. https://wiki.multitheftauto.com/wiki/GetLatentEventStatus If you want to have some advice for reduction and faking. I need to know a lot more about the context of the data and a lot of the details (conditions).0 points
-
function test() local alpha = math.sin ( getTickCount () / 200 ) dxDrawRectangle ( 416, 174, 498, 373, tocolor(0, 0, 0, 255*alpha), false ) end addEventHandler("onClientRender", root, test)0 points
