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

getPlayerCap(cid)

Vitor Amaral

New Member
Joined
Sep 20, 2009
Messages
20
Reaction score
0
Hello,

I just need this funciont "getPlayerCap(cid)" that return cap from a character and not freecap. I will not use that to check how much capacity u need to take some items.

I tryed to do that, but i did something wrong.

So, if someone help me, I will rep +.

Thanks for everything,

Bye :)
 
Hello,

I just need this funciont "getPlayerCap(cid)" that return cap from a character and not freecap. I will not use that to check how much capacity u need to take some items.

I tryed to do that, but i did something wrong.

So, if someone help me, I will rep +.

Thanks for everything,

Bye :)

It doesn't exist, but it could be done, I just don't know as of now, if it stores full cap in the db.
 
@Vitor Amaral
Você quer que Pegue a capacidade que o player tem? No total?
se sim:
-------
You Want the total cap from the player?
if yes:

-----

Code:
function getItemsInContainer(container) -- Function By Kydrai/Modifiqued by MaXwEllDeN
local items = {}
      if isContainer(container) and getContainerSize(container) > 0 then
         for slot=0, (getContainerSize(container)-1) do
             local item = getContainerItem(container, slot)
             if isContainer(item.uid) then
                local itemsbag = getItemsInContainerById(item.uid)
                for i=0, #itemsbag do
                    table.insert(items, itemsbag[i])
                end
             else
                    table.insert(items, item)
             end
         end
      end
return items
end

function getPlayerTotalCap(uid, arredondar) -- Function By MaXwEllDeN
   local free = getPlayerFreeCap(uid)
   local total = 0
   local items_check = {}
   for a = 1, 10 do   
      local item = getPlayerSlotItem(uid, a)
      if (item.uid > 0) and not (isInArray(items_check, item.itemid))then
         if (isContainer(item.uid)) then         
            local items = getItemsInContainer(item.uid)
            for a, b in pairs(items) do
                if not (isInArray(items_check, b.itemid)) then
                   table.insert(items_check, b.itemid)
                   total = total + getItemWeightById(b.itemid, getPlayerItemCount(uid, b.itemid))
                end                                            
            end
         else
            total = total + getItemWeightById(item.itemid, getPlayerItemCount(uid, item.itemid))
         end
      end 
   end

   return arredondar == true and math.ceil(free+total) or free+total
end
 
Last edited:
Lua:
function getPlayerCap(cid)
	query = db.getResult("SELECT `cap` FROM `players` WHERE `player_id` = '" .. getPlayerGUID(cid) .. "';")
	if(query:getID() < 1) then
		return nil
	end
	cap = query:getDataInt("cap")
	query:free()
	return cap
end
 
just find return std::max(0.00, capacity - inventoryWeight); in double Player::getFreeCapacity() const
remove - inventoryWeight, then you are done
and create a new function
 
Back
Top