• 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 How can i add skills to a respective vocation when login?

Gattaca

OTLand's Developer
Joined
Mar 13, 2009
Messages
158
Reaction score
2
Location
Venezuela
Oh Hello!

Well, as am making my new Original-WAR OT. I have made an very pretty scripts that own it, but. The only thing thats goin wrong is the skills giving into "data/creaturescripts/scripts/firstitems.lua". There i added;

Code:
if playervoc == 1 or playervoc == 5 then
doPlayerAddSkillTry(cid, 5, 20) -- Shield
end

And that is for each vocation, from normal to promotion. But, the problem is that when i connect into the game it doesn't give the skills or try to.

And the server only says;

[21/07/2009 13:41:03] Lua Script Error: [CreatureScript Interface]
[21/07/2009 13:41:03] data/creaturescripts/scripts/firstitems.lua:eek:nLogin

[21/07/2009 13:41:05] luaDoPlayerAddItem(). Item not found

Hope any help please.

Sincerely~~
Gattaca.

bump~~

<short>

bump n2.

still posting and bumping this thread.

Bump..........

How can i add skills to the players? While scripts? Please help...
 
Last edited by a moderator:
I'll look to the problem later, please only bump when there's 24 hours between the posts... Can you please post the full script? Maybe you've put your own part on the wrong places..
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
		


if item.uid == 29053 and getPlayerStorageValue(cid,29053) == 2 then
			doCreatureSay(cid, "You have already recieved this power!", TALKTYPE_ORANGE_1)


else if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then

			setPlayerStorageValue(cid,29053,2)
			doPlayerAddSkillTry(cid,1,50)
			doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
			doCreatureSay(cid, "You Gained 10 Melee Skills!", TALKTYPE_ORANGE_1)
else
		doCreatureSay(cid, "Only for Knights!", TALKTYPE_ORANGE_1)
		end
	
end
end

Hope it helps
 
Zoriath sorry i forget that ;S

Well the script am using is this:
Lua:
function onLogin(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The rules are from the original game tibia www.tibia.com")
	if getPlayerStorageValue(cid, 30001) == -1 then
				local playerVoc = getPlayerVocation(cid)
					if playerVoc == 1 or playerVoc == 5 then --If Vocation is Sorcerer or Master Sorcerer then weapon = Wand
						weapon = 2190 --Wand of vortex
					elseif playerVoc == 2 or playerVoc == 6 then --If Voc == Druid or Elder Druid then weapon = Rod
						weapon = 2182 --Snakebite Rod
					elseif playerVoc == 3 or playerVoc == 7 then --If Voc == Paladin or Royal Paladin then weapon = Spear
						weapon = 7378 --Royal Spear
					elseif playerVoc == 4 or playerVoc == 8 then --If Voc == Knight or Elite Knight then weapon = Sword
						weapon = 2432 --Fire Axe
					end

					if playervoc == 1 or playervoc == 5 then
						doPlayerAddSkillTry(cid, 5, 20) -- Shield
					end
					if playervoc == 2 or playervoc == 6 then
						doPlayerAddSkillTry(cid, 5, 20) -- Shield
					end
					if playervoc == 3 or playervoc == 7 then
						doPlayerAddSkillTry(cid, 4, 70) -- Distance
						doPlayerAddSkillTry(cid, 5, 40) -- Shield
					end
					if playervoc == 4 or playervoc == 8 then
						doPlayerAddSkillTry(cid, 5, 70) -- Shield
						doPlayerAddSkillTry(cid, 3, 70) -- Axe
						doPlayerAddSkillTry(cid, 2, 70) -- Sword
					end
				doPlayerAddItem(cid, weapon, 15)	
				doPlayerAddItem(cid, 2173, 1)
				-- Equipment
				doPlayerAddItem(cid, 2463, 1)
				doPlayerAddItem(cid, 2647, 1)
				doPlayerAddItem(cid, 2525, 1)
				doPlayerAddItem(cid, 2457, 1)
				doPlayerAddItem(cid, 2643, 1)
	--	for i = 1, table.maxn(firstItems) do
	--		doPlayerAddItem(cid, firstItems[i], 1)
	--	end
		local bag = doPlayerAddItem(cid, 2000, 1)
		doAddContainerItem(bag, 2120, 1)
		doAddContainerItem(bag, 2554, 1)
		doAddContainerItem(bag, 2273, 50)
		doAddContainerItem(bag, 2160, 3)
		doAddContainerItem(bag, 2268, 50)
		doAddContainerItem(bag, 2293, 50)
		doAddContainerItem(bag, 2311, 50)
		doAddContainerItem(bag, 2313, 50)
		doAddContainerItem(bag, 2304, 50)
		local manapotion = doPlayerAddItem(cid, 2001, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)
		doAddContainerItem(manapotion, 7620, 1)

		
		setPlayerStorageValue(cid, 30001, 1)
	end
 	return TRUE
end

Sorry about the bad tabbing, is just coded it for my war server.
And when i try to give skills, they do not gain the skills for example 65/65 they dont gain it ;s
 
No weapons is working, everything is working, the items giving and it all.
The only thing that is not mading is the addSkillTry,
and dont know why.

Any help?
 
No weapons is working, everything is working, the items giving and it all.
The only thing that is not mading is the addSkillTry,
and dont know why.

Any help?

With the function you are using you are only giving skill TRIES not skills.

Function made in a hurry, try it:
Code:
function doPlayerSetSkill(cid, skillid, skill)
	if getPlayerSkill(cid) >= skill then
		return TRUE
	end
	
	local skill_ = getPlayerSkill(cid, skillid)
	
	while skill_ < skill do
		doPlayerAddSkillTries(cid, skillid, 5000)
	end
	
	return TRUE
end
 
o,o

Just add the function to data/lib/functions.lua || data/functions.lua || data/global.lua. Restart the server.

Example:
Lua:
function onLogin(cid)
    if isInArray({ 4, 8 }, getPlayerVocation(cid)) == TRUE then
        doPlayerSetSkill(cid, 3, 70)
    end
    
    return TRUE
end
 
Back
Top