• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lock Level

vegaseek

Member
Joined
Dec 11, 2010
Messages
146
Reaction score
8
Hi! I need the following script into TFS 0.4: If a player logs in Levels lower than 45 will automatically set it exp / hp / mana / cap on the 45th level
 
#edit.

XML:
<event type="login" name="exp" script="exp.lua"/>
/\ THIS THE SHIT

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
 
Last edited:
Lua:
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
 
Last edited:
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

the getExperienceForLevel() function does not exist on 0.2.9

yet you could do it this way (worst case solution)
Lua:
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

This is as said a worse solution, but without the needed functions the only option I would say.



kind regards, Evil Hero.
 
ahh well, noticed that it wasn't made in c++
Lua:
function getExperienceForLevel(lv)
	lv = lv - 1
	return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end



kind regards, Evil Hero.
 
Code:
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

The script works. But I would ask for small change. Look:

viu7b5.jpg


I would like script to give experience to the 45 level. And do not lvl: 41/42/43/44/45 ... This is a very slow system.

I need this for something! Don't spam for Deafult!

kma1th.jpg
 
Last edited:
Back
Top