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

Lua Help bug BP (+cap)

luccagomes

New Member
Joined
Jul 30, 2015
Messages
153
Reaction score
1
It's work ok, but if i relog using this bp, it give me more 1000 cap

Code:
  <!-- sorcerer -->
   <movevent type="Equip" itemid="10518" slot="backpack" event="script" value="bpscap/magevipbag.lua">
     <vocation id="1"/>
     <vocation id="5" showInDescription="0"/>
   </movevent>
   <movevent type="DeEquip" itemid="10518" slot="backpack" event="script" value="bpscap/magevipbag.lua"/>

Code:
function getPlayerCap(cid)
local query = db.getResult("SELECT `cap` FROM `players` WHERE `id` = " .. getPlayerGUID(cid))
if query:getID() ~= -1 then
return tonumber(query:getDataString("cap"))
end
return 0
end

local capacidade = 1000
function onEquip(cid, item, slot)
   if getPlayerSlotItem(cid, slot).itemid == item.itemid then
    doPlayerSetMaxCapacity(cid, (getPlayerCap(cid) + capacidade))
    doPlayerSave(cid)
  end
  return true
end

function onDeEquip(cid, item, slot)
  doPlayerSetMaxCapacity(cid,getPlayerCap(cid) - capacidade)
  doPlayerSave(cid)
  return true
end
 
Mm.. try adding a storageID.. and then check if its less then 1 or equal to 1.
Then it wont continue and increase the cap a second time.

onEquip
If storage < 1 then
equip armor, change cap, set storage 1.

onDeEquip
If storage == 1 then
remove armor, change cap, set storage 0.

Also a small bug that may or may not happen.. If they receive the item from a shop or quest and it auto equips.. Im not certain what might happen. Id check if i were you.
 
Mm.. try adding a storageID.. and then check if its less then 1 or equal to 1.
Then it wont continue and increase the cap a second time.

onEquip
If storage < 1 then
equip armor, change cap, set storage 1.

onDeEquip
If storage == 1 then
remove armor, change cap, set storage 0.

Also a small bug that may or may not happen.. If they receive the item from a shop or quest and it auto equips.. Im not certain what might happen. Id check if i were you.

How?
 
Code:
function getPlayerCap(cid)
   local query = db.getResult("SELECT `cap` FROM `players` WHERE `id` = " .. getPlayerGUID(cid))
   if query:getID() ~= -1 then
     return tonumber(query:getDataString("cap"))
   end
   return 0
end

local capacidade = 1000
function onEquip(cid, item, slot)
-- IF STORAGE_VALUE_YOU_CHOOSE < 1 THEN
     if getPlayerSlotItem(cid, slot).itemid == item.itemid then
       -- SET_THAT_STORAGE_VALUE_TO, 1
       doPlayerSetMaxCapacity(cid, (getPlayerCap(cid) + capacidade))
       doPlayerSave(cid)
     end
-- END
   return true
end

function onDeEquip(cid, item, slot)
-- IF THAT_SAME_STORAGE_VALUE_YOU_CHOSE == 1 THEN
   -- SET_THAT_SAME_STORAGE_VALUE_AS, 0
   doPlayerSetMaxCapacity(cid,getPlayerCap(cid) - capacidade)
   doPlayerSave(cid)
-- END
   return true
end
 
Code:
function getPlayerCap(cid)
   local query = db.getResult("SELECT `cap` FROM `players` WHERE `id` = " .. getPlayerGUID(cid))
   if query:getID() ~= -1 then
     return tonumber(query:getDataString("cap"))
   end
   return 0
end

local capacidade = 1000
function onEquip(cid, item, slot)
-- IF STORAGE_VALUE_YOU_CHOOSE < 1 THEN
     if getPlayerSlotItem(cid, slot).itemid == item.itemid then
       -- SET_THAT_STORAGE_VALUE_TO, 1
       doPlayerSetMaxCapacity(cid, (getPlayerCap(cid) + capacidade))
       doPlayerSave(cid)
     end
-- END
   return true
end

function onDeEquip(cid, item, slot)
-- IF THAT_SAME_STORAGE_VALUE_YOU_CHOSE == 1 THEN
   -- SET_THAT_SAME_STORAGE_VALUE_AS, 0
   doPlayerSetMaxCapacity(cid,getPlayerCap(cid) - capacidade)
   doPlayerSave(cid)
-- END
   return true
end

TYY
 
Back
Top