Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 13/06/17 in Posts

  1. 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/bakaGaijin
    1 point
  2. Hi , i've updated the resource asm which i've added to the community since days Screenshot : About : This resource manages accounts security whether disable or enable the security for the account(s) + new feature ability to remove account(s) Features : * ability to secure / unsecure / remove / get status of account(s) * ability to find account(s) from the list - features with acs resource * securing accounts for everyone * secures account with owner serial * ability to unsecure the account for account owner himself Requirements : * You must add asm and acs resources to SuperModerator acl group for ability to remove account and kick player. * You must add yourself into the allowed group. Usage : Type /asm to open the gui , you must be in the allowed group (its console by default) Settings : * Allowed group is the allowed group to open the management gui * Hide offline accounts if this is set to true, offline accounts will not be listed. Download : https://community.multitheftauto.com/in ... ls&id=7339
    1 point
  3. السلام علكم و رحمة الله و بركاته مميزات الديربي- تقدر تعرف عدد الاعبين الي معاك بديربي واعلي حد للاعبين في الديربي هو 32- تقدر تعرف اسم الي دخل الديربي- تقدر تعرف كم من الوقت متبقي لبدأ الديربي من جديدالصور-- المود مكون من 3 اجزاء الاول المود و الثاني المكان و الثالث تأثيرات المابتحميل المودتحميل المكانتحميل المؤثيراتو السلام عليكم و رحمة الله و بركاته
    1 point
  4. table = { id , id } guiGridListAddRow guiGridListSetItemText getVehicleNameFromModel createMarker 'onClientMarkerHit' guiSetVisible 'onClientGUIClick' guiGridListGetSelectedItem guiGridListGetItemText triggerServerEvent table = { } addEvent addEventHandler getVehicleModelFromName createVehicle warpPedIntoVehicle
    1 point
  5. والله كفو شكرا لك
    1 point
  6. -- This is smaller example for select and get the data -- You Should Connect to ( your database ) with ( dbConnect ) -- And -- The ( DB ) will be the definition of ( dbConnect ) local table = "My Table"; local IsTomOnDatabase = dbExec(DB,"SELECT * FROM "..table.." WHERE jatekosnev=?",'cmdTommy') if #IsTomOnDatabase ~= 0 then -- this ( if ) will means if found cmdTommy in jatekosnev he will select it and return 1 or more outputChatBox(" CmdTommy is in table : ) ",root); outputChatBox(" And He is (X) :"..IsTomOnDatabase["X"],root); outputChatBox(" And He is (Y) :"..IsTomOnDatabase["Y"],root); outputChatBox(" And He is (Z) :"..IsTomOnDatabase["Z"],root); end
    1 point
  7. رتبه هههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههههه
    1 point
  8. @Gourmet. When I just started scripting I wrote this. You can't send the resources but you can send the data then display that in your gui. function getResourceData() local resources = {} local res = getResources() for k, resource in ipairs(res) do if getResourceInfo(resource, "type") ~= "map" then table.insert(resources, {name=getResourceName(resource), state=getResourceState(resource)}) end end triggerClientEvent("ResourcesTable", root, resources) end addEvent("ResourceList",true) addEventHandler("ResourceList",root,getResourceData) I'm assuming that's what you want.
    1 point
  9. انت اضغطت عمل ماب ؟!
    1 point
  10. Did you really ban yourself? You are fantastic! https://wiki.multitheftauto.com/wiki/RemoveBan
    1 point
  11. هذا الفنكشن مابيشتغل الى اذا انت في سيارة وتحركت بسرعة بأختصار هذا الفنكشن يعدل التشويش الي اذا انت في السيارة و مسرع
    1 point
  12. هي عبارة عن لون الخشب و شكله و انحضاره بماب الديربي
    1 point
  13. السلام عليكم و رحمة الله ورحمة الله و بركاتة ابي فريق لتجهيز سيرفر قريبا علي الاقل 5 و كمان 5 مصممين والسيرفر راح يكون هجولة مافي توزيع رتب و هاشغل الي يكون نشيط فعلا و يستاهل نعينه ادمن ورتبة واحدة بس غير كدا زائر يلعب و كدا ونهتم اكتر بتطوير السيرفر و اضافة الحصريات للزوار مب اهتمام للرتب الي معي يحط +1 و يروحله خاص السيرفر خلصت بنسبة 30 % و سويت 3 مهمات و سبورتر و بداية و اشياء كثيرة
    1 point
  14. اتوقع في فنكشن بأسم getAdminsByGroup ^ شيك عليه ويمكن يفيدك
    1 point
  15. أخص ي الرومنسيه ، أبدع أو قو أوت
    1 point
  16. فكرة جميلة بس لو تخليه بمميزات اكثر , راح يكون أجمل علعموم بتوفيق لك <3
    1 point
  17. @coNolel سيرفر ماستر مب هجولة و ما راح اذكر نوع الجيم مود او الشرح عنه لعدم سرقة الفكرة وانا قولت فوق هجولة و لو مافي غير فكرة ماستر ما بسرقها ماستر في القلب @Master_MTA
    1 point
  18. addEventHandler ( "onClientKey", root, function ( key ) if tostring(getElementData(getLocalPlayer(),"onCrossMap")) == "yes" then for i=1,4 do if key == "F"..i then cancelEvent ( ) end end for i=6,9 do if key == "F"..i then cancelEvent ( ) end end end end ) كود انا مسويه قديم , حطه في الكلاينت أو addEventHandler ( "onClientKey", root, function ( key ) if tostring(getElementData(getLocalPlayer(),"onCrossMap")) == "yes" then if key:find("F") or key == "p" or key == "b" then cancelEvent ( ) end end end )
    1 point
  19. ههه اشك اني المقصود +_+ حبيب قلبي ننايف <3
    1 point
  20. ماعتقد حد هيفيد ك روح انت صمم بنفسك احسن
    1 point
  21. كلام فاضي بما انك مبرمج ولك خبره بمجرد اي واحد يطلب منك مود ويعطيك مواصفاته بالكامل ماراح يصعب عليك انك تسويه هذا ان كنت مبرمج اما سالفة مبرمج هجولة ومبرمج زومبي اعرف ماعنده سالفة لان المبرمج يقدر يسوي اي سكربت بمجرد انه ياخذ الفكرة
    1 point
  22. This is a scripting section, meaning you're asking and searching for help of your own script, not requesting someone to script something for you. Please refer to this topic:
    1 point
  23. createColRectangle -- or createRadarArea "onClientRender" isElementWithinColShape -- ColRectangle isInsideRadarArea -- RadarArea setPlayerWeaponSlot
    1 point
  24. This is my server. The gui is made by dgs. ( I am bad in design sry)
    1 point
  25. Actually, that's Tommy Vercetti in our logo.
    1 point
  26. Hello Guys! I've made a simple SAUR Fun Theme for MTA you can use it aswell if you are fun of SAUR! Screenshots; http://s9.postimage.org/dkv3rkdjj/image.jpg http://s9.postimage.org/jzu4o8k9b/image.png Download Link: http://www.4shared.com/rar/h6JnE8xy/images.html How to install; Extract the rar file and replace the folder "Images" here; Program Files\MTA San Andreas 1.3\MTA\cgui\images http://www.saur.co
    1 point
×
×
  • Create New...