Jump to content

اهلاا ممكن تضبطولي ها الكود


Recommended Posts

السلامم عليكم

ورحمة الله وبركاته

الزبده

انا عندي مود الفل

و ابي اخليه يعني

الي يبي يركب سياره يكون لفله

5

لو ممكن

الكود

حق الفل الي معي

الكود الاول

level_server

local ExpRewardForKill = {1, 8}  
  
  
  
local levels = {} 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        connection = dbConnect( "sqlite", "levels.db" ) 
        --exports["scoreboard"]:scoreboardAddColumn ( "level", root, 90, "Player's Level") 
        if ( connection )then 
            dbExec ( connection, "CREATE TABLE IF NOT EXISTS levels (levelID INTEGER PRIMARY KEY NOT NULL, accountName TEXT, level INT, experience INT)" ) 
            outputDebugString ( "Successfully connected to levels.db" ) 
        else 
            outputDebugString ( "Failed to connect to levels.db", 3 ) 
        end 
         
        local LivelsFile = xmlLoadFile ( "levels.xml" ) 
        if ( LivelsFile ) then 
            outputDebugString ( "levels.xml successfully open") 
            for index, levelData in ipairs ( xmlNodeGetChildren ( LivelsFile ) ) do 
                local levelAttributes = xmlNodeGetAttributes ( levelData ) 
                table.insert(levels, { ["levelName"] = levelAttributes.levelName, ["experienceRequired"] = tonumber(levelAttributes.experienceRequired), ["moneyReward"] = tonumber(levelAttributes.moneyReward)}) 
            end 
        else 
            outputDebugString ( "Failed to open to levels.xml", 1 ) 
        end 
         
         
    end 
) 
  
  
--[[ 
addCommandHandler ( "level", 
    function ( thePlayer ) 
        removeElementData(thePlayer,"experience") 
        removeElementData(thePlayer,"level") 
    end 
) 
]] 
  
  
addEventHandler("onResourceStop",resourceRoot, 
    function ( ) 
        if isElement ( connection ) then  
            setTimer(destroyElement, 1000, 1, connection ) 
        end 
    end 
) 
  
addEventHandler("onResourceStop",resourceRoot, 
function () 
    for index, player in ipairs(getElementsByType("player")) do 
        local experience = tonumber(getElementData(player,"experience")) or 0 
        setPlayerExperience(player, experience) 
        local PlayerLevel = tonumber(getElementData(player,"level")) or 1 
        setPlayerLevel(player, PlayerLevel) 
    end 
end) 
  
function saveExpOnQuitOrLogout(account) 
    local experience = tonumber(getElementData(source,"experience")) or 0 
    local PlayerLevel = tonumber(getElementData(source,"level")) or 1 
    if (experience) then 
        if (account and account == "userdata") then 
            setPlayerExperience(account, experience) 
            setPlayerLevel(account, PlayerLevel) 
        else 
            setPlayerExperience(source, experience) 
            setPlayerLevel(source, PlayerLevel) 
        end 
    end 
    setElementData(source,"experience",0) 
end 
addEventHandler("onPlayerLogout",root,saveExpOnQuitOrLogout) 
addEventHandler("onPlayerQuit",root,saveExpOnQuitOrLogout) 
  
  
function CheckLevelFromExp(dataName) 
    if (source and getElementType(source) == "player" and dataName == "experience") then 
        local SourceLevel = tonumber( getElementData(source,"level") ) 
        local SourceExp = tonumber( getElementData(source,"experience") ) 
        local NewLvl = SourceLevel+1 
        if ( levels[sourceLevel] ) then 
            if ( levels[NewLvl]) then 
                local RequiredExp = tonumber( levels[sourceLevel]["experienceRequired"] ) 
                if ( SourceExp >= RequiredExp ) then 
                    setElementData(source,"experience_n", tonumber(levels[NewLvl]["experienceRequired"])) 
                    setElementData(source,"level",NewLvl) 
                    setTimer(setElementData, 50, 1, source,"experience",0) 
                    givePlayerMoney(source,tonumber(levels[NewLvl].moneyReward)) 
                    triggerClientEvent ( source, "LevelUpEffect", source ) 
                    outputChatBox("*LEVEL UP* You're now level ".. tostring(NewLvl) .."! Congratulations.",source,0,255,0) 
                end 
            end 
        end 
    end 
end 
addEventHandler("onElementDataChange",root,CheckLevelFromExp) 
  
function OnZombieKill (killer) 
    if (killer and killer ~= source) then 
        if getPlayerAccount(killer) then 
            local experience = tonumber(getElementData(killer,"experience")) 
            local SourceLevel = getElementData(killer,"level") 
            if ( not SourceLevel ) then  
                SourceLevel = 1  
                setElementData(killer,"level",1)  
            end 
            if ( levels[sourceLevel+1] ) then 
                local randomExperience = math.random(unpack(ExpRewardForKill)) 
                if (experience) then 
                    setElementData(killer,"experience",experience+tonumber(randomExperience)) 
                else 
                    setElementData(killer,"experience",randomExperience) 
                end 
            else 
                setElementData(killer,"experience",tonumber(levels[sourceLevel]["experienceRequired"])) 
            end 
        end 
    end 
end 
addEvent("onZombieWasted",true) 
addEventHandler ("onZombieWasted", root, OnZombieKill) 
  
  
addEventHandler("onPlayerLogin",root, 
function (_,account) 
    local accountName = getAccountName(account) 
    local handler = connection 
    local query = dbQuery( handler, "SELECT accountName FROM levels WHERE accountName=?", tostring(accountName) ) 
    local result, numrows, errmsg = dbPoll ( query, -1 ) 
    if ( type( result ) == "table" and #result == 0 or not result ) then 
        if dbExec( handler, "INSERT INTO `levels` (`levelID`, `accountName`, `level`, `experience`) VALUES (NULL, '".. accountName .."', '1', '0');") then 
            setElementData(source, "experience", 0) 
            setElementData(source, "experience_n", tonumber(levels[1].experienceRequired)) 
            setElementData(source, "level", 1) 
        end 
    else 
        local level = getPlayerLevel(source) 
        setElementData(source, "experience", getPlayerExperience(source)) 
        if (levels[level]) then 
            setElementData(source, "experience_n", tonumber(levels[level].experienceRequired)) 
        else 
            setElementData(source, "experience_n", tonumber(levels[level -1].experienceRequired)) 
        end 
        setElementData(source, "level", level) 
    end 
end) 
  
  
  
function getPlayerLevel(thePlayer) 
    local handler = connection 
    if (isElement(thePlayer) and getElementType(thePlayer) == "player") then 
        account = getPlayerAccount(thePlayer) 
    else 
        account = thePlayer 
    end 
    if (not account or isGuestAccount(account)) then return false end 
    local accountName = getAccountName(account) 
    local query = dbQuery( handler, "SELECT level FROM `levels` WHERE accountName='".. tostring(accountName) .."'") 
    local result, numrows, errmsg = dbPoll( query, -1 ) 
    if (result) then 
        return tonumber(result[1]["level"]) 
    end 
end 
  
function setPlayerLevel(thePlayer, theLevel) 
    local handler = connection 
    if (isElement(thePlayer) and getElementType(thePlayer) == "player") then 
        account = getPlayerAccount(thePlayer) 
    else 
        account = thePlayer 
    end 
    if (not account or isGuestAccount(account)) then return false end 
    local accountName = getAccountName(account) 
    if dbExec( handler, "UPDATE `levels` SET `level` = '" .. tonumber(theLevel) .. "' WHERE `accountName` = '" .. tostring(accountName) .."'" ) then 
        return true 
    else 
        return false 
    end 
end 
  
function getPlayerExperience(thePlayer) 
    local handler = connection 
    if (isElement(thePlayer) and getElementType(thePlayer) == "player") then 
        account = getPlayerAccount(thePlayer) 
    else 
        account = thePlayer 
    end 
    if (not account or isGuestAccount(account)) then return false end 
    local accountName = getAccountName(account) 
    local query = dbQuery( handler, "SELECT experience FROM `levels` WHERE accountName='".. tostring(accountName) .."'") 
    local result, numrows, errmsg = dbPoll( query, -1 ) 
    if (result) then 
        return tonumber(result[1]["experience"]) 
    end 
end 
  
function setPlayerExperience(thePlayer, theExperience) 
    local handler = connection 
    if (isElement(thePlayer) and getElementType(thePlayer) == "player") then 
        account = getPlayerAccount(thePlayer) 
    else 
        account = thePlayer 
    end 
    if (not account or isGuestAccount(account)) then return false end 
    local accountName = getAccountName(account) 
    if dbExec( handler, "UPDATE `levels` SET `experience` = '" .. tonumber(theExperience) .. "' WHERE `accountName` = '" .. tostring(accountName) .."'" ) then 
        return true 
    else 
        return false 
    end 
end 

الكود الثاني

level_client

local sx, sy = guiGetScreenSize() 
  
function drawExperience() 
    dxDrawRectangle((310/1024)*sx,(698/768)*sy,(481/1024)*sx,(36/768)*sy,tocolor(255,255,255,35),false) 
    dxDrawRectangle((315/1024)*sx,(703/768)*sy,(472/1024)*sx,(26/768)*sy,tocolor(0,0,0,255),false) 
    local experience = getElementData(localPlayer,"experience") or 0 
    local experience_n = getElementData(localPlayer,"experience_n") or 0 
    local level = getElementData(localPlayer,"level") or 1 
    local percent = (experience / experience_n * 100) 
    if (percent >= 100) then 
        percent = 100 
    elseif (experience_n < 1) then 
        percent = 0 
    end 
    dxDrawRectangle((320/1024)*sx,(706/768)*sy,(tonumber(percent)*4.64/1024)*sx,(20/768)*sy,tocolor(255,255,255,75),false) 
    dxDrawBorderedText("Level: ".. tostring(level) .." | Experience Points: ".. tostring(experience) .." > ".. tostring(experience_n),(430/1024)*sx,(707/768)*sy,(667/1024)*sx,(724/768)*sy,tocolor(0,0,0,255),(sx/1024)*0.6,"bankgothic","center","center",false,false,false) 
end 
addEventHandler("onClientRender",root,drawExperience) 
  
function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) 
    dxDrawText ( text, x - 1, y - 1, w - 1, h - 1, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black 
    dxDrawText ( text, x + 1, y - 1, w + 1, h - 1, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x - 1, y + 1, w - 1, h + 1, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x + 1, y + 1, w + 1, h + 1, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x - 1, y, w - 1, h, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x + 1, y, w + 1, h, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y - 1, w, h - 1, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y + 1, w, h + 1, tocolor ( 255, 255, 255, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) 
end 
  
  
  
addEvent ( "LevelUpEffect", true ) 
addEventHandler ( "LevelUpEffect", root, 
    function ( ) 
        PlayerLevelUpSound() 
        addEventHandler("onClientRender",root,DrawLevelUp) 
        setTimer(function() 
            removeEventHandler("onClientRender",root,DrawLevelUp) 
        end, 4000, 1) 
    end 
) 
  
function PlayerLevelUpSound() 
    local sound = playSound("levelup.mp3") 
    setSoundVolume(sound, 1) 
end 
  
function DrawLevelUp() 
    dxDrawBorderedText( "LEVEL UP!!!", sx/2, sy/15, sx/2, sx/2, tocolor(255,144,0,255),(sx/1024)*2.5,"bankgothic","center","center",false,false,false ) 
end 
  
  

Link to comment

انا قلت

انا صنعته ؟ ؟ ؟

ادري انه باك اب من اليويتوب بعد

--------------------------------------------

الفكنشات الي عطيتوني اياها استخدمتها كلها ما ضبطت

لو ممكن تعطوني الكود المعدل عليهه

Link to comment
طيب هو نزل باك اب يعني عادي

لو ما يبي كان ما نزل

افف

افهم فيه واحد اجنبي معه سيرفر وجا واحد عربي وزرفه ونشره فهمت؟

يعني لو جا صاحب السيرفر الي انسرق منه الباك اب وسمح له بنساعده بأذن الله

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

نتمنى من المشرفين حذف الموضوع- :roll:

Link to comment

فيه كثير مودات اللفل شوف هذا كويس وفيه فنكشنات واحداث تساعدك اذا كنت تبي تسويه بـ لوحة او دي اكس ع الشاشه او لبل

https://community.multitheftauto.com/index.php?p= ... ls&id=1253

وهذي صفحة فنكشناته واحداثه بالويكي

https://wiki.multitheftauto.com/wiki/Resource:Exp_system

وهذا مود لفل ثاني

https://community.multitheftauto.com/in ... ls&id=5719

وهذا اللفل حقك بالسكور بورد

https://community.multitheftauto.com/in ... ls&id=7660

وهذا طلبك اللفل سستم حق العقرب <--

https://community.multitheftauto.com/in ... ls&id=4169

وهذا يجيب لك اللفل حقك تحت الشاشه

https://community.multitheftauto.com/in ... ls&id=7731

وهذا يجيب لك اللفل بس مادري وين بالشاشه

https://community.multitheftauto.com/in ... ls&id=6143

Link to comment
مشكور و اقدر تعبككك

لاكن كلهم ماقدر اخليه يعني يكرب السياره يكون لفله 5

اتمنى انكم تساعدوني

https://community.multitheftauto.com/index.php?p= ... ls&id=1253

وهذي صفحة فنكشناته واحداثه بالويكي

https://wiki.multitheftauto.com/wiki/Resource:Exp_system

شوف صفحة الفنكشنات بالويكي فيه تأكد من لفل اللاعب

+ حدث

"onVehicleStartEnter"

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...