Jump to content

[Help]Levels


Wisin

Recommended Posts

Posted

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 )

Posted
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 )

Posted
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? :oops:

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Posted

Still same errors :oops:, and my account has that data "exp.lvl"

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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