Wisin Posted April 4, 2010 Share Posted April 4, 2010 Hi mta forums, i wish someone could tell me whats wrong with my script and help me to fix it, i will post code here: function rank( killer ) local kills = getElementData( killer, "deaths") if (kills == 2 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 2!", killer) elseif (kills == 3 ) then outputChatBox(""..killer.."Level Up! now you´re LvL 3!", killer) elseif (kills == 5 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 4!", killer) elseif (kills == 10 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 5!", killer) elseif (kills == 15 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 6!", killer) elseif (kills == 20 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 7!", killer) elseif (kills == 25 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 8!", killer) elseif (kills == 50 ) then outputChatBox(""..killer.." Level Up! now you´re LvL 9!", killer) end end function onPlayerQuit ( quitType, reason, responsibleElement,thePreviousAccount ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then setAccountData ( playeraccount, "exp.lvl", playerScore ) end end function onPlayerLogin ( thePreviousAccount, theCurrentAccount, autoLogin ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playerScore = getAccountData ( playeraccount, "exp.lvl" ) if ( playerScore ) then end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ("onPlayerLogin", getRootElement(), onPlayerLogin) addEventHandler ( "onPlayerWasted", getRootElement(), rank ) Link to comment
karlis Posted April 4, 2010 Share Posted April 4, 2010 killlevels={2=2,3=3,5=3,10=5,15=6,20=7,25=8,50=9} function rank( _, killer ) local kills = getElementData( killer, "kills") setElementData(killer,"kills",kills+1) if killlevels[kills+1]~=nil then outputChatBox(""..killer.." Level Up! now you´re LvL "..killlevels[kills+1].."!", killer) end end function onPlayerQuit ( quitType, reason, responsibleElement,thePreviousAccount ) local playerScore = getElementData( source, "deaths") local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then setAccountData ( playeraccount, "exp.lvl", playerScore ) end end function onPlayerLogin ( thePreviousAccount, theCurrentAccount, autoLogin ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playerScore = getAccountData ( playeraccount, "exp.lvl" ) if ( playerScore ) then setElementData(source,"kills",playerScore) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ("onPlayerLogin", getRootElement(), onPlayerLogin) addEventHandler ( "onPlayerWasted", getRootElement(), rank ) Link to comment
Gamesnert Posted April 4, 2010 Share Posted April 4, 2010 Hi mta forums, i wish someone could tell me whats wrong with my script and help me to fix it, i will post code here: Please read the guidelines of the proper way to ask questions thoroughly and edit your post. Link to comment
Castillo Posted April 5, 2010 Share Posted April 5, 2010 killlevels={2=2,3=3,5=3,10=5,15=6,20=7,25=8,50=9} function rank( _, killer ) local kills = getElementData( killer, "kills") setElementData(killer,"kills",kills+1) if killlevels[kills+1]~=nil then outputChatBox(""..killer.." Level Up! now you´re LvL "..killlevels[kills+1].."!", killer) end end function onPlayerQuit ( quitType, reason, responsibleElement,thePreviousAccount ) local playerScore = getElementData( source, "deaths") local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then setAccountData ( playeraccount, "exp.lvl", playerScore ) end end function onPlayerLogin ( thePreviousAccount, theCurrentAccount, autoLogin ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playerScore = getAccountData ( playeraccount, "exp.lvl" ) if ( playerScore ) then setElementData(source,"kills",playerScore) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ("onPlayerLogin", getRootElement(), onPlayerLogin) addEventHandler ( "onPlayerWasted", getRootElement(), rank ) Your code gives me a error in line 1 expected near "=" Edit: i ve fixed that but now it gives 1 warning in line 4 and 1 error in line 5 saying line 4: Bad argument getElementData line 5: attempt to perform arithmetic on local "kills" (a boolean value) any help? Link to comment
karlis Posted April 5, 2010 Share Posted April 5, 2010 you need login first, and make sure your account already got such data try function onPlayerLogin ( thePreviousAccount, theCurrentAccount, autoLogin ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount(playeraccount) then local playerScore = getAccountData ( playeraccount, "exp.lvl" ) if ( playerScore ) then setElementData(source,"kills",playerScore) else setAccountData ( playeraccount, "exp.lvl",1 ) setElementData(source,"kills",1) end end end and try put tonumber() to all getElementData and accountdata results Link to comment
Castillo Posted April 5, 2010 Share Posted April 5, 2010 Still same errors , and my account has that data "exp.lvl" 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