<event type="login" name="exp" script="exp.lua"/>
function onLogin(cid)
if getPlayerLevel(cid) <= 45 then
doPlayerAddExp(cid,1328800) -- not the best option.
doCreatureSay(cid, "You win 45 levels to play this server!", TALKTYPE_ORANGE_1)
end
return true
end
That's just like.. wrong! You can't use it like that you have to subtract it with something. Or it wont be precise.LUA:doPlayerAddExp(cid,1328800)
That's just like.. wrong! You can't use it like that you have to subtract it with something. Or it wont be precise.
Err... maybe a database query?
function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
dofile('./config.lua')
function onLogin(cid)
if getPlayerLevel(cid) < 45 then
local env, con
if sqlType == 'mysql' then
env = luasql.mysql()
con = env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort)
else
env = luasql.sqlite3()
con = env:connect(sqliteDatabase)
end
local cur = con:execute('SELECT `experience` FROM `players` WHERE `id` = ' .. getPlayerGUID(cid))
local row = cur:fetch({})
cur:close()
con:close()
env:close()
row = tonumber(row.experience)
if row then
doPlayerAddExp(cid, getExperienceForLevel(45) - row)
doCreatureSay(cid, 'You win 45 levels to play this server!', TALKTYPE_ORANGE_1)
end
end
return true
end
LUA:dofile('./config.lua') function onLogin(cid) if getPlayerLevel(cid) < 45 then local env, con if sqlType == 'mysql' then env = luasql.mysql() con = env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort) else env = luasql.sqlite3() con = env:connect(sqliteDatabase) end local cur = con:execute('SELECT `experience` FROM `players` WHERE `id` = ' .. getPlayerGUID(cid)) local row = cur:fetch({}) cur:close() con:close() env:close() row = tonumber(row.experience) if row then doPlayerAddExp(cid, getExperienceForLevel(45) - row) doCreatureSay(cid, 'You win 45 levels to play this server!', TALKTYPE_ORANGE_1) end end return true end
function onLogin(cid)
local stance = 1 -- the higher the stance the less looping it needs.
while getPlayerLevel(cid) < 45 do
doPlayerAddExp(cid, stance)
end
return true
end
forgot to include itthe getExperienceForLevel() function does not exist on 0.2.9
function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
function onLogin(cid)
local stance = 1 -- the higher the stance the less looping it needs.
while getPlayerLevel(cid) < 45 do
doPlayerAddExp(cid, stance)
end
return true
end