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

Skills problem

Aarthec

w0000t
Joined
Apr 25, 2009
Messages
129
Reaction score
0
Location
Sweden
doPlayerAddSkill(cid, amount)
I guess that's what I should use to make the player recieve a skill but I don't get how I should use it.
I tried with
PHP:
doPlayerAddSkill(cid, skillid, amount))
But that didn't work ^^

Also tried with:
PHP:
doPlayerAddSkillTry(cid, SKILL_SWORD, getPlayerRequiredSkillTries(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD))

Doesn't work.

Maybe it doesn't work because of my config.lua (rateSkill = 0). So how can I do this? :p
 
Last edited:
These are multipliers, if you set it below 1 it should need less tries than in previous skill level, maybe server behaves a bit strange if it is set wrong, try sth like 1.05 for almost exact number of tries
 
Maybe use these formulas.
Lua:
local current = getPlayerRequiredSkillTries(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD))
local skillTries = (getPlayerRequiredSkillTries(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD) +add) / getConfigInfo("rateSkill"))
 
Not Tested

data/lib/functions.lua
Lua:
function doPlayerAddSkillSword(cid, amount)
local current = getPlayerRequiredSkillTries(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD))
local skillTries = (getPlayerRequiredSkillTries(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD)+amount) / getConfigInfo("rateSkill"))
    if isPlayer(cid) == TRUE then
        doPlayerAddSkillSword(cid, (current + skillTries))
    else
        error("Player not found.")
    end
end

Example:
Lua:
local stroage = 1234
function onUse(item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) >= 100 then
		if getPlayerStorageValue(cid, storage) == -1 then
			doPlayerAddSkillSword(cid, 1)
			setPlayerStorageValue(cid, storage, 1)
			doSendAnimatedText(getCreaturePosition(cid), "Sword Up!", TEXTCOLOR_LIGHTBLUE)
		else
			doPlayerSendCancel(cid, "You have already used this.")
		end
	else
		doPlayerSendCancel(cid, "You must be atleast level 100 to use this.")
	end
	return TRUE
end
 
Last edited:
[20/09/2009 21:47:47] data/lib/function.lua:307: stack overflow
[20/09/2009 21:47:47] stack traceback:
[20/09/2009 21:47:47] data/lib/function.lua:307: in function 'isPlayer'
[20/09/2009 21:47:47] data/lib/function.lua:468: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] ...
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'
[20/09/2009 21:47:47] data/lib/function.lua:469: in function 'doPlayerAddSkillSword'

alot of errors ;o
 
Try it now...this is just an example, I don't know if it will work.
(I edited the function.lua part).
 
0.3.5 Lua Functions:
PHP:
getPlayerRequiredSkillTries(cid, skillId, skillLevel) //TODO

I guess it won't work, because it doesn't exist yet. :thumbup:
 
So it isn't working yet which makes it impossible to fix my problem without source editing? -.-

I really appreciate your help though, rep++.
 
Last edited:
Yea, np...
if only that function was in 0.3.5, I think it would work.

2 points to new bar! :thumbup:
 
doPlayerAddSkill(cid, SKILL_SWORD)
works if I have "rateSkill = 1" in config.

Is there a chance I could make it work with that function?
 
Back
Top Bottom