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

[MOD] Professions System

Collz

Pandas Go RAWR!!!
Joined
Oct 10, 2008
Messages
2,091
Reaction score
57
Location
New York
This script was originally created by Teckman. I converted it into a Mod. So all credits goes to the original scripter.

Make a new file in the Mods folder called professions.xml and add this
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Professions System" enabled="yes">
	<action itemid="2550;2566;2422;2553" event="script"><![CDATA[
local professions = {
	["herbalism"] = {storage = 1030, maxSkill = 550},
	["mining"] = {storage = 1031, maxSkill = 400},
	["skinning"] = {storage = 1032, maxSkill = 500}
}
 
local recipes = {
	-- herbalism (herbs)
	[2740] = {tool = 2550, skill = 0, loot = {{2801, 4}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2767] = {tool = 2550, skill = 20, loot = {{2804, 4}, {2803, 7}, {2799, 4}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2771] = {tool = 2550, skill = 60, loot = {{2801, 4}, {2802, 4}, {2804, 5}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2741] = {tool = 2550, skill = 150, loot = {{2800, 6}, {2802, 4}, {2803, 5}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2768] = {tool = 2550, skill = 250, loot = {{2801, 7}, {2803, 5}, {2799, 4}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2743] = {tool = 2550, skill = 400, loot = {{2798, 4}, {2804, 5}, {2799, 4}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2769] = {tool = 2550, skill = 450, loot = {{2805, 4}, {2802, 5}, {2804, 3}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	[2783] = {tool = 2550, skill = 550, loot = {{2801, 6}, {2800, 7}, {2803, 6}}, effect = CONST_ME_MAGIC_GREEN, profession = "herbalism"},
	--herbalism (mushrooms)
	[4179] = {tool = 2566, skill = 10, loot = {{2794, 2}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4180] = {tool = 2566, skill = 40, loot = {{2792, 3}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4181] = {tool = 2566, skill = 90, loot = {{2794, 4}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4178] = {tool = 2566, skill = 160, loot = {{2792, 5}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4171] = {tool = 2566, skill = 280, loot = {{2787, 5}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4170] = {tool = 2566, skill = 420, loot = {{2791, 5}, {2789, 4}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4179] = {tool = 2566, skill = 510, loot = {{2789, 6}, {2791, 7}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4177] = {tool = 2566, skill = 550, loot = {{2793, 5}, {2787, 7}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	--herbalism (big mushrooms)
	[4167] = {tool = 2550, skill = 50, loot = {{2791, 3}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4168] = {tool = 2550, skill = 150, loot = {{2790, 4}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4169] = {tool = 2550, skill = 250, loot = {{2791, 5}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4174] = {tool = 2550, skill = 350, loot = {{2790, 5}, {2795, 5}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4175] = {tool = 2550, skill = 450, loot = {{2791, 4}, {2796, 6}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4172] = {tool = 2550, skill = 550, loot = {{2791, 5}, {2796, 6}, {2792, 4}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	[4173] = {tool = 2550, skill = 550, loot = {{2795, 5}, {2787, 7}, {2793, 7}}, effect = CONST_ME_MAGIC_RED, profession = "herbalism"},
	--mining (stones)
	[3607] = {tool = 2422, skill = 0, loot = {{2150, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[3608] = {tool = 2422, skill = 10, loot = {{2149, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[3609] = {tool = 2422, skill = 50, loot = {{2150, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[3615] = {tool = 2422, skill = 100, loot = {{2147, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[3616] = {tool = 2422, skill = 130, loot = {{2149, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[1357] = {tool = 2422, skill = 190, loot = {{2146, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[1356] = {tool = 2422, skill = 280, loot = {{9970, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[1285] = {tool = 2422, skill = 320, loot = {{2149, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	--mining (minerals, metals)
	[5868] = {tool = 2553, skill = 100, loot = {{2149, 2}, {2146, 2}, {9970, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[5867] = {tool = 2553, skill = 200, loot = {{5889, 1}, {2146, 2}, {9970, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[5866] = {tool = 2553, skill = 300, loot = {{5892, 1}, {2149, 2}, {2147, 2}, {9970, 2}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[5753] = {tool = 2553, skill = 350, loot = {{5888, 1}, {2150, 2}, {2146,2 }, {9970, 2}, {2156, 1}}, effect = CONST_ME_HITAREA, profession = "mining"},
	[5751] = {tool = 2553, skill = 400, loot = {{5887, 1}, {2149, 2}, {2147, 2}, {9970, 2}, {2158, 1}}, effect = CONST_ME_HITAREA, profession = "mining"}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	if recipes[itemEx.itemid] then
		if itemEx.actionid > 0 or itemEx.uid > 0 then
			doCreatureSay(cid, "You can't do that.", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
		end
		lootTable = {}
		lootName = "You recive: "
		professionSkill = getPlayerStorageValue(cid, professions[recipes[itemEx.itemid].profession].storage)
		itemPos = getThingPos(itemEx.uid)
		if professionSkill < 1 then
			professionSkill = 0
		end
		if item.itemid == recipes[itemEx.itemid].tool then
			if professionSkill >= recipes[itemEx.itemid].skill then
				if item.actionid ~= 5001 then				
					if math.random(1, 3) < 2 then
						doRemoveItem(itemEx.uid, 1)
						doSendMagicEffect(itemPos, recipes[itemEx.itemid].effect)
						if recipes[itemEx.itemid].profession ~= "skinning" then
							addEvent(doCreateItem, 120000, itemEx.itemid, 1, itemPos)
							addEvent(doSendMagicEffect, 120000, itemPos, recipes[itemEx.itemid].effect)
						end
						if math.random(1, 2) < 2 then
							if professionSkill < professions[recipes[itemEx.itemid].profession].maxSkill then
								setPlayerStorageValue(cid, professions[recipes[itemEx.itemid].profession].storage, professionSkill + 1)
								doCreatureSay(cid, "You advanced in "..recipes[itemEx.itemid].profession..". ("..professionSkill..").", TALKTYPE_ORANGE_1)
							end
						end
						repeat
							if #recipes[itemEx.itemid].loot == 0 then
								break
							end
							for i = 1, #recipes[itemEx.itemid].loot do
								if math.random(1, 2) < 2 then
									table.insert(lootTable, (recipes[itemEx.itemid].loot)[i])
								end
							end
						until lootTable ~= {}
						for i = 1, #lootTable do
							lootCount = math.random(1, lootTable[i][2])	
							doPlayerAddItem(cid, lootTable[i][1], lootCount)
							if i == #lootTable then
								lootName = lootName..""..lootCount.."x ".. getItemNameById(lootTable[i][1]) .."."
							else
								lootName = lootName..""..lootCount.."x ".. getItemNameById(lootTable[i][1]) ..", "
							end
						end
						if lootName == "You recive: " then
							lootName = "You don't recive any loot."
						end
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, lootName)
					else
						doSendMagicEffect(itemPos, CONST_ME_BLOCKHIT)
					end
				else
					doSendMagicEffect(itemPos, CONST_ME_BLOCKHIT)
					doCreatureSay(cid, "This tree was cut recenlty by someone else!", TALKTYPE_ORANGE_1)
				end
			else
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				doCreatureSay(cid, "You don't have required skill to do that!", TALKTYPE_ORANGE_1)
		end
		else
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_BLOCKHIT)
			doCreatureSay(cid, "This tool doesn't match!", TALKTYPE_ORANGE_1)
		end
	end
	return true
end
	]]></action>
</mod>
And your done.

How It Works:
Professions System - Examples

Original Script
This mod was tested using TFS 0.3.6!
 
All it says is "You can't do that". I've tried with every piece available. Starting with the ones with skill 0. Any help?
 
I got it working, all I had to do was remove -

Code:
		if itemEx.actionid > 0 or itemEx.uid > 0 then
			doCreatureSay(cid, "You can't do that.", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
		end
 
Pretty sure this might be crashing my server now, not recommended to use. AVOID THIS SCRIPT UNLESS YOU KNOW WHAT YOUR DOING. It is bugged.
 
Back
Top