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

Lua Easy creaturescript

Leeroyjenkinz

New Member
Joined
Jun 24, 2013
Messages
28
Reaction score
2
I actually tried searching, but couldn't find a creaturescript to send a player a message when he reaches level 100 saying congratulations

Anyone have a script/could direct me in the right direction?
 
This in creaturescripts.xml
XML:
<event type="advance" name="LevelUp" event="script" value="levelup.lua"/>

This in login.lua creaturescript/scripts under function onLogin.lua:
LUA:
registerCreatureEvent(cid, "LevelUp")

Now create new lua in creaturescripts/scripts and name it "levelup.lua" and paste the script below:
LUA:
local config = {
	level = 100,
	storage = 1001
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
 
	if(skill == SKILL__EXPERIENCE) then
		return true
	end
 
	if(newLevel < oldLevel) then
		return true 
	end
 
	if(newLevel == config.level and getPlayerStorageValue(cid, config.storage) < 1) then
		doPlayerSendTextMessage(cid,25, "You have reached level "..config.level..".")
		setPlayerStorageValue(cid, config.storage, 1)
	end
	return true
end
 
Last edited:
This in creaturescripts.xml
XML:
<event type="advance" name="LevelUp" event="script" value="levelup.lua"/>

This in login.lua creaturescript/scripts under function onLogin.lua:
LUA:
registerCreatureEvent(cid, "LevelUp")

Now create new lua in creaturescripts/scripts and name it "levelup.lua" and paste the script below:
LUA:
local config = {
	level = 100,
	storage = 1001
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
 
	if(skill == SKILL__EXPERIENCE) then
		return true
	end
 
	if(newLevel < oldLevel) then
		return true 
	end
 
	if(newLevel == config.level and getPlayerStorageValue(cid, config.storage) < 1) then
		doPlayerSendTextMessage(cid,25, "You have reached level "..config.level..".")
		setPlayerStorageValue(cid, config.storage, 1)
	end
	return true
end
This is giving me that message when I reach axing 20, or sword 20, or any skill 20 :(
 
sorry, It does nothing now.

Do you think this is the reason?

enums.h
enum skills_t {
SKILL_FIRST = 0,
SKILL_FIST = SKILL_FIRST,
SKILL_CLUB = 1,
SKILL_SWORD = 2,
SKILL_AXE = 3,
SKILL_DIST = 4,
SKILL_SHIELD = 5,
SKILL_FISH = 6,
SKILL_LAST = SKILL_FISH
};

That there is no skill for experience?

But however, in enum levelTypes_t {

There is LEVEL_EXPERIENCE (which i've already tried)
enum levelTypes_t {
LEVEL_FIRST = 0,
LEVEL_SKILL_FIST = LEVEL_FIRST,
LEVEL_SKILL_CLUB = 1,
LEVEL_SKILL_SWORD = 2,
LEVEL_SKILL_AXE = 3,
LEVEL_SKILL_DIST = 4,
LEVEL_SKILL_SHIELD = 5,
LEVEL_SKILL_FISH = 6,
LEVEL_MAGIC = 7,
LEVEL_EXPERIENCE = 8,
LEVEL_LAST = LEVEL_EXPERIENCE
};
 
LUA:
local t = {
	39001, {
	[100] = {"Congratulations, you have reached level 100!", 1},
	[200] = {"Congratulations, you have reached level 200!", 2},
	[300] = {"Congratulations, you have reached level 300!", 3}
	}
}
function onAdvance(cid, skill, oldlevel, newlevel)
	if skill == SKILL__LEVEL then
		for level, v in pairs(t[2]) do
			if oldlevel < level and getPlayerLevel(cid) >= level and getPlayerStorageValue(cid, t[1]) < v[2] then
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, v[1])
				setPlayerStorageValue(cid, t[1], v[2])
			end
		end
	end
	doPlayerSave(cid, true) 
	return true
end
 
LUA:
local t = {
	39001, {
	[100] = {"Congratulations, you have reached level 100!", 1},
	[200] = {"Congratulations, you have reached level 200!", 2},
	[300] = {"Congratulations, you have reached level 300!", 3}
	}
}
function onAdvance(cid, skill, oldlevel, newlevel)
	if skill == SKILL__LEVEL then
		for level, v in pairs(t[2]) do
			if oldlevel < level and getPlayerLevel(cid) >= level and getPlayerStorageValue(cid, t[1]) < v[2] then
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, v[1])
				setPlayerStorageValue(cid, t[1], v[2])
			end
		end
	end
	doPlayerSave(cid, true) 
	return true
end
Still nothing, waaaaah.

Appreciate the help regardless :)
 
Back
Top