Leaderboard
Popular Content
Showing content with the highest reputation on 17/10/17 in all areas
-
local screenWidth, screenHeight = guiGetScreenSize() local webBrowser = createBrowser(screenWidth, screenHeight, false, false) function webBrowserRender() dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true) end addEventHandler("onClientBrowserCreated", webBrowser, function() loadBrowserURL(webBrowser, "https://wiki.multitheftauto.com/wiki/Main_Page") addEventHandler("onClientRender", root, webBrowserRender) end ) Load this script and you should have all the information you need.2 points
-
Thank you all the same. But listen bro, I am just want to make some contributions to MTA. I don't accept any donation materially. Instead, you use it and give me the response to your feeling. This is the best donation to me.2 points
-
Hello, We, the eXo-Reallife team, would like to release a module that is also used on our server. It is a pathfinding module developed by Jusonex and StiviK. The module uses the A * algorithm. (https://en.wikipedia.org/wiki/A*_search_algorithm) We use this for our GPS: Why did we develop a module for this and did not simply write a script? This has a very simple reason. The module calculates the routes in your own threads, which has the advantage that it is much faster than a script, and secondly, you can calculate how much routes as you want side by side. This will not cause any lags etc.! What are the features of the module? The module can load several graphs / nodes side by side The module calculates the routes in its own threads Very useful API functions (such as findNodeAt or getNodeNeighbors) What are the main features? int loadPathGraph (String pathToGraphFile) This function loads the graph from the given file and returns a GraphId which you need for all other functions. If something does not work, false is returned. bool findShortestPathBetween (int graphId, float startX, float startY, float startZ, float endX, float endY, float endZ, function callback) This function finds the shortest route between the points. (Unfortunately, no vectors can be handed over!) The callback function is called when the calculation is finished. As an argument, either a table is returned that contains all nodes, or false if no route is found. bool unloadPathGraph (int graphId) You can use this function if you no longer need and want to unload the graph, it returns true if everything is fine, false if an error has occurred. You will find all the other functions that are included in our documentation. Why is the eXo team releasing all this? Well, that has the simple reason, we want to share our work with others and not just keep it for us! We hope we can enrich you with it and vlt. Even help! Where can I download the module? The whole module is open-source and can be viewed in our GitHub organization. It's released under the MIT License. GitHub organization: https://github.com/eXo-MTA Repository: https://github.com/eXo-MTA/ml_pathfind Download the module (Windows / Linux): https://github.com/eXo-MTA/ml_pathfind/releases Nodes of all roads in SA: https://github.com/eXo-MTA/ml_pathfind/blob/master/test/sa_nodes.json If you find any mistakes or suggestions, you can simply create a new issue and we will look into it. So now that's it, have fun with the module! - StiviK and the eXo-Reallife team (Original thread in German: https://www.mta-sa.org/thread/36365-release-mta-sa-pathfinding-module/?postID=407938#post407938)1 point
-
Hello community. This is my first decent post on the forums, so bear with me. Currently, if you want two resources to share some data, or call some functions from each other, there are two methods: -You could use exports to call functions in another resource. Such a function needs to be global, defined statically in meta.xml, and called using exports. In such a function call, only certain datatypes are transferred. Functions, etc are lost. Any tables transferred are passed by value not reference (You get a copy, so any changes you make do not change the actual table) and any information about metatables is lost. -You could use elements. Information can be shared and set using setElementData, and functions can be called by making the functions event handlers, and using triggerEvent instead of function calls. Again, function objects cannot be passed, tables are passed by value, and metatables are not applied. The syntax for these is also terrible and inconvenient. I bring to you, bakaGaijin. The one stop solution for all your inter resource communications. -Now, letting another resource use your function is as easy as: --This is the first resource, called "Resource1" bakaGaijin.SomeFunction = function() outputChatBox("Hello world") end --This is the second resource, called "Resource2" bakaGaijin("Resource1").SomeFunction() --Resource1 will output "Hello World" No need to edit the meta.xml file for every time you wish to export some thing. The sharing is done at runtime! The syntax to "export" something is: bakaGaijin.EXPORTED_NAME = SOME_VALUE SOME_VALUE can be anything, not just a function. So you can even expose your tables to other resources. Or constant literals, anything you want. --This is the first resource, called "Resource1" bakaGaijin.SomeTable = {1, 2, 3} --This is the second resource, called "Resource2" local table = bakaGaijin("Resource1").SomeTable for i, v in ipairs( table ) do outputChatBox(v) table[i] = 0 end Tables are passed BY REFERENCE. So any changes you make to the table are actually reflected on the one in the other resource. This means that after Resource2 has run, the table that was in Resource1 will have 0 for all it's values. (This assumes Resource2 was started after Resource1, for the table to exist first) Functions are not lost, and are transferred safely. So they can be used as parameters for other functions, can be returned by a function, stored in a table etc. Tables do not lose any values. Tables with functions in them (key or value) transfer while preserving the functions. Metatables are also not lost. Any __newindex or __index metamethods you set on a table will be active even when it is passed to another resource. (Caveat: Only the host resource that originally created the table can set it's metatable properly. I'll fix this in later versions of the resource) On top of that, it's fast. I've optimized it so that you will never even feel that you're working with different virtual machines at the same time. To use bakaGaijin, all you need to do is: 1) Export a function called "bakaGaijin_export" in your meta.xml file for the resource that wants to use bakaGaijin. 2) Make sure you download and start bakaGaijin before the resources that will use it. You can download bakaGaijin from https://github.com/Luca-spopo/bakaGaijin (If you're a developer, then folk the repo to show your appreciation! Contributions are welcome, just send me a pull request) 3) Append this line to your program: loadstring(exports["bakaGaijin"]:use())() OR add bakaGaijin.lua (provided in the folder bakaGaijin) to your meta.xml file as a script. (Before all other scripts) This: element = createElement() setElementData(element, "x", 200.001) --Used to give floating point errors at some point setElementData(element, "y", 100) --Also, the field names must be strings AFAIK exports["SomeResource"]:sendElementToMe(element) --The colon notation changes the signature of the function turns into this: local table = {x=200.001, y=100, 1, 2, 3, 4, = table} --Indices dont have to be strings, and recursion is allowed bakaGaijin("SomeResource").sendElementToMe(table) This also means that you can make and use Lua classes across resources. No need to include files made by other people into each one of your resource. So something like 50p's GUI classes https://forum.multitheftauto.com/viewtopic.php?f=108&t=24122&hilit=class can become an actual part of DxLib. (In fact, my current project is to use bakaGaijin to make my own dxGUI library) You can do some really cool shiz with bakaGaijin. Remember, the objects that you are exposing using bakaGaijin.blabla are only the "named" objects. Any objects belonging to the closure or a table in blabla are also accessible. Moreover, bakaGaijin.blabla itself is an object, and can be used as such. You can use it as a parameter if you want. Something like this is totally valid: --Resource1 loadstring(exports["bakaGaijin"]:use())() bakaGaijin.fun1 = function(a, b, c) bakaGaijin("Resource2").checkA(a) b.i = true bakaGaijin("Resouce2").checkB() assert(c==bakaGaijin.fun1) end --Resource2 loadstring(exports["bakaGaijin"]:use())() local a = function() end local b = {i = false} local c = bakaGaijin("Resource1").fun1 --Assuming Resource1 started first. bakaGaijin.checkA = function(par) local keyTest = {} keyTest[a] = false keyTest[par] = true assert(keyTest[a]) --True end function bakaGaijin.checkB(par) --This syntax also works, and is super cute. assert(b.i) --Resource1 set it to true, so it's true end c(a, b, c) --Calls the function in Resource1 Note that the length operator (#) does not work on exported tables, and I cannot make it work unless MTA upgrades to Lua 5.2 bakaGaijin provides a global function called len that should be used instead. len(table) will give the length of a table properly, even if it is an "exported" table. A word of caution: bakaGaijin has it's own garbage collector on top of Lua's garbage collector. Any object that goes from one resource to another is monitored for usage, and deleted when unused. So try to not load the garbage collector too much and dont use gaijin objects for things that will happen very often. In case you are wondering about the name, bakaGaijin means "Stupid Foreigner". The objects that are being sent to other resources are foreigners. Yes I know it's lame. I have included two resources called bakaGaijinTest1 and bakaGaijinTest2 on the github repo, run these alongside bakaGaijin and then type "/bakaTest" to see that everything works. You can open driver.lua and driver2.lua in these resources to see examples of how to do stuff, and to go through it's features. Have fun! Leave a reply if you like it. Or help me build the documentation or wiki or whatever. Link to source code: https://github.com/Luca-spopo/bakaGaijin1 point
-
Download: https://community.multitheftauto.com/?p=resources&s=details&id=14907 - /globalcena - Troll everyone on server - /cena [playername/part] (troll a specific player) - /stopcena (effect will last until stopped with this cmd) it will replace all world textures with johncena GIFs and sound the known meme track that belongs to it. Credits also to @Brophy, originally made by him for SAES server but now edited.1 point
-
local scw,sch = guiGetScreenSize() local cursorX,cursorY = getCursorPosition() local absX,absY = cursorX*scw,cursorY*sch1 point
-
استبدل جهة الكلينت بهذا : _setElementModel = setElementModel function setElementModel ( e, m ) return triggerServerEvent ( 'setElementModel_SERVER', e, m ) end addEventHandler ("onClientGUIClick",getRootElement(), function(button,state,absoluteX,absoluteY) if (button == "left") then if (source == clothesshopStartWindowCJbutton) then cjTempTable = nil cjTempTable = {} for i=0,17 do local tstr,mstr = getPedClothes local tempTab = {i,tstr,mstr} table.insert (cjTempTable,tempTab) end guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopCJwindow,true) elseif (source == clothesshopStartWindowSkinButton) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopCJwindow,false) guiSetVisible (clothesshopSkinWindow,true) elseif (source == clothesshopStartWindowCloseButton) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) elseif (source == clothesshopSkinWindowButtonOK) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopSkinWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) elseif (source == clothesshopSkinWindowButtonCancel) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopSkinWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) triggerServerEvent ("clothesShopClose",getLocalPlayer(),"skin-cancel") elseif (source == clothesshopCJwindowButtonOK) then local clothes = {} for i=0,17 do local t,m = getPedClothes (getLocalPlayer(),i) if t and m then table.insert (clothes,i .. "," .. t .. "," .. m) end end guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopSkinWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) triggerServerEvent ("clothesShopClose",getLocalPlayer(),"save-cj",clothes) elseif (source == EmploymentAgencyWindowCloseButton) then guiSetVisible (EmploymentAgencyWindow,false) showCursor (false,false) guiSetInputEnabled (false) elseif (source == clothesshopSkinWindowLeft) then local skin = getElementModel (getLocalPlayer()) if (skin == 0) then setElementModel (getLocalPlayer(),312) elseif (skin == 7) then setElementModel (getLocalPlayer(),2) elseif (skin == 9) then setElementModel (getLocalPlayer(),7) elseif (skin == 43) then setElementModel (getLocalPlayer(),41) elseif (skin == 66) then setElementModel (getLocalPlayer(),64) elseif (skin == 75) then setElementModel (getLocalPlayer(),73) elseif (skin == 87) then setElementModel (getLocalPlayer(),85) elseif (skin == 148) then setElementModel (getLocalPlayer(),118) elseif (skin == 150) then setElementModel (getLocalPlayer(),148) elseif (skin == 209) then setElementModel (getLocalPlayer(),207) elseif (skin == 290) then setElementModel (getLocalPlayer(),288) elseif (skin == 274) then setElementModel (getLocalPlayer(),272) else setElementModel (getLocalPlayer(),skin -1) end elseif (source == clothesshopSkinWindowRight) then local skin = getElementModel (getLocalPlayer()) if (skin == 312) then setElementModel (getLocalPlayer(),0) elseif (skin == 2) then setElementModel (getLocalPlayer(),7) elseif (skin == 7) then setElementModel (getLocalPlayer(),9) elseif (skin == 41) then setElementModel (getLocalPlayer(),43) elseif (skin == 64) then setElementModel (getLocalPlayer(),66) elseif (skin == 73) then setElementModel (getLocalPlayer(),75) elseif (skin == 85) then setElementModel (getLocalPlayer(),87) elseif (skin == 118) then setElementModel (getLocalPlayer(),148) elseif (skin == 148) then setElementModel (getLocalPlayer(),150) elseif (skin == 207) then setElementModel (getLocalPlayer(),209) elseif (skin == 288) then setElementModel (getLocalPlayer(),290) elseif (skin == 272) then setElementModel (getLocalPlayer(),274) else setElementModel (getLocalPlayer(),skin +1) end elseif (source == clothesshopCJwindowButtonLeft) then if (getElementModel (getLocalPlayer()) == 0) then local r,c = guiGridListGetSelectedItem (clothesshopCJwindowClothesGridlist) if (r) then local type = tonumber(guiGridListGetItemText (clothesshopCJwindowClothesGridlist,r,1)) if (type) then local type,id = getPedIndexClothes (getLocalPlayer(),type) setPedIndexClothes (getLocalPlayer(),type,id-1) end else exports.js_infowindow:showInfoWindow ("Select the clothes you want to change!") end else exports.js_infowindow:showInfoWindow ("You haven't got the CJ skin!\nGet that first before you go to get clothes!") end elseif (source == clothesshopCJwindowButtonRight) then if (getElementModel (getLocalPlayer()) == 0) then local r,c = guiGridListGetSelectedItem (clothesshopCJwindowClothesGridlist) if (r) then local type = tonumber(guiGridListGetItemText (clothesshopCJwindowClothesGridlist,r,1)) if (type) then local type,id = getPedIndexClothes (getLocalPlayer(),type) setPedIndexClothes (getLocalPlayer(),type,id+1) end else exports.js_infowindow:showInfoWindow ("Select the clothes you want to change!") end else exports.js_infowindow:showInfoWindow ("You haven't got the CJ skin!\nGet that first before you go to get clothes!") end end end end) addEvent ("openClothesShop",true) addEventHandler ("openClothesShop",getRootElement(), function() guiSetVisible (clothesshopStartWindow,true) showCursor (true,true) end) function getPedIndexClothes (player,type) local tstr,mstr = getPedClothes (player,type) if (tstr) then local type,index = getTypeIndexFromClothes (tstr,mstr) return type,index else return type,0 end end function setPedIndexClothes (player,type,index) if (index > 0) then local tstr,mstr = getClothesByTypeIndex (type,index) if tstr and mstr then triggerServerEvent ( 'pedClothes_SERVER', player, true, tstr, mstr, type ) end else triggerServerEvent ( 'pedClothes_SERVER', player, false, tstr, mstr, type ) end end جهة السيرفر : addEvent ( 'setElementModel_SERVER', true ) addEvent ( 'pedClothes_SERVER', true ) addEventHandler ( 'setElementModel_SERVER', root, function ( elm, model ) setElementModel ( elm, model ) end ) addEventHandler ( 'pedClothes_SERVER', root, function ( theBool, ... ) return _G [ theBool and 'addPedClothes' or 'removePedClothes' ] ( unpack ( { ... } ) ) end )1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
المود مفتوح المصدر للجميع أسمح للجميع بتغيير الحقوق أو تعديله, انا لم اضع اسمي على المود عند إنشاءه, أهم شيء اللي يفتحه يتعلم منه ويطور نفسه1 point
-
1 point
-
Always a solution: Reduce elementdata updates. Every time you call setElementData(without disabling synchronization), it will send data. (even if the value is the same) I often see people do this: (clientside) addEventHandler("onClientRender", root, function () local data = "random data" setElementData(localPlayer, "key", data) end) He, Frame 1: please update (16 ms later) Frame 2: please update (16 ms later) Frame 3: please update (16 ms later) Etc. Not even a second has past and you almost requested 62 UPDATES! (not sure if there is elementdata reduction clientside, but I don't think so) Which is IDIOTIC! (for the ones who do this, please go in your microwave) Which should/could be done like this: addEventHandler("onClientRender", root, function () local data = "random data" if data ~= getElementData(localPlayer, "key") then setElementData(localPlayer, "key", data) end end) Or this: (serverside) -- element could be a team for key, data in ipairs(example) do setElementData(element, "score", getElementData(element, "score") + 1) end Updating the score to 20? = Tell all clients/players 20x > "I have grown 1 more!" Which is stupid. Should/could be done like this. local score = getElementData(element, "score") or 0 for key, data in ipairs(example) do score = score + 1 end setElementData(element, "score", score)1 point
-
Hi everybody , dgs dx memo will released in the next version. Maybe the end of this month.1 point
-
0 points
-
الشخصية تتغير عند اللاعب فقط أظن ! إستعمل : -- Client triggerServerEvent -- Server addEvent addEventHandler setElementModel0 points