Adicionar Premium Exp

Holly Angel
em Scripts

Holly Angel

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 15/08/06Posts: 110Char no Tibia: Alca Morth

Gostaria de pedir ajuda de vocês da comunidade para um pequeno problema que não consigo resolver.

 

Gostaria de adicionar no meu servidor uma exp bônus para quem é premium account, tentei adicionar pelo creaturescripts, porem não obtive exito.

Acredito que por se tratar de uma versão antiga de servidor (7.72) Inferna 1.0, o método para acrescentar a rate seja outro.

Acredito que seja possível fazer isso através do functions,xml localizado na pasta data, pois é la que é configurado os stages do servidor.

 

functions.xml

STAGES = {
{level = 150, rate = 2},
{level = 120, rate = 3},
{level = 100, rate = 5},
{level = 90, rate = 8},
{level = 80, rate = 10},
{level = 60, rate = 15},
{level = 40, rate = 20},
{level = 30, rate = 30},
{level = 20, rate = 40},
{level = 8, rate = 50},
{level = 1, rate = 20}
}

DEFAULT_RATE = 2

function checkStages(cid)
        local level = getPlayerLevel(cid)
        
        for i = 1, # STAGES do
                if (level >= STAGES[i].level) then
                        doPlayerSetRate(cid, 8, STAGES[i].rate)
                        return
                end
        end
        
        doPlayerSetRate(cid, 8, DEFAULT_RATE)
end

function isPromoted(cid)
	if (isPlayer(cid) == TRUE) then
		local voc = getPlayerVocation(cid)
		if (voc >= 5 and voc <= 8) then
			return TRUE
		end
	end
	
	return FALSE
end

function doPlayerAddBless(cid, blessid)
	if (getPlayerBless(cid, blessid) == FALSE) then
		local storageid = STORAGE_BLESSES + blessid
		setPlayerStorageValue(cid, storageid, 1)
		doPlayerUpdateLevelLossPercent(cid)
	end
end

function getPlayerBless(cid, blessid)
	local storageid = STORAGE_BLESSES + blessid
	if (getPlayerStorageValue(cid, storageid) == TRUE) then
		return TRUE
	else
		return FALSE
	end
end

function doPlayerRemoveBless(cid, blessid)
	if (getPlayerBless(cid, blessid) == 1) then
		local storageid = STORAGE_BLESSES + blessid
		setPlayerStorageValue(cid, storageid, 0)
		doPlayerUpdateLevelLossPercent(cid)
	end
end

function RemoveAllBlessings(cid)
  if (getPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES) == 1) then
    local BLESSINGS = {1, 2, 3, 4, 5}
       for v = 1, 5 do
          if (getPlayerBless(cid, BLESSINGS[v]) > 0) then
              doPlayerRemoveBless(cid, BLESSINGS[v])
              setPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES, 0)
              setPlayerStorageValue(cid,43668,0)
          end
       end
  end
 return 1
end

function doSetLossPercentBoth(cid, percent)
local ABILITIES = {0, 1, 2}
  for A = 1, 3 do
     doPlayerSetLossPercent(cid, ABILITIES[A], percent)
  end
 return 1
end

function doPlayerUpdateLevelLossPercent(cid)
	local i = 0
	local blesses = 0
	while i < 6 do
		if getPlayerBless(cid, i) == TRUE then
			blesses = blesses + 1
		end
		i = i + 1
	end

	if (blesses >= 5) then
            if (isPromoted(cid) == TRUE) then
                doSetLossPercentBoth(cid, 2)
            else
                doSetLossPercentBoth(cid, 5)
            end
	elseif (blesses >= 4) then
            if (isPromoted(cid) == TRUE) then
                doSetLossPercentBoth(cid, 3)
            else
                doSetLossPercentBoth(cid, 6)
            end
	elseif (blesses >= 3) then
            if (isPromoted(cid) == TRUE) then
                doSetLossPercentBoth(cid, 4)
            else
                doSetLossPercentBoth(cid, 7)
            end
	elseif (blesses >= 2) then
            if (isPromoted(cid) == TRUE) then
                doSetLossPercentBoth(cid, 5)
            else
                doSetLossPercentBoth(cid, 8)
            end
	elseif (blesses >= 1) then
            if (isPromoted(cid) == TRUE) then
                doSetLossPercentBoth(cid, 6)
            else
                doSetLossPercentBoth(cid, 9)
            end
	else
            if (isPromoted(cid) == TRUE) then
                doSetLossPercentBoth(cid, 7)
            else
                doSetLossPercentBoth(cid, 10)
            end
	end
end

function kickAllPlayers()
local players = getPlayersOnlineList() 
   for i = 1, table.maxn(players) do 
       doRemoveCreature(players[i])
   end
   return 1
end

function isSorcerer(cid)
	if (isPlayer(cid) == TRUE) then
		local voc = getPlayerVocation(cid)
		if (voc == 1 or voc == 5) then
			return TRUE
		end
	end
	
	return FALSE
end

function isDruid(cid)
	if (isPlayer(cid) == TRUE) then
		local voc = getPlayerVocation(cid)
		if (voc == 2 or voc == 6) then
			return TRUE
		end
	end
	
	return FALSE
end

function isPaladin(cid)
	if (isPlayer(cid) == TRUE) then
		local voc = getPlayerVocation(cid)
		if (voc == 3 or voc == 7) then
			return TRUE
		end
	end
	
	return FALSE
end

function isKnight(cid)
	if (isPlayer(cid) == TRUE) then
		local voc = getPlayerVocation(cid)
		if (voc == 4 or voc == 8) then
			return TRUE
		end
	end
	
	return FALSE
end

function isFemale(cid)
	if (isPlayer(cid) == TRUE) then
		if (getPlayerSex(cid) == 0) then
			return TRUE
		end
	end
        return FALSE
end

function getDirectionTo(pos1, pos2)
	local dir = NORTH
	if(pos1.x > pos2.x) then
		dir = WEST
		if(pos1.y > pos2.y) then
			dir = NORTHWEST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHWEST
		end
	elseif(pos1.x < pos2.x) then
		dir = EAST
		if(pos1.y > pos2.y) then
			dir = NORTHEAST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHEAST
		end
	else
		if(pos1.y > pos2.y) then
			dir = NORTH
		elseif(pos1.y < pos2.y) then
			dir = SOUTH
		end
	end
	return dir
end

function getDistanceBetween(pos1, pos2)
	local xDif = math.abs(pos1.x - pos2.x)
	local yDif = math.abs(pos1.y - pos2.y)

	local posDif = math.max(xDif, yDif)
	if (pos1.z ~= pos2.z) then
		posDif = (posDif + 9 + 6)
	end
	return posDif
end

function getPlayerLookPos(cid)
	return getPosByDir(getThingPos(cid), getPlayerLookDir(cid))
end

function getPosByDir(basePos, dir)
	local pos = basePos
	if(dir == NORTH) then
		pos.y = pos.y-1
	elseif(dir == SOUTH) then
		pos.y = pos.y + 1
	elseif(dir == WEST) then
		pos.x = pos.x-1
	elseif(dir == EAST) then
		pos.x = pos.x+1
	elseif(dir == NORTHWEST) then
		pos.y = pos.y-1
		pos.x = pos.x-1
	elseif(dir == NORTHEAST) then
		pos.y = pos.y-1
		pos.x = pos.x+1
	elseif(dir == SOUTHWEST) then
		pos.y = pos.y+1
		pos.x = pos.x-1
	elseif(dir == SOUTHEAST) then
		pos.y = pos.y+1
		pos.x = pos.x+1
	end
	return pos
end

function doRelocateDelete(pos,posto)
  return doRelocate(pos,posto)
end

function doRelocateRemove(pos,posto)
	-- Relocates moveable items and deletes non-moveable unless it is a door.
	local oldstackpos = pos.stackpos
	doRelocate(pos,posto)
	if pos.stackpos == nil then pos.stackpos = 1 end
	while 1 do
		if getThingfromPos(pos).uid > 0 and getThingfromPos(pos).itemid ~= 1209 and getThingfromPos(pos).itemid ~= 1210 and getThingfromPos(pos).itemid ~= 1211 then
			doRemoveItem(getThingfromPos(pos).uid)
		else
			if pos.stackpos > 1 then
				pos.stackpos = pos.stackpos-1
			else
				pos.stackpos = oldstackpos  
				break
			end
		end
	end
end

-- Functions made by Jiddo
function doPlayerGiveItem(cid, itemid, count, charges)
	local hasCharges = (isItemRune(itemid) == TRUE or isItemFluidContainer(itemid) == TRUE)
	if(hasCharges and charges == nil) then
		charges = 1
	end
	
	while count > 0 do
    	local tempcount = 1
    	
    	if(hasCharges) then
    		tempcount = charges
    	end
    	if(isItemStackable(itemid) == TRUE) then
    		tempcount = math.min (100, count)
   		end
    	
       	local ret = doPlayerAddItem(cid, itemid, tempcount)
       	if(ret == LUA_ERROR) then
        	ret = doCreateItem(itemid, tempcount, getPlayerPosition(cid))
        end
        
        if(ret ~= LUA_ERROR) then
        	if(hasCharges) then
        		count = count-1
        	else
        		count = count-tempcount
        	end
        else
        	return LUA_ERROR
        end
	end
    return LUA_NO_ERROR
end

function doPlayerTakeItem(cid, itemid, count)
	if(getPlayerItemCount(cid,itemid) >= count) then
		
		while count > 0 do
			local tempcount = 0
    		if(isItemStackable(itemid) == TRUE) then
    			tempcount = math.min (100, count)
    		else
    			tempcount = 1
    		end
        	local ret = doPlayerRemoveItem(cid, itemid, tempcount)
        	
            if(ret ~= LUA_ERROR) then
            	count = count-tempcount
            else
            	return LUA_ERROR
            end
		end
		
		if(count == 0) then
			return LUA_NO_ERROR
		end
	end
	return LUA_ERROR
end

function doPlayerAddMoney(cid, amount)
	local crystals = math.floor(amount/10000)
	amount = amount - crystals*10000
	local platinum = math.floor(amount/100)
	amount = amount - platinum*100
	local gold = amount
	local ret = 0
	if(crystals > 0) then
		ret = doPlayerGiveItem(cid, ITEM_CRYSTAL_COIN, crystals)
		if(ret ~= LUA_NO_ERROR) then
			return LUA_ERROR
		end
	end
	if(platinum > 0) then
		ret = doPlayerGiveItem(cid, ITEM_PLATINUM_COIN, platinum)
		if(ret ~= LUA_NO_ERROR) then
			return LUA_ERROR
		end
	end
	if(gold > 0) then
		ret = doPlayerGiveItem(cid, ITEM_GOLD_COIN, gold)
		if(ret ~= LUA_NO_ERROR) then
			return LUA_ERROR
		end
	end
	return LUA_NO_ERROR
end

function doPlayerBuyItem(cid, itemid, count, cost, charges)
    if(doPlayerRemoveMoney(cid, cost) == TRUE) then
    	return doPlayerGiveItem(cid, itemid, count, charges)
    end
	return LUA_ERROR
end

function doPlayerSellItem(cid, itemid, count, cost)
	if(doPlayerTakeItem(cid, itemid, count) == LUA_NO_ERROR) then
		if(doPlayerAddMoney(cid, cost) ~= LUA_NO_ERROR) then
			error('Could not add money to ' .. getPlayerName(cid) .. '(' .. cost .. 'gp)')
		end
		return LUA_NO_ERROR
	end
	return LUA_ERROR
	
end

function getPlayerMoney(cid)
	return ((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))
end

function doPlayerWithdrawAllMoney(cid)
	return doPlayerWithdrawMoney(cid, getPlayerBalance(cid))
end

function doPlayerDepositAllMoney(cid)
	return doPlayerDepositMoney(cid, getPlayerMoney(cid))
end

function doPlayerTransferAllMoneyTo(cid, target)
	return doPlayerTransferMoneyTo(cid, target, getPlayerBalance(cid))
end

function playerExists(name)
	return (getPlayerGUIDByName(name) ~= 0)
end

function getConfigInfo(info)
	if (type(info) ~= 'string') then 
		return nil 
	end

	dofile('config.lua')
	return _G[info]
end

function getTibiaTime()
	local minutes = getWorldTime()
	local hours = 0
	local ampm = "am"
	local between = ":"
	while (minutes > 59) do
		hours = hours + 1
		minutes = minutes - 60
	end
	while (hours > 12) do
		ampm = "pm"
		hours = hours - 12
	end
	if (minutes < 10) then
		between = ":0"
	end

	return {hours = hours, minutes = minutes, ampm = ampm, between = between}
end

function getTime()
	return getTibiaTime().hours..""..getTibiaTime().between..""..getTibiaTime().minutes.." "..getTibiaTime().ampm
end

exhaustion = 
{

	check = function (cid, storage)
		local exhaust = getPlayerStorageValue(cid, storage)  
		if (os.time() >= exhaust) then
			return FALSE
		else
			return TRUE
		end
	end,

	get = function (cid, storage)
		local exhaust = getPlayerStorageValue(cid, storage) 
		local left = exhaust - os.time()
		if (left >= 0) then
			return left
		else
			return FALSE
		end
	end,
	
	set = function (cid, storage, time)
		setPlayerStorageValue(cid, storage, os.time()+time)  
	end,

	make = function (cid, storage, time)
		local exhaust = exhaustion.get(cid, storage)
		if (exhaust > 0) then
			return FALSE
		else
			exhaustion.set(cid, storage, time)
			return TRUE
		end
	end
}


	table.find = function (table, value)
		for i,v in pairs(table) do
			if (v == value) then
				return i
			end
		end
		return nil
	end
	table.getPos = table.find

	table.isStrIn = function (txt, str)
		local result = false
		for i, v in pairs(str) do          
			result = (string.find(txt, v) and not string.find(txt, '(%w+)' .. v) and not string.find(txt, v .. '(%w+)'))
			if (result) then
				break
			end
		end
		return result
	end

	table.countElements = function (table, item)
		local count = 0
		for i, n in pairs(table) do
			if (item == n) then count = count + 1 end
		end
		return count
	end
	
	table.getCombinations = function (table, num)
		local a, number, select, newlist = {}, #table, num, {}
		for i = 1, select do
			a[#a + 1] = i
		end
		local newthing = {}
		while (1) do
			local newrow = {}
			for i = 1, select do
				newrow[#newrow + 1] = table[a[i]]
			end
			newlist[#newlist + 1] = newrow
			i = select
			while (a[i] == (number - select + i)) do
				i = i - 1
			end
			if (i < 1) then break end
				a[i] = a[i] + 1
				for j = i, select do
					a[j] = a[i] + j - i
				end
			end
		return newlist
	end


	string.split = function (str)
		local t = {}
		local function helper(word) table.insert(t, word) return "" end
		if (not str:gsub("%w+", helper):find"%S") then return t end
	end
	
	string.separate = function(separator, string)
		local a, b = {}, 0
		if (#string == 1) then return string end
	    while (true) do
			local nextSeparator = string.find(string, separator, b + 1, true)
			if (nextSeparator ~= nil) then
				table.insert(a, string.sub(string,b,nextSeparator-1)) 
				b = nextSeparator + 1 
			else
				table.insert(a, string.sub(string, b))
				break 
			end
	    end
		return a
	end

function createClass(parent)
	local newClass = {}
	function newClass:new(instance)
		local instance = instance or {}
		setmetatable(instance, {__index = newClass})
		return instance
	end

	if(parent ~= nil) then
		setmetatable(newClass, {__index = parent})
	end

	function newClass:getSelf()
		return newClass
	end

	function newClass:getParent()
		return baseClass
	end

	function newClass:isa(class)
		local tmp = newClass
		while(tmp ~= nil) do
			if(tmp == class) then
				return true
			end

			tmp = tmp:getParent()
		end

		return false
	end
	
	function newClass:setAttributes(attributes)
		for k, v in pairs(attributes) do
			newClass[k] = v
		end
	end

	return newClass
end

Result = createClass(nil)
Result:setAttributes({
	id = -1,
	query = ""
})

function Result:getID()
	return self.id
end

function Result:setID(_id)
	self.id = _id
end

function Result:getQuery()
	return self.query
end

function Result:setQuery(_query)
	self.query = _query
end

function Result:create(_query)
	self:setQuery(_query)
	local _id = db.storeQuery(self:getQuery())
	if(_id) then
		self:setID(_id)
	end

	return self:getID()
end

function Result:getRows(free)
	local free = free or false
	if(self:getID() == -1) then
		error("[Result:getRows] Result not set!")
	end

	local c = 0
	repeat
		c = c + 1
	until not self:next()

	local _query = self:getQuery()
	self:free()
	if(not free) then
		self:create(_query)
	end

	return c
end

function Result:getDataInt(s)
	if(self:getID() == -1) then
		error("[Result:getDataInt] Result not set!")
	end

	return result.getDataInt(self:getID(), s)
end

function Result:getDataLong(s)
	if(self:getID() == -1) then
		error("[Result:getDataLong] Result not set!")
	end

	return result.getDataLong(self:getID(), s)
end

function Result:getDataString(s)
	if(self:getID() == -1) then
		error("[Result:getDataString] Result not set!")
	end

	return result.getDataString(self:getID(), s)
end

function Result:getDataStream(s)
	if(self:getID() == -1) then
		error("[Result:getDataStream] Result not set!")
	end

	return result.getDataStream(self:getID(), s)
end

function Result:next()
	if(self:getID() == -1) then
		error("[Result:next] Result not set!")
	end

	return result.next(self:getID())
end

function Result:free()
	if(self:getID() == -1) then
		error("[Result:free] Result not set!")
	end

	self:setQuery("")
	local ret = result.free(self:getID())
	self:setID(-1)
	return ret
end

Result.numRows = Result.getRows
function db.getResult(query)
	if(type(query) ~= 'string') then
		return nil
	end

	local ret = Result:new()
	ret:create(query)
	return ret
end

Quem puder me ajudar, minha eterna gratidão!

'

 



Tibia Gold Times 7.4

Em breve

 

 

~ Holly Angel come back !

Kemix

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/06/06Posts: 15Gênero: Masculino


function checkStages(cid)

 

local premiumexp = 2 --- edite qual multiplicador você quer na exp normal

 

local level = getPlayerLevel(cid)

if isPromoted(cid) == false then premiumexp = 1 end

 

for i = 1, # STAGES do

if (level >= STAGES.level) then

doPlayerSetRate(cid, 8, STAGES.rate * premiumexp)

return

end

end

 

doPlayerSetRate(cid, 8, DEFAULT_RATE)

end