• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Level 160,190,200, = automatic premium points

Axelor

Member
Joined
Sep 2, 2010
Messages
505
Reaction score
9
Hello,

when all players reach

level 160,

level 190,

and level 220,


they receive at level 160= 20 premium points
level 180 = 30 premium points
level 210= 30 premium points

Also when they received this level, there comes a whole broadcast on the server that he gained points and is level up.


Someone can help?

repp+
 
I understand you need to send the player a message?
Then try this (not tested, report bugs)
LUA:
local t, storage = {
	{160, 20},
	{180, 30},
	{210, 30},
}, 256
 
function onAdvance(cid, skill, oldLevel, newLevel)
	if skill ~= SKILL__LEVEL then
		return true
	end
	for i = 1, #t do
		local v = t[i]
		if newLevel >= v[1] and getCreatureStorage(cid, storage) < i then
			db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))
			doCreatureSetStorage(cid, storage, i)
			doPlayerSendTextMessage(cid, 19, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Premium Points!')
		end
	end
	return true
end


thanks to Cyko For a part of the script :P
 
Last edited:
Why don't you put 'break' when it's found? Why do you use '19' instead of constant (backward/forward compatibility)? Why don't you use just table indexes? You know this script is going to give the points only once, because after first advance (first with points receiving) player will have storage and on next premium advance he won't get anything?
 
Why don't you put 'break' when it's found?
if there's a player which already should've received points and the script is added only later, he won't receive all the points he should get the first time, but he would have to advance several levels (depends on how many he missed)
Why don't you use just table indexes?
ordering table indexes in sequential order takes less memory
/Lua object memory sizes
 
if there's a player which already should've received points and the script is added only later, he won't receive all the points he should get the first time, but he would have to advance several levels (depends on how many he missed)

Yeah, you got the point but what about comparign level to first table value and if it's just equal then break? That would save some iterations :P.

ordering table indexes in sequential order takes less memory
/Lua object memory sizes

Actually it's only few bytes and none cares about them in era of machines with shitloads of RAM, so gtfo with your 512 SDRAM PC.
 
Less than perfect just because it uses few bytes more? Then half of otland scripts should be already shitlisted if it's unacceptable, they're even more nonlegit.
i don't care about them since i haven't written those :p i want to be sure the stuff i post is atleast decent
also gb2choj chuju wyjebany
 
Back
Top