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

[NPC] Skill Master

Mazen

Developer
Joined
Aug 20, 2007
Messages
612
Reaction score
38
Location
Sweden
Hello Otland!

This is a Skill Master NPC. It gives you rewards depending on what skill level you are. It's very configurable and filled with features.

Rewards Supported:
  • Items
  • Outfits
  • Money
  • Reputation (Based on storage ids)

If you wish to see more features in this NPC, just post your suggestions here.

Lua:
local config = {
	skills = {
		["fist"] = {id = 0, storage = 23001, name = "Fist Fighting",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {{6500, 20}, {5806, 1}},
					outfits = {32, 30},
					money = 1000,
					reputation = 5
				},
				{
					requirements = {storageid = 2, skill_level = 20},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["club"] = {id = 1, storage = 23002, name = "Club Fighting",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["sword"] = {id = 2, storage = 23003, name = "Sword Fighting",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["axe"] = {id = 3, storage = 23004, name = "Axe Fighting",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["distance"] = {id = 4, storage = 23005, name = "Distance Fighting",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["shielding"] = {id = 5, storage = 23006, name = "Shielding",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["fishing"] = {id = 6, storage = 23007, name = "Fishing",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["magic"] = {id = 7, storage = 23008, name = "Magic Level",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		},
		["level"] = {id = 8, storage = 23009, name = "Level",
			rewards = {
				{
					requirements = {storageid = 1, skill_level = 10},
					items = {},
					outfits = {},
					money = 0,
					reputation = 0
				}
			}
		}
	},
	
	main = {
		reputation_storage = 30000,
		rewardEffect = 40
	}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 		npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 							npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
	if (not npcHandler:isFocused(cid)) then
		return false
	end
	
	local message = msg
	local rewardGiven = false
	
	if config.skills[message] then
		local skl = config.skills[message]
		local p_skl = getPlayerSkillLevel(cid, skl.id)
		local r_skl = skl.rewards
		
		for _, reward in ipairs(r_skl) do
			if getPlayerStorageValue(cid, skl.storage) < reward.requirements.storageid then
				if p_skl >= reward.requirements.skill_level then
					-- Items
					if reward.items[1] then
						for _, item in ipairs(reward.items) do
							doPlayerAddItem(cid, item[1], item[2])
						end
					end
					
					-- outfits
					if reward.outfits[1] then
						for i = 1, #reward.outfits do
							doPlayerAddOutfit(cid, reward.outfits[i], 0)
						end
					end
					
					-- Money
					doPlayerAddMoney(cid, reward.money)
					
					-- Reputation
					local currentRep = getPlayerStorageValue(cid, config.main.reputation_storage)
					if currentRep == -1 then
						doPlayerSetStorageValue(cid, config.main.reputation_storage, 0)
					end
					doPlayerSetStorageValue(cid, config.main.reputation_storage, currentRep + reward.reputation)
					
					-- Reward Storage Id.
					doPlayerSetStorageValue(cid, skl.storage, reward.requirements.storageid)
					doSendMagicEffect(getPlayerPosition(cid), config.main.rewardEffect)
					rewardGiven = true
				else
					break
				end
			end
		end
		if rewardGiven then
			npcHandler:say("Congratulations!", cid)
		else
			npcHandler:say("You are not experienced enough to get any rewards for ".. skl.name:lower()..".", cid)
		end
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Download: UploadHyper (For including TABs and more comfortable scripting)

Have fun! :D
 
Last edited:
Can you make a phase system? When someone is level 300 he can change to level 1 again but is phase 2 and max phase is 3, and when is phase 3 the person will get like 500ccs

Is it possible to do? :)

That is not possible in LUA, sorry.

1 suggestion left!
 
Sportacus won!!

Check the first post for the script.

It's an NPC that will reward you for reaching a specified skill level. Reward types supported are: Reputation, items, money and outfits.
 
Sportacus won!!

Check the first post for the script.

It's an NPC that will reward you for reaching a specified skill level. Reward types supported are: Reputation, items, money and outfits.

Thank you Mazen! This is a big help for me, I really appreciate it.

I will post back after I test it on my server.

Again though, thank you for the help! :p
 
I get this error when i try spawn it;

[17/10/2010 15:00:21] [Error - LuaScriptInterface::loadFile] data/npc/scripts/skill master.lua:110: unexpected symbol near '='
[17/10/2010 15:00:21] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/skill master.lua
[17/10/2010 15:00:21] data/npc/scripts/skill master.lua:110: unexpected symbol near '='

Help fast please ;)
----->
If helped me, REP++
 
Back
Top