capitanazop Posted October 24, 2008 Share Posted October 24, 2008 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
RealistiC Posted October 24, 2008 Share Posted October 24, 2008 ohh Thank you man maybe i use this for my LVDM mode Link to comment
capitanazop Posted October 24, 2008 Author Share Posted October 24, 2008 but remember now is not finished and have errors ;D Link to comment
DiSaMe Posted October 24, 2008 Share Posted October 24, 2008 Nice, and if you made something with attack damage, that would show unique features of MTA And you could make some sequence for this to make infinite levels Link to comment
50p Posted October 26, 2008 Share Posted October 26, 2008 1. You use setAccountData(), don't use it untill DP3. 2. You getClientAccount() when he joins, his account is guest account until he logs in (I'm not sure if it would work if auto-login is enabled). Link to comment
lil Toady Posted October 28, 2008 Share Posted October 28, 2008 1. You use setAccountData(), don't use it untill DP3. You can safely use setAccountData, just check if user is logged in Link to comment
robhol Posted October 28, 2008 Share Posted October 28, 2008 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! 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
Simbad de Zeeman Posted October 28, 2008 Share Posted October 28, 2008 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. Link to comment
50p Posted October 28, 2008 Share Posted October 28, 2008 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
Simbad de Zeeman Posted October 28, 2008 Share Posted October 28, 2008 I had it working all the time on Linux & Windows. Link to comment
50p Posted October 28, 2008 Share Posted October 28, 2008 I had it working all the time on Linux & Windows. Then you're lucky. Link to comment
aralmo Posted October 31, 2008 Share Posted October 31, 2008 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
BrianNZ Posted November 15, 2008 Share Posted November 15, 2008 why dont you optamize the code by makeing the " you leveled up to level 2 change to something like you leveled up to level [current level+ 1] then you have unlimited levels, and just set a max level.... you could allso translate it to a percentage bar, eg 50/125 xp Link to comment
robhol Posted November 16, 2008 Share Posted November 16, 2008 Slightly off-topic here, but coding in non-english is incredibly bad practice, especially if you want help with your script. Link to comment
Playsinator Posted September 24, 2009 Share Posted September 24, 2009 Good Idea! Does someone have a ready-to-use-script of this? THX Playsi Link to comment
MOH Posted September 27, 2009 Share Posted September 27, 2009 Yes, I have finished the script. It wasn't hard I'll post it on the resource page when I have time. 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