• 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] Attribute System

xuvurex

New Member
Joined
Mar 23, 2008
Messages
10
Reaction score
0
Hello everyone, iv recently started messing around with tibia again on account of being bored and am having some problems with my Attribute System (altered "Rooteh"'s script). I have tried and searched everywhere for a solution and tried multiple outcomes which only get me to end up freezing or just not working in general.

If i use "doPlayerAddSkill" i just get an error telling me that it pretty much doesn't exist...iv tried going into my functions and altering it but still no success. Iv even tried converting everything and using 'doAddSkillTry" instead but that's when my server decides to freeze. My problem pretty much is, i cant get my script to add a skill. Any help would be greatly appreciated.

Thank you

PS: im using tfs 0.3.6 cryingdamson V3 and it shows the function in my function log

Lua:
--Made By Rooteh--
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end
 
local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v) == TRUE) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end
 
local function doPlayerAddAttributePoint(cid, amount)
-- Function made by Rooteh
-- doPlayerAddAttributePoint(cid, amount)
local storagevalue = 47061
local current = getPlayerStorageValue(cid, storagevalue)
local new = (current+amount)
setPlayerStorageValue(cid, storagevalue, new)
return LUA_NO_ERROR
end
 
local function doPlayerCheckAttributePoint(cid)
-- Function made by Rooteh
-- doPlayerCheckAttributePoint(cid)
local storagevalue = 47061
local amt = getPlayerStorageValue(cid, storagevalue)
return amt
end
 
function onCreatureAppear(cid)
end
 
function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
		if(isPlayer(cid) == TRUE) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
end
 
function onCreatureSay(cid, type, msg)
local Fist = 
{ [0] = {name = 'None', cost = 1, amount = 3},
				[1] = {name = 'Fire Apprentice', cost = 1, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
			    [2] = {name = 'Water Apprentice', cost = 1, amount = 3},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 4},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 1, amount = 3}
}
 
local Club = 
{ [0] = {name = 'None', cost = 1, amount = 3},
				[1] = {name = 'Fire Apprentice', cost = 1, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
			    [2] = {name = 'Water Apprentice', cost = 1, amount = 3},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 4},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 1, amount = 3}
}
 
local Sword = 
{ [0] = {name = 'None', cost = 1, amount = 3},
				[1] = {name = 'Fire Apprentice', cost = 1, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
			    [2] = {name = 'Water Apprentice', cost = 1, amount = 3},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 4},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 1, amount = 3}
}
 
local Axe = 
{ [0] = {name = 'None', cost = 1, amount = 3},
				[1] = {name = 'Fire Apprentice', cost = 1, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
			    [2] = {name = 'Water Apprentice', cost = 1, amount = 3},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 4},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 1, amount = 3}
}
 
local Distance = 
{ [0] = {name = 'None', cost = 1, amount = 3},			
				[1] = {name = 'Fire Apprentice', cost = 1, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
			    [2] = {name = 'Water Apprentice', cost = 1, amount = 3},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 4},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 1, amount = 3}
}
 
local Shield = 
{ [0] = {name = 'None', cost = 1, amount = 3},
				[1] = {name = 'Fire Apprentice', cost = 2, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxMana Added
				[2] = {name = 'Water Apprentice', cost = 4, amount = 7},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 1},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 2, amount = 3}
}
 
local Magic = 
{ [0] = {name = 'None', cost = 1, amount = 3},
				[1] = {name = 'Fire Apprentice', cost = 2, amount = 3}, ---[1] = Vocation,  Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxMana Added
				[2] = {name = 'Water Apprentice', cost = 4, amount = 7},
				[3] = {name = 'Nature Apprentice', cost = 1, amount = 2},
				[4] = {name = 'Air Apprentice', cost = 1, amount = 1},
				[5] = {name = 'None', cost = 1, amount = 2},
				[6] = {name = 'Ice Sorcerer', cost = 1, amount = 2},
				[7] = {name = 'Energy Sorcerer', cost = 1, amount = 2},
				[8] = {name = 'Druid', cost = 1, amount = 2},
				[9] = {name = 'Paladin', cost = 2, amount = 3}
}
 
	if((msg == "hi") and not (isFocused(cid))) then
		selfSay("Welcome "..getCreatureName(cid)..", would you like to learn about {Attribute Points}? You currently have "..doPlayerCheckAttributePoint(cid).." attribute points.", cid)
		addFocus(cid)
		talk_state = 1
	elseif((isFocused(cid)) and (msg == "attribute" or msg == "points" or msg == "help" or msg == "job" or msg == "attribute point" or msg == "attribute points")) and talk_state == 1 then
		selfSay("When you gain levels, you recieve attribute points. You can spend the attribute points on {fist}, {club}, {sword}, {axe}, {distance}, {shield} or {magic} level to improve your character.", cid)
	elseif((isFocused(cid)) and (msg == "fist")) and talk_state == 1 then
		selfSay("As a "..(Fist[getPlayerVocation(cid)].name).." you can increase your fist fighting by "..(Fist[getPlayerVocation(cid)].amount)..".  It will cost you "..(Fist[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on fist fighting?", cid)
		talk_state = 2
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 2 then
		if doPlayerCheckAttributePoint(cid) >= Fist[getPlayerVocation(cid)].amount then
			local fistskill = getPlayerSkillLevel(cid, SKILL_FIST)
			doPlayerAddSkill(cid, (fistskill+Fist[getPlayerVocation(cid)].amount))
			local fist = (getPlayerSkillLevel(cid, SKILL_FIST))
			doPlayerAddSkill(cid, fist)
			doPlayerAddAttributePoint(cid, -(Fist[getPlayerVocation(cid)].cost))
			selfSay("Your fist fighting has increased by "..(Fist[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "club")) and talk_state == 1 then
		selfSay("As a "..(Club[getPlayerVocation(cid)].name).." you can increase your club fighting by "..(Club[getPlayerVocation(cid)].amount)..".  It will cost you "..(Club[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on club fighting?", cid)
		talk_state = 3
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 3 then
		if doPlayerCheckAttributePoint(cid) >= Club[getPlayerVocation(cid)].amount then
			local clubskill = getPlayerSkillLevel(cid, SKILL_CLUB)
			doPlayerAddSkill(cid, (clubskill+Club[getPlayerVocation(cid)].amount))
			local club = (getPlayerSkillLevel(cid, SKILL_CLUB))
			doPlayerAddSkill(cid, club)
			doPlayerAddAttributePoint(cid, -(Club[getPlayerVocation(cid)].cost))
			selfSay("Your club fighting has increased by "..(Club[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "sword")) and talk_state == 1 then
		selfSay("As a "..(Sword[getPlayerVocation(cid)].name).." you can increase your sword fighting by "..(Sword[getPlayerVocation(cid)].amount)..".  It will cost you "..(Sword[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on sword fighting?", cid)
		talk_state = 4
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 4 then
		if doPlayerCheckAttributePoint(cid) >= Sword[getPlayerVocation(cid)].amount then
			local swordskill = getPlayerSkillLevel(cid, SKILL_SWORD)
			doPlayerAddSkill(cid, (swordskill+Sword[getPlayerVocation(cid)].amount))
			local sword = (getPlayerSkillLevel(cid, SKILL_SWORD))
			doPlayerAddSkill(cid, sword)
			doPlayerAddAttributePoint(cid, -(Sword[getPlayerVocation(cid)].cost))
			selfSay("Your sword fighting has increased by "..(Sword[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "axe")) and talk_state == 1 then
		selfSay("As a "..(Axe[getPlayerVocation(cid)].name).." you can increase your axe fighting by "..(Axe[getPlayerVocation(cid)].amount)..".  It will cost you "..(Axe[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on axe fighting?", cid)
		talk_state = 5
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 5 then
		if doPlayerCheckAttributePoint(cid) >= Axe[getPlayerVocation(cid)].amount then
			local axeskill = getPlayerSkillLevel(cid, SKILL_AXE)
			doPlayerAddSkill(cid, (axeskill+Axe[getPlayerVocation(cid)].amount))
			local axe = (getPlayerSkillLevel(cid, SKILL_AXE))
			doPlayerAddSkill(cid, axe)
			doPlayerAddAttributePoint(cid, -(Axe[getPlayerVocation(cid)].cost))
			selfSay("Your axe fighting has increased by "..(Axe[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "distance")) and talk_state == 1 then
		selfSay("As a "..(Distance[getPlayerVocation(cid)].name).." you can increase your distance fighting by "..(Distance[getPlayerVocation(cid)].amount)..".  It will cost you "..(Distance[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on distance fighting?", cid)
		talk_state = 6
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 6 then
		if doPlayerCheckAttributePoint(cid) >= Distance[getPlayerVocation(cid)].amount then
			local distanceskill = getPlayerSkillLevel(cid, SKILL_DISTANCE)
			doPlayerAddSkill(cid, (distanceskill+Distance[getPlayerVocation(cid)].amount))
			local distance = (getPlayerSkillLevel(cid, SKILL_DISTANCE))
			doPlayerAddSkill(cid, distance)
			doPlayerAddAttributePoint(cid, -(Distance[getPlayerVocation(cid)].cost))
			selfSay("Your distance fighting has increased by "..(Distance[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "shield")) and talk_state == 1 then
		selfSay("As a "..(Shield[getPlayerVocation(cid)].name).." you can increase your shielding by "..(Shield[getPlayerVocation(cid)].amount)..".  It will cost you "..(Shield[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on shielding?", cid)
		talk_state = 7
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 7 then
		if doPlayerCheckAttributePoint(cid) >= Shield[getPlayerVocation(cid)].amount then
			local shieldskill = getPlayerSkillLevel(cid, SKILL_SHIELD)
			doPlayerAddSkill(cid, (shieldskill+Shield[getPlayerVocation(cid)].amount))
			local shield = (getPlayerSkillLevel(cid, SKILL_SHIELD))
			doPlayerAddSkill(cid, shield)
			doPlayerAddAttributePoint(cid, -(Shield[getPlayerVocation(cid)].cost))
			selfSay("Your shielding has increased by "..(Shield[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "magic")) and talk_state == 1 then
		selfSay("As a "..(Magic[getPlayerVocation(cid)].name).." you can increase your magic level by "..(Magic[getPlayerVocation(cid)].amount)..".  It will cost you "..(Magic[getPlayerVocation(cid)].cost).." attribute points.", cid)
		selfSay("Do you want to spend your attribute points on magic level?", cid)
		talk_state = 8
	elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 8 then
		if doPlayerCheckAttributePoint(cid) >= Magic[getPlayerVocation(cid)].amount then
			local magicskill = getPlayerMagLevel(cid)
			doPlayerAddMagLevel(cid, (magicskill+Magic[getPlayerVocation(cid)].amount))
			local magic = (getPlayerMagLevel(cid))
			doPlayerAddMagLevel(cid, magic)
			doPlayerAddAttributePoint(cid, -(Magic[getPlayerVocation(cid)].cost))
			selfSay("Your magic level has increased by "..(Magic[getPlayerVocation(cid)].amount).."!", cid)
			selfSay("Goodbye, come back and see me soon!", cid)
			talk_state = 0
			removeFocus(cid)
		else
			selfSay("You do not have enough attribute points!", cid)
			selfSay("Come back after you level.", cid)
			talk_state = 0
			removeFocus(cid)
		end
	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
		selfSay("cya!", cid, TRUE)
		closeShopWindow(cid)
		removeFocus(cid)
	end
end
 
function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		closeShopWindow(cid)
		removeFocus(cid)
	end
end
 
function onPlayerEndTrade(cid)
	selfSay("It was a pleasure doing business with you.", cid)
end
 
function onThink()
	for i, focus in pairs(focuses) do
		if(isCreature(focus) == FALSE) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Hmph!")
				closeShopWindow(focus)
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end
 
I got kinda teh same problem. I went in items.lua and added this <attribute key="skillSword" value="5"/>. But as soon i restart server the weapon says that it increases my sword skill but my skills arent going higher.. It stays at 10 and wont change to 15. I´m trying it for a week now and now i need ur guys help. Got the same serv like above.
 

Similar threads

Back
Top