moF Posted June 19 Share Posted June 19 (edited) addCommandHandler("Health", function(playerSource,commandName,id) if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("Health")) then if(id) then local playerID = tonumber(id) if(playerID) then local targetPlayer, targetPlayerName = getPlayerID(playerID) if targetPlayer then setElementHealth ( targetPlayer, 100 ) else end end end end end ) كود صحيح ؟؟ Edited June 20 by xLive تعديل التنسيق Link to comment
Scripting Moderators xLive Posted June 20 Scripting Moderators Share Posted June 20 (edited) تم نقل موضوعك إلى قسم البرمجة باللغة العربية، الرجاء استعمال هذا القسم مستقبلًا إذا كودك في جانب الخادم يعتبر صحيح getPlayerID لكن بشرط إن دالة موجودة وتعمل لأن هذي الدالة غير موجودة باللعبة، المفترض تكون مُعرفة في الكود عندك Edited June 20 by xLive Link to comment
NotAnyOne Posted August 25 Share Posted August 25 (edited) local playerIDs = {} function generateUniqueID() local id repeat id = math.random(1, 9999) until not playerIDs[id] return id end addEventHandler("onPlayerJoin", root, function() local id = generateUniqueID() playerIDs[id] = source setElementData(source, "ID", id) outputChatBox("تم تعيين ID الخاص بك: " .. id, source, 0, 255, 0) end) addEventHandler("onPlayerQuit", root, function() local id = getElementData(source, "ID") if id then playerIDs[id] = nil end end) function getPlayerFromID(id) for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "ID") == id then return player end end return nil end addCommandHandler("Health", function(playerSource, commandName, id) if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Health")) then if (id) then local playerID = tonumber(id) if (playerID) then local targetPlayer = getPlayerFromID(playerID) if targetPlayer then setElementHealth(targetPlayer, 100) outputChatBox("تم تعيين الصحة إلى 100 لـ " .. getPlayerName(targetPlayer), playerSource, 0, 255, 0) else outputChatBox("لم يتم العثور على لاعب بهذا الـ ID.", playerSource, 255, 0, 0) end else outputChatBox("الـ ID غير صحيح.", playerSource, 255, 0, 0) end else outputChatBox("يرجى تحديد ID اللاعب.", playerSource, 255, 0, 0) end else outputChatBox("ليس لديك الصلاحية لاستخدام هذا الأمر.", playerSource, 255, 0, 0) end end ) Edited August 25 by NotAnyOne Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now