Jump to content

طلب شرح


Recommended Posts

شرح زاحف عن الداتا بقسم الدروس يكفي و يوفي يخوي

بس بعطيك مثالين على الاكاونت داتا ان شاء الله تفهم

واذا مافهمت اتبع شرح زاحف فهو افضل ومنسق بشكل رائع تقدر تفهم منه

والاكاونت داتا ماتختلف ابداً عن الداتا المنت الا ان الاكاونت داتا تحفظ على الحساب

والالمنت داتا تحفظ على الالمنت , لاعب او سيارة او ماركر او اوبجكت ...الخ

فهذي مثالين على الاكاونت داتا لعلك تعي وظيفتها

  
--[[ نسوي امر ]] addCommandHandler("giveAccountMoney", 
    function( p, cmd, money ) -- وظيفة مع البرامترز الخاصة ب الكوماند 
        if cmd and money then -- giveAccountMoney تحقق اذا كتب الامر و الفلوس زي كذا = الفلوس 
            local acc = getPlayerAccount(p) -- نجيب حساب اللاعب 
            if acc then -- نتحقق اذا الحساب موجود يعني اللاعب عنده حساب فعلاً 
                givePlayerMoney(p, tonumber(money)) -- نعطيه عدد فلوس بنفس اللي كتبها 
                setAccountData(acc, "Gold-Money", money) -- نحط الفلوس بأكاونت داتا 
            else return end 
        end 
    end 
) 
  
  
--[[ عند تسجيل الدخول ]] addEventHandler("onPlayerLogin", root, 
    function() 
        local acc = getPlayerAccount(source) 
        if acc then 
            local money = getAccountData(acc, "Gold-Money", money) -- نجيب الاكاونت داتا 
            local give = givePlayerMoney(source,tonumber(money)) -- نعطي اللاعب الفلوس بقيمة الداتا 
            if give then return outputChatBox("You have take golds for [ "..money.." ]", source) end 
        end 
    end 
) 
  

مثال 2

  
num = 0 
setTimer( 
    function() 
        local data = getElementData(root, "testdata") 
        if not data then 
            setElementData(v, "testdata", tostring(num)) 
            setAccountData(getPlayerAccount(v), "testdata", getElementData(v, "testdata")) 
            return outputChatBox(tostring(num), root) end 
        else 
            for _ , v in ipairs(getElementsByType("player")) do  
                num = num + 1 
                setElementData(v, "testdata", tostring(num)) 
                setAccountData(getPlayerAccount(v), "testdata", getElementData(v, "testdata")) 
                return outputChatBox(tostring(num), root) end 
            end 
        end 
    end, 
1000, 0) 
  

اما المثال الثاني فسويته على عجل وماني متاكد اصلاً هو شغال او لا

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...