ivor Posted March 13, 2016 Author Share Posted March 13, 2016 تفضل 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 OnPlayerKill (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("onPlayerWasted",true) addEventHandler ("onPlayerWasted", root, OnPlayerKill) 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 Link to comment
Me[Z]oO Posted March 13, 2016 Share Posted March 13, 2016 يب فهمت انا فالمود حقي في 3 ملفات server.luac = مشفر والى سواه صديقي level_server.lua = انا الى سويته وهوا عباره عن تريقرات و تحقق اذا اللاعب اترقي يشغل لفل اب ايفيكت الى بـ كلينت و يحفظ بيانات اللفل وكذا level_client.lua = تصميم اللفل و لفل اب ايفيكت احط كودك وين ؟ طيب سؤال سويت مود اللفل كله وربطه بقاعدة بيانات ومو عارف تسوي طلبك ذا ؟ . مود اللفل حق وسيم Link to comment
ivor Posted March 13, 2016 Author Share Posted March 13, 2016 انت الوحيد الى اتكلم ؟ مسوي نفسك ابو العريف ؟ شوف سيرفرك وكلمني Link to comment
Me[Z]oO Posted March 13, 2016 Share Posted March 13, 2016 https://forum.multitheftauto.com/viewtopic.php?f=160&t=97196 https://forum.multitheftauto.com/viewtopic.php?f=160&t=96918 بنزل اكواد مسروقة لعرب كوم واقول بمسحها لحقوقي الشخصية وما باخد من الفري روم اكواد وانزلها بتحدي الاول حق البرو سفن Link to comment
ivor Posted March 13, 2016 Author Share Posted March 13, 2016 مود الرشوة سويته انا والله ثاني شئ اكواد التوب بشوف غيرها وللمرة الثانية شوف سيرفرك بدل ماتشحت الزوار وتربط سيرفرات :] ترا انت تسببت ب ذا كله لنفسك لأنك خائن , نسيت اننا بالمنتدي Link to comment
Me[Z]oO Posted March 13, 2016 Share Posted March 13, 2016 هههههههههههه طير بس قال مسوي اللفل كامل ومو عارف تسوي طلبك ي رقل قل شي معقول Link to comment
ivor Posted March 13, 2016 Author Share Posted March 13, 2016 و لك تعليقاتك مالها لازمه لان ماراح تسد معي يلا روح انقلع شوفلك مكان مجرد نوبات يزودون مشاركات فقط -_+ Link to comment
#Soking Posted March 14, 2016 Share Posted March 14, 2016 Error صار سمعتك بالارض انا لو مكانك اعتزل هههههههه يب ولله لان خلاص الكل يعرف العيبك 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