• 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!

Lua Ranks By Level [Rep++]

Alyhide

Banned User
Joined
Aug 21, 2010
Messages
1,945
Reaction score
55
Location
Switzerland
Hello, I am wondering if anybody can fix this script? I mean, it doesn't give ANY errors in console, it just simply, does not work.. What the script is supposed to do is once the player reaches level 100, it gives the rank 'Warlord of the Flame' to a character, along with a congratulations message and 100 crystal coins. It is also supposed to show in the player's description, after the guild, level,name,etc.​



Part 1:
LUA:
local t = {
	[100] = {id = 2160, count = 100, desc = "Warlord of the Flame"}
}
 
local storage = 7500
function onAdvance(cid, skill, oldLevel, newLevel)
	local i = t[newLevel]
	if skill == SKILL__LEVEL and newLevel == i and getCreatureStorage(cid, storage) < newLevel then
 
		local first = function()
			local reward = doCreateItemEx(i.id, i.count)
			if doPlayerAddItemEx(cid, reward, true) ~= RETURNVALUE_NOERROR then
				return false
			end
 
			doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Congratulations, you have reached level " .. i .. "! You are now ranked " .. i.desc .. ".")
			return true
		end
 
		if first then
			doCreatureSetStorage(cid, storage, newLevel)
		end
	end
 
	return true
end

Part 2:
LUA:
local t = {
	[100] = {"Warlord of the Flame"}
}
 
local storage = 7500
function onLook(cid, thing, position, lookDistance)
	return isPlayer(thing.uid) and doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " is ranked " .. t[getCreatureStorage(thing.uid, storage)][1] .. ".") and true
end
 
No errors in console, just stays that way.. :(
I'm using Crying Damson 0.3.6 [8.54]

Code:
15:13 You advanced from Level 99 to Level 100.
Code:
15:14 You see yourself. You are a druid.
 
Done :thumbup:

@Shin,
It's not such a good idea to make long scripts into one line, it doesn't do much of anything except allow you to make mistakes more easily. You could argue that it reacts faster but not really. :p

I do it for fun and to make scripts complicated, if you noticed they are a bit hard to read. Even harder to script the longer you go.
 
Back
Top