Jump to content

[REQUEST]Creating a LvL System.


capitanazop

Recommended Posts

hi when im triying to create a LvL system example: you kills 5 players and level up to lvl 2 and if you are lvl 2 you hp is now 75 and you armor 15.

here is a part of the code, the idea is colaborate and complement the code, and i thinks that script have problem.

function cdm_playerWasted( totalAmmo, killer ) 
    setPlayerTeam ( source, nil ) 
    if ( killer) then 
        if ( killer ~= source ) then 
            setElementData( killer, "Kills", getElementData( killer, "Kills" ) + 1 ) 
            setElementData( source, "Deaths", getElementData( source, "Deaths") + 1 ) 
        else 
             
            setElementData( source, "Deaths", getElementData( source, "Deaths") + 1 ) 
        end 
  
        local kills = getElementData( killer, "Kills") 
        local maton = getClientName(killer) 
        if (kills == 2 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 2!", killer) 
        elseif (kills == 3 ) then 
            outputChatBox(""..maton.."Level Up! now you´re LvL 3!", killer) 
        elseif (kills == 5 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 4!", killer) 
        elseif (kills == 10 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 5!", killer) 
        elseif (kills == 15 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 6!", killer) 
        elseif (kills == 20 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 7!", killer) 
        elseif (kills == 25 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 8!", killer) 
        elseif (kills == 50 ) then 
            outputChatBox(""..maton.." Level Up! now you´re LvL 9!", killer) 
        end 
         
    else 
        setElementData( source, "Kills", getElementData( source, "Kills" ) - 1 ) 
        setElementData( source, "Deaths", getElementData( source, "Deaths") + 1 ) 
         
     

and for save that.

function onPlayerQuit ( ) 
  
      -- when a player leaves, store his current Score amount in his account data 
      local playeraccount = getClientAccount ( source ) 
      if ( playeraccount ) then 
            local playerScore = getPlayerScore ( source ) 
            setAccountData ( playeraccount, "exp.lvl", playerScore ) 
      end 
end 
  
function onPlayerJoin ( ) 
      -- when a player joins, retrieve his Score amount from his account data and set it 
      local playeraccount = getClientAccount ( source ) 
      if ( playeraccount ) then 
            local playerScore = getAccountData ( playeraccount, "exp.lvl" ) 
            -- make sure there was actually a value saved under this key (check if playerScore is not false). 
            -- this will for example not be the case when a player plays the gametype for the first time 
            if ( playerScore ) then 
                  setPlayerScore ( source, playerScore ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) 

if you find errors or u wanna add stuff,utils etc... to the script post it ;D.

bye n sorry for ma english

Link to comment
1. You use setAccountData(), don't use it untill DP3.

You can safely use setAccountData, just check if user is logged in

Oh sh1t, lil Toady posted in the forum! :shock:

So what you're saying is, it only freaks out and wipes all account data if the user's not logged in?

And it's XML-based, isn't it?

Link to comment
1. You use setAccountData(), don't use it untill DP3.

You can safely use setAccountData, just check if user is logged in

I don't know how many times I have to say that.. but why don't you check first (or second) version of my bank resource and see that people were complaining... I didn't want "not logged in" users to save their money so I had to check if they are logged in first. I will always tell people not to use setAccountData in DP2 because my "well known" bank resource was built with this and failed at the beginning.

1. You use setAccountData(), don't use it untill DP3.

You can safely use setAccountData, just check if user is logged in

Hmm that might explain why i never had problems with that in the beginning.

You must be one of those lucky guys. Maybe OS has got something to do with this, I don't know because I never had Linux, UNIX, etc. servers, so people be aware of accounts being wiped after setAccountData been used.

Link to comment

It works perfect to me too, but also had that problem.

When registering a player i was setting the email before login and it deleted the account's data, just moving a line within a if and it works now perfect. Btw im using a lot of variables inside account data.

Link to comment
  • 3 weeks later...
  • 10 months 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...