أسرع طريقة تتعلم فيها الـ API هي سكربت يسوي شي واحد. هذا السكربت يضيف أمر /hello: يرحّب بالشخصية ويعطيها بخشيش بسيط، والمبلغ يحدده السيرفر.
- سوّ المجلد
سوّ مجلد
jrs_helloداخل مجلدresources. السكربت يحتاج بس ملف manifest وملف كود واحد. - اكتب الملفين
احفظ الاثنين UTF-8 بدون BOM، وإلا السيرفر يرفض يقرأ الـ manifest.
fxmanifest.luafx_version 'cerulean' game 'rdr3' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' lua54 'yes' server_script 'server.lua'server.lualocal JRS = exports.jrs_core:getCoreApi() RegisterCommand('hello', function(source) local character = JRS.GetCharacter(source) if not character then return end -- player is still on the character screen JRS.NotifyRightTip(source, 'Hello ' .. character.firstname, 4000) JRS.AddMoney(source, 5) -- server decides the amount end) - شغّله بعد الكور
أضف
ensure jrs_helloفي سطر لحاله تحتensure jrs_coreفيserver.cfg، سوّ ريستارت وادخل واكتب/hello.JRS.GetCharacterيرجّعnilإذا اللاعب لسا في شاشة الشخصيات، عشان كذا الأمر يتحقق منها أول.
المحرر#
أي محرر يمشي. لكن إضافة JRS Core لـ VS Code توفر عليك وقت كثير: حمّل jrs-core-vsc.vsix، افتح Extensions واضغط ... واختر Install from VSIX.
تعطيك إكمال تلقائي وشرح عند الوقوف على كل export وحدث في الكور، وsnippets للأكواد المتكررة، وثيم JRS Dark، وأمر يفتح هذا الموقع. اكتب JRS. أو exports.jrs_core: أو jrs- في ملف .lua عشان تتأكد إنها شغالة.
قبل ما تعطي فلوس أو أغراض من أحداثك، اقرأ كتابة سكربتات متينة.