Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 22/02/24 in all areas

  1. Lua Language Server - Definition files The Lua language server is a powerful tool that enhances the development experience for Lua programming. It provides a comprehensive set of code editing features, including suggestions, auto-completion, and error checking. With the Lua language server, developers can effortlessly navigate through their resource files, access documentation easily, and ensure code correctness by giving warnings. Why should you care? The language server will inform you about all sorts of problems: type mismatches, missing function arguments, missing variables, etc. You have access to a lot of MTA syntax/autocomplete out of the box. The syntax information will remain while writing. You do not have to restart your resource so often in order to validate if everything is working. Type validation Having value type validation in your code editor is one of the main key features of the Lua Language Server. When working with variables, parameters, and arguments in Lua, you are not restricted to specific value types. This flexibility can make mistakes more likely to happen. However, being able to validate those mistakes instantly saves you a lot of time and frustration. Type annotations for your own functions Adding type annotations to your own functions can help improve validation and catch logic mistakes. It is particularly useful when calling functions from different parts of your code, as the annotations provide clarity on the expected input (arguments) and output (return values). Additionally, comments that are placed above or adjacent to a variable or function are visible when hovering over them in another file or line. This can provide helpful information and context when working with the code. How that looks like: How can I quickly add annotations in less than a second? Open the spoiler: AddEventHandler auto-complete Most MTA addEventHandler functions have full eventName autocompletion. And the attached anonymous function is fully autocompleted and typed as well. Navigation features of Lua Language Server It can be time consuming to find out where a (global) function or variable is located. Being able to jump right to it, saves you a lot of time. Other information which you can find in the readme Installation for the Lua Language Server How to use the definition files? Known issues Make sure to always have an empty new line at the end of your files, as recommended in this issue. Currently, the Lua server language definition files do not have a clear separation between serverside functions/events and clientside functions/events. However, it is possible to enforce this separation for specific functions if needed. outputChatBox--[[@as outputChatBox_server]]("Serverside", player) In certain cases, certain functions in the Lua server language definition files may return multiple types, even if you have selected a different syntax. To handle this situation, you can use the `cast` or `as` notation to explicitly specify the desired type or adjust the returned type. See `Casting and as` syntax below. Casting and as In certain situations, you may have a strong understanding of the type(s) that a variable or expression will have. This is where the keywords "cast" and "as" come into play. These keywords enable you to explicitly specify the intended type, ensuring proper type handling. local varName = exampleFunc() ---@cast varName string local varName = exampleFunc() ---@cast varName string | number local varName = exampleFunc() --[[@as string]] local varName = exampleFunc() --[[@as string | number]] Download The definition files can be downloaded here.
    3 points
  2. I opened a merge request to add two little client function defs that were missing
    1 point
  3. This is incredible. I use it with the VSCode Error Lens extension, it's so useful! https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens THANK YOU
    1 point
  4. After some testing i could just say: wow. Just for the sole fact of updated syntax this is amazing (although there is mistakes to be found), and the latter is just spicy addition.
    1 point
  5. تابل صحح الغلط ^ مشكور والشباب الباقين ماقصرو , وحياك الله ي صاحب الوضوع
    1 point
  6. نفس الخطأ الي صححته onClientGUIClick طيب مافيه مشكله هذا لاني نسخته ماني فاضي اكتبه ض1 + عندك غلط انت وكلاسيك accName = guiGetText ( اسم الايدت ) -- accName هنا موجود مايحتاج تتحقق منه if accName and accName ~= "" then يعني يصير مره وحده كذا if accName ~= "" then ميحتاج تتحقق منه لانه موجود اصلاً ذذ
    1 point
  7. نفس الخطأ الي صححته onClientGUIClick
    1 point
  8. #Client addEventHandler ( "onClientGUIClick", resourceRoot, function ( ) if ( source == اسم الزر ) then AccountName = guiGetText ( اسم الايديت ) if ( AccountName ~= "" ) then triggerServerEvent ( "GiveAdmin", localPlayer, AccountName ) end end end ) #Server addEvent ( "GiveAdmin", true ) addEventHandler ( "GiveAdmin", root, function ( AccountName ) if ( AccountName ) then aclGroupAddObject ( aclGetGroup ( "Admin" ), "user.".. AccountName ) end end )
    1 point
  9. addEventHandler ( "onClientGUIClick",resourceRoot, function ( ) if ( source == اسم الزر ) then AccName = guiGetText ( اسم الايديت ) if AccName and AccName ~= "" then triggerServerEvent ( "GiveAdmin", getRootElement(), AccName ) end end end )
    1 point
  10. -- #Client addEventHandler ( "onClinetGUIClick",resourceRoot, function ( ) if source == اسم الزر then AccName = guiGetText ( اسم الايديت ) if AccName and AccName ~= "" then triggerServerEvent ( "GiveAdmin", getRootElement(), AccName ) end end end ) -- #Server addEvent ( "GiveAdmin", true ) addEventHandler ( "GiveAdmin", getRootElement(), function ( Acc ) local Account = getAccount ( Acc ) if Account then aclGroupAddObject (aclGetGroup("Admin"), "user."..Account) end end ) ماجربته
    1 point
  11. حوسسه !!!! كيف حاط بالتريقر الفنكشن الي مسويه ؟ وحاط الاند قبل الافنت ومو مسوي addEventHandler بسيرفر ومو مسوي فنكشن وتتحقق ان الحساب الي بالايديت معه كونسل وبعدين تعطيه ادمن ؟ كودك كله خططاء
    1 point
  12. event : "onClientGUIClick" </p>\n<pre class=\"prettyprint lang-lua ipsCode\"> \nguiGetText \ntriggerServerEvent \naclGroupAddObject \naclGetGroup \n \n</pre>\n<div></div>\n<p>
    1 point
  13. As this question is mostly a server/scripting support question, it's been moved into a better place for best result . We are not able to help with unlocking/decrypting server assets here - you would have to use a backup key to do this yourself.
    0 points
×
×
  • Create New...