• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

doPlayerAddMagLevel(cid, add)

Tufte

Member
Joined
Nov 19, 2007
Messages
652
Reaction score
24
Location
Norway
This function is very handy for custom quests! Now you can add magic levels specified in 1 function!

Usage:
PHP:
doPlayerAddMagLevel(cid, 5)
This will add 5 magic-levels upon the players current magic level! If he had mlvl 55, he will now have 60.

Put this in your data/lib/functions.lua

PHP:
function doPlayerAddMagLevel(cid, add)
local current = getPlayerRequiredMana(cid, getPlayerMagLevel(cid))
local manaspend = ((getPlayerRequiredMana(cid, getPlayerMagLevel(cid)+add)) / getConfigInfo("rateMagic"))
	if isPlayer(cid) == TRUE then
		doPlayerAddSpentMana(cid, (current + manaspend))
	else
		error("Player not found in function doPlayerAddMagLevel")
	end
end

Tested on 0,3,4PL2

Would'nt mind a rep point from you ;)
 
@Topic,

Wow, great job.
Make one for skills?
 
if you want it for skills, just replace
PHP:
	getPlayerRequiredMana(cid, magicLevel)
with
PHP:
	getPlayerRequiredSkillTries(cid, skillId, skillLevel)
and
PHP:
	doPlayerAddSpentMana(cid, amount)
with
PHP:
	doPlayerAddSkillTry(cid, skillid, n)
 
@Tufte,

Cool,
Thanks for this.
 
This function is very handy for custom quests! Now you can add magic levels specified in 1 function!

Usage:
PHP:
doPlayerAddMagLevel(cid, 5)
This will add 5 magic-levels upon the players current magic level! If he had mlvl 55, he will now have 60.

Put this in your data/lib/functions.lua

PHP:
function doPlayerAddMagLevel(cid, add)
local current = getPlayerRequiredMana(cid, getPlayerMagLevel(cid))
local manaspend = ((getPlayerRequiredMana(cid, getPlayerMagLevel(cid)+add)) / getConfigInfo("rateMagic"))
	if isPlayer(cid) == TRUE then
		doPlayerAddSpentMana(cid, (current + manaspend))
	else
		error("Player not found in function doPlayerAddMagLevel")
	end
end

Tested on 0,3,4PL2

Would'nt mind a rep point from you ;)


awesome script, could you remake it a little so if u step on a location, u get one magic level. also with storage value so u only could do it once :) thx

+ rep!
 
well, thats increadibly easy to make, you should be able to make it yourself :p

PHP:
function onStepIn(cid, pos)
	if getPlayerStorageValue(cid, 50010) ~= 1 then
		doPlayerAddMagLevel(cid, 1) 
        setPlayerStorageValue(cid, 50010, 1)
		doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
	else
		doPlayerSendCancel(cid, "You have already received the power of this tile.")
		doSendMagicEffect(pos, CONST_ME_POFF)
	end
	return TRUE
end
 
It should be like this?
Lua:
function doPlayerAddClubLevel(cid, add)
local current = getPlayerRequiredSkillTries(cid, 1, getPlayerSkillLevel(cid, 1))
local clubTries = (getPlayerRequiredSkillTries(cid, 1, getPlayerSkillLevel(cid, 1)+add) / getConfigInfo("rateSkill"))
    if isPlayer(cid) == TRUE then
        doPlayerAddSkillTry(cid, 1, (current + clubTries))
    else
        error("Gracz nie znaleziony w funkcji doPlayerAddClubLevel")
    end
end
If not, correct this plx :p.
 
i am not sure, you must play with the formulas since im not sure if the skilltries works as the mana spent...
 
No work, i need magic 80 and change to magic 66....

fix please
 
Sorry for refresh, but I need help. It is possible to edit this function to remove mlvls?
 
Back
Top