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

doPlayerAddFrags + doPlayerAddLevel

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,663
Solutions
125
Reaction score
1,109
Location
Germany
GitHub
slawkens
Warning:
These functions works only in TFS 0.3.

Both accepts negative values, so you can use ex.:
doPlayerAddFrags(cid, -5) -- removing 5 frags
and
doPlayerAddLevel(cid, -30) --removing 30 levels

Place it in data/lib/function.lua file.

doPlayerAddFrags(cid, amount)
Code:
function doPlayerAddFrags(cid, amount)
	return doPlayerSetRedSkullTicks(cid, getPlayerRedSkullTicks(cid) + getConfigInfo('timeToDecreaseFrags') * amount)
end

doPlayerAddLevel(cid, amount[, round = FALSE])
Code:
function doPlayerAddLevel(cid, amount, round)
	local newExp = 0
	local currentLevel = getPlayerLevel(cid)
	if(amount > 0) then
		newExp = getExperienceForLevel(currentLevel + amount) - (round == TRUE and getPlayerExperience(cid) or getExperienceForLevel(currentLevel))
	else
		newExp = -((round == TRUE and getPlayerExperience(cid) or getExperienceForLevel(currentLevel)) - getExperienceForLevel(currentLevel + amount))
	end

	return doPlayerAddExp(cid, newExp)
end

Example talkaction: (Remove 1 frag for 1cc)
Code:
local config =
{
	cost = 10000
}

function onSay(cid, words, param)
	if(doPlayerRemoveMoney(cid, config.cost) ~= TRUE) then
		doPlayerSendCancel(cid, "Not enought money, remove frag cost " .. config.cost .. "gp.")
		return TRUE
	end

	doPlayerAddFrags(cid, -1) --remove 1 frag
	return TRUE
end

doPlayerAddLevel has also additional parameter - round (default: FALSE), if you set it to TRUE, ex:
doPlayerAddLevel(cid, 3, TRUE) - if player have 30% to next level, then he'll only get these 30% so he have next level and 0%.
 
when addExp removing lvl - not remove only exp for next lvl,
example:
You have 94 lvl and 22% to 95
if you remove 8000000 exp you have 94 lvl and 0% to 95.
 
Back
Top