Jump to content

[experience+skills[Help]


banoka

Recommended Posts

hello dudes can you help me to add skills/stats to this system For example if EXP get, >= 1000 and <=1999 the skill of AK47 get 500.?

function win(ammo, killer, weapon, bodypart) 
    if (killer and getElementType(killer) == "player" and killer ~= source) then 
        local H = getElementData(killer, "EXP") or 0 
        local S = getElementData(killer, "LV") or 0 
        local noob = getPlayerName(source) 
        local experience = 200 
        setElementData(killer, "EXP", tonumber(H)+experience) 
        local H = tonumber(H) + experience 
        triggerClientEvent(killer, "onTestExp", killer, experience) 
        if (tonumber(H) >= 0 and tonumber(H) <=999) then 
            setElementData(killer, "LV", 1) 
            setElementData(killer, "experience.rank", "1") 
        elseif (tonumber(H) >= 1000 and tonumber(H) <=1999) then 
            setElementData(killer, "LV", 2) 
        elseif (tonumber(H) >= 2000 and tonumber(H) <=2999) then 
            setElementData(killer, "LV", 3) 
        elseif (tonumber(H) >= 3000 and tonumber(H) <=3999) then 
            setElementData(killer, "LV", 4) 

Link to comment
    function win(ammo, killer, weapon, bodypart) 
        if (killer and getElementType(killer) == "player" and killer ~= source) then 
            local H = getElementData(killer, "EXP") or 0 
            local S = getElementData(killer, "LV") or 0 
            local noob = getPlayerName(source) 
            local experience = 200 
            setElementData(killer, "EXP", tonumber(H)+experience) 
            local H = tonumber(H) + experience 
            triggerClientEvent(killer, "onTestExp", killer, experience) 
  
            local yourExperience = math.ceil (H/1000) 
                setElementData(killer, "LV", yourExperience) 
                setElementData(killer, "experience.rank", "1") 
        end 
    end 
                 

Divides your experience by one thosand (Seams to be what you were doing) then rounds it up to the nearest whole number.

Link to comment
    function win(ammo, killer, weapon, bodypart) 
        if (killer and getElementType(killer) == "player" and killer ~= source) then 
            local H = getElementData(killer, "EXP") or 0 
            local S = getElementData(killer, "LV") or 0 
            local noob = getPlayerName(source) 
            local experience = 200 
            setElementData(killer, "EXP", tonumber(H)+experience) 
            local H = tonumber(H) + experience 
            triggerClientEvent(killer, "onTestExp", killer, experience) 
  
            local yourExperience = math.ceil (H/1000) 
                setElementData(killer, "LV", yourExperience) 
                setElementData(killer, "experience.rank", "1") 
        end 
    end 
                 

Divides your experience by one thosand (Seams to be what you were doing) then rounds it up to the nearest whole number.

bro i dont get it!?

Link to comment
         
         
         
        function win(ammo, killer, weapon, bodypart) 
            if (killer and getElementType(killer) == "player" and killer ~= source) then 
                local H = getElementData(killer, "EXP") or 0 
                local S = getElementData(killer, "LV") or 0 
                local noob = getPlayerName(source) 
                local experience = 200 
                setElementData(killer, "EXP", tonumber(H)+experience) 
                local H = tonumber(H) + experience 
                triggerClientEvent(killer, "onTestExp", killer, experience) 
      
                local yourExperience = math.ceil (H/1000) 
                local gunExperience = (H/5)/5 
                  
                    setElementData(killer, "LV", yourExperience) 
                    setElementData(killer, "experience.rank",tostring(yourExperience)) 
                if gunExperience < 1001 then 
                        for i=69,79 do 
                    setPedStat (killer,i,gunExperience) 
                    end  
                end 
            end 
       end 
 end 
  

Should work, untested.

Link to comment
         
         
         
        function win(ammo, killer, weapon, bodypart) 
            if (killer and getElementType(killer) == "player" and killer ~= source) then 
                local H = getElementData(killer, "EXP") or 0 
                local S = getElementData(killer, "LV") or 0 
                local noob = getPlayerName(source) 
                local experience = 200 
                setElementData(killer, "EXP", tonumber(H)+experience) 
                local H = tonumber(H) + experience 
                triggerClientEvent(killer, "onTestExp", killer, experience) 
      
                local yourExperience = math.ceil (H/1000) 
                local gunExperience = (H/5)/5 
                  
                    setElementData(killer, "LV", yourExperience) 
                    setElementData(killer, "experience.rank",tostring(yourExperience)) 
                if gunExperience < 1001 then 
                        for i=69,79 do 
                    setPedStat (killer,i,gunExperience) 
                    end  
                end 
            end 
       end 
 end 
  

Should work, untested.

bro i uploaded the resources to this link (http://www.mediafire.com/download/t8ibe ... MTA_SA.zip) can you download it and fix it?!

Link to comment

Never mind, I messed up sorry. Set your server side to this

             
            
            
            function win(ammo, killer, weapon, bodypart) 
                if (killer and getElementType(killer) == "player" and killer ~= source) then 
                    local H = getElementData(killer, "EXP") or 0 
                    local S = getElementData(killer, "LV") or 0 
                    local noob = getPlayerName(source) 
                    local experience = 200 
                    setElementData(killer, "EXP", tonumber(H)+experience) 
                    local H = tonumber(H) + experience 
                    triggerClientEvent(killer, "onTestExp", killer, experience) 
          
                    local yourExperience = math.ceil (H/1000) 
                    local gunExperience = (H/5)/33 
                        setElementData(killer, "LV", yourExperience) 
                        setElementData(killer, "experience.rank",tostring(yourExperience)) 
                    if gunExperience < 1001 then 
                            setElementData(killer, "player.weaponExp",gunExperience) 
                            for i=69,79 do 
                        setPedStat (killer,i,gunExperience) 
                        end  
                    end 
                end 
           end 
     end 
      
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "LV", getAccountData(account, "LV") or "0") 
    setElementData(source, "EXP", getAccountData(account, "EEXP") or "0") 
    setElementData(source, "player.key", getAccountData(account, "player.key") or "Guest") 
    setElementData(source, "experience.rank", getAccountData(account, "experience.rank") or "Guest") 
    setElementData(source, "player.weaponExp", getAccountData(account, "player.weaponExp")) 
         if gunExperience < 1001 then 
               for i=69,79 do 
        setPedStat (killer,i,gunExperience) 
        end  
    end 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function onLogout (_,account) 
    setElementData(source, "LV", 0) 
    setElementData(source, "EXP", 0) 
    setElementData(source, "reputation.point", 0) 
    setElementData(source, "experience.rank", "Newbie") 
    setElementData(source, "player.key", "Guest") 
end 
addEventHandler ("onPlayerLogout", root, onLogout) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(thePlayer, "LV")) 
        setAccountData (theAccount, "EEXP", getElementData(thePlayer, "EXP")) 
        setAccountData (theAccount, "experience.rank", getElementData(thePlayer, "experience.rank")) 
        setAccountData (theAccount, "player.key", getElementData(thePlayer, "player.key")) 
        setAccountData (theAccount, "player.weaponExp", getElementData(thePlayer, "player.weaponExp")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 
 ---this is top of me 
  
addCommandHandler ( "setxp", 
    function ( thePlayer, _, who, EXP ) 
    if getElementData(thePlayer, "player.key") == "dashty123" then 
    if ( who ) then 
        local EXP = tonumber (EXP) or 0 
        local ThePlayer = getPlayerFromParticalName ( who ) 
        if ( ThePlayer ) then 
            setElementData( ThePlayer,"EXP",EXP ) 
            outputChatBox("Your XP has been set to "..EXP, ThePlayer, 255, 0, 0, true) 
        else 
            outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) 
    end 
    end 
    end 
) 
  
function getPlayerFromParticalName(thePlayerName) 
    local thePlayer = getPlayerFromName(thePlayerName) 
    if thePlayer then 
        return thePlayer 
    end 
    for _,thePlayer in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then 
            return thePlayer 
        end 
    end 
return false 
end 
  
function outputChange(dataName,oldValue) 
    if getElementType(source) == "player" and dataName == "experience.rank" and oldValue then  
        local newValue = getElementData(source,dataName) 
        outputChatBox("Congratulations you are Rank up #FFFFFF'"..'Just Do it'.."'",source, 255, 0, 0, true) 
        triggerClientEvent(source, "onClientRankUp", source) 
    end 
end 
addEventHandler("onElementDataChange",getRootElement(),outputChange) 
  
addEventHandler("onPlayerLogin", root, 
function(_, account) 
    if not getAccountData(account, "player.key") then 
        setElementData(source, "player.key", getAccountName(account)) 
        setAccountData(account, "player.key", getElementData(source, "player.key")) 
    else 
    end 
end) 
  
addEvent("addToTeam", true) 
addEventHandler("addToTeam", root, 
function (playername, teamname) 
local player = getPlayerFromName(playername or "") 
local team = getTeamFromName(teamname or "") 
    if player and team then 
        local r, g, b = getTeamColor ( team ) 
        setPlayerTeam(player, team) 
        setPlayerNametagColor ( player, r, g, b ) 
        outputChatBox("You have been moved to #FFFFFF"..getTeamName(team).."#FF0000.", player, 255, 0, 0, true) 
   end 
end) 
  
addEvent("kickFromTeam", true) 
addEventHandler("kickFromTeam", root, 
function (playername, teamname) 
local player = getPlayerFromName(playername or "") 
local team = getTeamFromName(teamname or "") 
    if player and team then 
        local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255) 
        setPlayerTeam(player, nil) 
        setPlayerNametagColor(player, red, green, blue) 
        outputChatBox("You have been kicked out of the #FFFFFF"..team.."#FF0000.", player, 255, 0, 0, true) 
    end 
end) 
  
addEvent("promotePlayer",true) 
addEventHandler("promotePlayer",root, 
function(playername, rank) 
local player = getPlayerFromName(playername or "") 
    if player then 
        if rank then 
            setElementData(player, "clan.rank", rank) 
            outputChatBox("You have been promoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) 
        end 
    end 
end) 
  
addEvent("DemotePlayer",true) 
addEventHandler("DemotePlayer",root, 
function(playername, rank) 
local player = getPlayerFromName(playername or "") 
    if player then 
        if rank then 
            setElementData(player, "clan.rank", rank) 
            outputChatBox("You have been demoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) 
        end 
    end 
end) 
  
function loopFix( thePlayer, _, who, lossp ) 
if getElementData(thePlayer, "player.key") == "vievsonic" then 
    if ( who ) then 
        local LossC = tonumber (lossp) or 0 
        local ThePlayer = getPlayerFromParticalName ( who ) 
            if ( ThePlayer ) then 
                setElementData( ThePlayer,"EXP",LossC ) 
            end 
        end 
    end 
end 
addCommandHandler ( "fixbug", loopFix) 
  
addEventHandler( 'onPlayerLogin', root, 
    function ( ) 
        local account = getPlayerAccount( source ) 
        if account and not isGuestAccount( account ) then 
            local accountName = getAccountName( account ) 
            if accountName == "dashty123" then 
                aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) 
                setElementData(source, "ACL", "Lui") 
            end 
       end 
    end 
) 
  
function RGBToHex(red, green, blue) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then 
        return nil 
    end 
    return string.format("#%.2X%.2X%.2X", red, green, blue) 
end 

Link to comment
Never mind, I messed up sorry. Set your server side to this
             
            
            
            function win(ammo, killer, weapon, bodypart) 
                if (killer and getElementType(killer) == "player" and killer ~= source) then 
                    local H = getElementData(killer, "EXP") or 0 
                    local S = getElementData(killer, "LV") or 0 
                    local noob = getPlayerName(source) 
                    local experience = 200 
                    setElementData(killer, "EXP", tonumber(H)+experience) 
                    local H = tonumber(H) + experience 
                    triggerClientEvent(killer, "onTestExp", killer, experience) 
          
                    local yourExperience = math.ceil (H/1000) 
                    local gunExperience = (H/5)/33 
                        setElementData(killer, "LV", yourExperience) 
                        setElementData(killer, "experience.rank",tostring(yourExperience)) 
                    if gunExperience < 1001 then 
                            setElementData(killer, "player.weaponExp",gunExperience) 
                            for i=69,79 do 
                        setPedStat (killer,i,gunExperience) 
                        end  
                    end 
                end 
           end 
     end 
      
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "LV", getAccountData(account, "LV") or "0") 
    setElementData(source, "EXP", getAccountData(account, "EEXP") or "0") 
    setElementData(source, "player.key", getAccountData(account, "player.key") or "Guest") 
    setElementData(source, "experience.rank", getAccountData(account, "experience.rank") or "Guest") 
    setElementData(source, "player.weaponExp", getAccountData(account, "player.weaponExp")) 
         if gunExperience < 1001 then 
               for i=69,79 do 
        setPedStat (killer,i,gunExperience) 
        end  
    end 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function onLogout (_,account) 
    setElementData(source, "LV", 0) 
    setElementData(source, "EXP", 0) 
    setElementData(source, "reputation.point", 0) 
    setElementData(source, "experience.rank", "Newbie") 
    setElementData(source, "player.key", "Guest") 
end 
addEventHandler ("onPlayerLogout", root, onLogout) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(thePlayer, "LV")) 
        setAccountData (theAccount, "EEXP", getElementData(thePlayer, "EXP")) 
        setAccountData (theAccount, "experience.rank", getElementData(thePlayer, "experience.rank")) 
        setAccountData (theAccount, "player.key", getElementData(thePlayer, "player.key")) 
        setAccountData (theAccount, "player.weaponExp", getElementData(thePlayer, "player.weaponExp")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 
 ---this is top of me 
  
addCommandHandler ( "setxp", 
    function ( thePlayer, _, who, EXP ) 
    if getElementData(thePlayer, "player.key") == "dashty123" then 
    if ( who ) then 
        local EXP = tonumber (EXP) or 0 
        local ThePlayer = getPlayerFromParticalName ( who ) 
        if ( ThePlayer ) then 
            setElementData( ThePlayer,"EXP",EXP ) 
            outputChatBox("Your XP has been set to "..EXP, ThePlayer, 255, 0, 0, true) 
        else 
            outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) 
    end 
    end 
    end 
) 
  
function getPlayerFromParticalName(thePlayerName) 
    local thePlayer = getPlayerFromName(thePlayerName) 
    if thePlayer then 
        return thePlayer 
    end 
    for _,thePlayer in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then 
            return thePlayer 
        end 
    end 
return false 
end 
  
function outputChange(dataName,oldValue) 
    if getElementType(source) == "player" and dataName == "experience.rank" and oldValue then  
        local newValue = getElementData(source,dataName) 
        outputChatBox("Congratulations you are Rank up #FFFFFF'"..'Just Do it'.."'",source, 255, 0, 0, true) 
        triggerClientEvent(source, "onClientRankUp", source) 
    end 
end 
addEventHandler("onElementDataChange",getRootElement(),outputChange) 
  
addEventHandler("onPlayerLogin", root, 
function(_, account) 
    if not getAccountData(account, "player.key") then 
        setElementData(source, "player.key", getAccountName(account)) 
        setAccountData(account, "player.key", getElementData(source, "player.key")) 
    else 
    end 
end) 
  
addEvent("addToTeam", true) 
addEventHandler("addToTeam", root, 
function (playername, teamname) 
local player = getPlayerFromName(playername or "") 
local team = getTeamFromName(teamname or "") 
    if player and team then 
        local r, g, b = getTeamColor ( team ) 
        setPlayerTeam(player, team) 
        setPlayerNametagColor ( player, r, g, b ) 
        outputChatBox("You have been moved to #FFFFFF"..getTeamName(team).."#FF0000.", player, 255, 0, 0, true) 
   end 
end) 
  
addEvent("kickFromTeam", true) 
addEventHandler("kickFromTeam", root, 
function (playername, teamname) 
local player = getPlayerFromName(playername or "") 
local team = getTeamFromName(teamname or "") 
    if player and team then 
        local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255) 
        setPlayerTeam(player, nil) 
        setPlayerNametagColor(player, red, green, blue) 
        outputChatBox("You have been kicked out of the #FFFFFF"..team.."#FF0000.", player, 255, 0, 0, true) 
    end 
end) 
  
addEvent("promotePlayer",true) 
addEventHandler("promotePlayer",root, 
function(playername, rank) 
local player = getPlayerFromName(playername or "") 
    if player then 
        if rank then 
            setElementData(player, "clan.rank", rank) 
            outputChatBox("You have been promoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) 
        end 
    end 
end) 
  
addEvent("DemotePlayer",true) 
addEventHandler("DemotePlayer",root, 
function(playername, rank) 
local player = getPlayerFromName(playername or "") 
    if player then 
        if rank then 
            setElementData(player, "clan.rank", rank) 
            outputChatBox("You have been demoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) 
        end 
    end 
end) 
  
function loopFix( thePlayer, _, who, lossp ) 
if getElementData(thePlayer, "player.key") == "vievsonic" then 
    if ( who ) then 
        local LossC = tonumber (lossp) or 0 
        local ThePlayer = getPlayerFromParticalName ( who ) 
            if ( ThePlayer ) then 
                setElementData( ThePlayer,"EXP",LossC ) 
            end 
        end 
    end 
end 
addCommandHandler ( "fixbug", loopFix) 
  
addEventHandler( 'onPlayerLogin', root, 
    function ( ) 
        local account = getPlayerAccount( source ) 
        if account and not isGuestAccount( account ) then 
            local accountName = getAccountName( account ) 
            if accountName == "dashty123" then 
                aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) 
                setElementData(source, "ACL", "Lui") 
            end 
       end 
    end 
) 
  
function RGBToHex(red, green, blue) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then 
        return nil 
    end 
    return string.format("#%.2X%.2X%.2X", red, green, blue) 
end 

Bro dont working,can you add to my system? the Skill?

Link to comment
local weaponSkill = math.floor(level/100 * 999)  

As simple as that.

if (tonumber(H) >= 0 and tonumber(H) <=999) then 
            setElementData(killer, "LV", 1) 
            setElementData(killer, "experience.rank", "1") 
        elseif (tonumber(H) >= 1000 and tonumber(H) <=1999) then 
            setElementData(killer, "LV", 2) 

dude its my system, i did use math.floor.

Link to comment
Ofc you did.

KhbHglF.png

That hurts, yet so true.

huh?

i meaning can you add skill weap to this system or you cant?

(tonumber(H) >= 0 and tonumber(H) <=999) then 
            setElementData(killer, "LV", 1) 
        elseif (tonumber(H) >= 1000 and tonumber(H) <=1999) then 
            setElementData(killer, "LV", 2) 
        elseif (tonumber(H) >= 2000 and tonumber(H) <=2999) then 
            setElementData(killer, "LV", 3) 

Link to comment
  • 3 weeks later...

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