Lua Problem attempt to perform arithmetic on a string value

Discussion in 'Support' started by dervin13, Aug 7, 2018.

  1. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    Hi, can anyone help me with this?

    [Error - CreatureScript Interface]
    data/creaturescripts/scripts/rewardchest_boss.lua:eek:nStatsChange
    Description:
    data/creaturescripts/scripts/rewardchest_boss.lua:104: attempt to perform arithmetic on a string value
    stack traceback:
    data/creaturescripts/scripts/rewardchest_boss.lua:104: in function <data/creaturescripts/scripts/rewardchest_boss.lua:100>

    Code (Text):
    1. dofile('data/sistemas/rewardchest.lua')
    2.  
    3. local function addRewardLoot(uid, bossName, tabela_reward)
    4.     local money = math.random(10, 40)
    5.     local msg = "The following items are available in your reward chest:"
    6.     local chest = doCreateItemEx(REWARDCHEST.rewardBagId)
    7.  
    8. doItemSetAttribute(chest, "description", "Reward System has kill the boss ".. bossName ..".")
    9.  
    10.     if table.maxn(tabela_reward) > 0 then
    11.         for x = 1, table.maxn(tabela_reward) do
    12.             local rand = math.random(100)
    13.             if rand <= tabela_reward[x][3] then
    14.                 local count = math.random(1, tabela_reward[x][2])
    15.                 doAddContainerItem(chest, tabela_reward[x][1], count)
    16. msg = msg .. " ".. (tabela_reward[x][2] > 1 and tabela_reward[x][2] or "") .." ".. getItemNameById(tabela_reward[x][1]) ..","
    17.             end
    18.         end
    19.         doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " and ".. money .." platinum coins.")
    20.     else
    21.         doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " ".. money .." platinum coins.")
    22.     end
    23.  
    24.     doAddContainerItem(chest, 2152, money)
    25.     doPlayerSendMailByName(getPlayerName(uid), chest, REWARDCHEST.town_id)
    26.  
    27.     local boss = REWARDCHEST.bosses[bossName]
    28.     setPlayerStorageValue(uid, boss.storage, 0)
    29.     doSendMagicEffect(getPlayerPosition(uid), CONST_ME_MAGIC_BLUE)
    30. end
    31.  
    32. local function addLoot(tabela_loot, tabela_reward, all_loot)
    33.     if table.maxn(tabela_loot) > 0 then
    34.         if all_loot then
    35.             for x = 1, table.maxn(tabela_loot) do
    36.                 table.insert(tabela_reward, tabela_loot[x])
    37.             end
    38.         else
    39.             table.insert(tabela_reward, tabela_loot[math.random(table.maxn(tabela_loot))])
    40.         end
    41.     end
    42.  
    43.     return tabela_reward
    44. end
    45.  
    46. local function rewardChestSystem(bossName)
    47.     local players = {}
    48.     local boss = REWARDCHEST.bosses[bossName]
    49.  
    50.     for _, uid in ipairs(getPlayersOnline()) do
    51.         if getPlayerStorageValue(uid, boss.storage) > 0 then
    52.             table.insert(players, uid)
    53.         end
    54.     end
    55.  
    56.     table.sort(players, function(a, b) return getPlayerStorageValue(a, boss.storage) > getPlayerStorageValue(b, boss.storage) end)
    57.  
    58.     local porcentagem = math.ceil(getPlayerStorageValue(players[1], boss.storage))
    59.  
    60.     for i = 1, table.maxn(players) do
    61.  
    62.         local tabela_reward = {}
    63.         local pontos = getPlayerStorageValue(players[i], boss.storage)
    64.  
    65.         if i == 1 then
    66.             addLoot(boss.comum, tabela_reward, false)
    67.             addLoot(boss.semi_raro, tabela_reward, false)
    68.             addLoot(boss.raro, tabela_reward, false)
    69.             addLoot(boss.sempre, tabela_reward, true)
    70.         elseif i >= 2 and pontos >= math.ceil((porcentagem * 0.8)) then
    71.             addLoot(boss.comum, tabela_reward, false)
    72.             addLoot(boss.semi_raro, tabela_reward, false)
    73.             addLoot(boss.raro, tabela_reward, false)
    74.             addLoot(boss.muito_raro, tabela_reward, false)
    75.         elseif pontos < math.ceil((porcentagem * 0.8)) and pontos >= math.ceil((porcentagem * 0.6)) then
    76.             addLoot(boss.comum, tabela_reward, false)
    77.             addLoot(boss.semi_raro, tabela_reward, false)
    78.             addLoot(boss.raro, tabela_reward, false)
    79.         elseif pontos < math.ceil((porcentagem * 0.6)) and pontos >= math.ceil((porcentagem * 0.4)) then
    80.             addLoot(boss.comum, tabela_reward, false)
    81.             addLoot(boss.semi_raro, tabela_reward, false)
    82.         elseif pontos < math.ceil((porcentagem * 0.4)) and pontos >= math.ceil((porcentagem * 0.1)) then
    83.             addLoot(boss.comum, tabela_reward, false)
    84.         end
    85.  
    86.         addRewardLoot(players[i], bossName, tabela_reward)
    87.     end
    88. end
    89.  
    90. function onDeath(cid, corpse, killer)
    91.     local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
    92.     if boss then
    93.         addEvent(rewardChestSystem, 1000, getCreatureName(cid):lower())
    94.     end
    95.     return true
    96. end
    97.  
    98. function onStatsChange(cid, attacker, type, combat, value)
    99.     if isMonster(cid) and type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
    100.         local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
    101.         if boss and attacker then
    102.             setPlayerStorageValue(attacker, boss.storage, getPlayerStorageValue(attacker, boss.storage) + math.ceil((value / REWARDCHEST.formula.hit)))
    103.         end
    104.     end
    105.     return true
    106. end
    Rewardchest

    Code (Text):
    1. REWARDCHEST = {
    2.     rewardBagId = 2595,
    3.     formula = {hit = 3, block = 1, suport = 9},
    4.     storageExaust = 60000,
    5.     town_id = 1,
    6.     bosses = {
    7.         ["ghazbaran"] =
    8.         {
    9.             comum = {
    10.                 {2143, 10, 100}, -- white pearl
    11.                 {2146, 10, 100}, -- small sapphire
    12.                 {2145, 10, 100}, -- small diamond
    13.                 {2144, 10, 100}, -- black pearl
    14.                 {2149, 10, 100}, -- small emeralds
    15.                 {5954, 3, 100}, -- demon horn
    16.                 {7896, 1, 100}, -- glacier kilt
    17.                 {7590, 1, 100}, -- great mana potion
    18.                 {2179, 1, 100}, -- gold ring
    19.                 {2151, 1, 100}, -- talon
    20.             },
    21.  
    22.             semi_raro = {
    23.                 {2152, 90, 100}, -- platinum coin
    24.                 {7368, 50, 100}, -- assassin star
    25.                 {2130, 1, 100}, -- golden amulet
    26.                 {2436, 1, 100}, -- skull staff
    27.                 {2447, 1, 100}, -- twin axe
    28.                 {2171, 1, 100}, -- platinum amulet
    29.                 {2158, 1, 100}, -- blue gem
    30.                 {2393, 1, 100}, -- giant sword
    31.                 {2164, 1, 100}, -- might ring
    32.                 {7454, 1, 100}, -- glorious axe
    33.                 {6553, 1, 100}, -- ruthless axe
    34.                 {9971, 1, 100}, -- gold ingot
    35.             },
    36.  
    37.             raro = {
    38.                 {2160, 3, 100}, -- crystal coin
    39.                 {8887, 1, 100}, -- frozen plate
    40.                 {2470, 1, 100}, -- golden legs
    41.                 {2472, 1, 100}, -- magic plate armor
    42.                 {7431, 1, 100}, -- demonbone
    43.                 {2520, 1, 100}, -- demon shield
    44.                 {5943, 1, 100}, -- morgaroth hearth
    45.                 {2466, 1, 100}, -- golden armor
    46.                 {2514, 1, 100}, -- mastermind shield
    47.                 {2142, 1, 100}, -- ancient amulet
    48.                 {2123, 1, 100}, -- ring of the sky
    49.                 {1984, 1, 100}, -- blue tome
    50.             },
    51.  
    52.             muito_raro = {
    53.                 {8866, 1, 100}, -- robe of the ice queen
    54.                 {6553, 1, 100}, -- ruthless axe
    55.                 {8884, 1, 100}, -- oceanborn leviathan armor
    56.                 {2421, 1, 100}, -- thunder hammer
    57.                 {2646, 1, 100}, -- golden boots
    58.                 {7455, 1, 100}, -- mythril axe
    59.             },
    60.          
    61.             sempre = {
    62.                 {2148, 90, 100}, -- gold coin
    63.                 {6500, 9, 100}, -- demonic essence
    64.                 {2177, 1, 100}, -- life crystal
    65.                 {2214, 1, 100}, -- ring of healing
    66.             },
    67.          
    68.             storage = 65479,
    69.         },
    70.      
    71.         ["orshabaal"] =
    72.         {
    73.             comum = {
    74.                 {2143, 10, 100}, -- white pearl
    75.                 {2146, 10, 100}, -- small sapphire
    76.                 {2145, 10, 100}, -- small diamond
    77.                 {2144, 10, 100}, -- black pearl
    78.                 {2149, 10, 100}, -- small emeralds
    79.                 {5954, 3, 100}, -- demon horn
    80.                 {7896, 1, 100}, -- glacier kilt
    81.                 {2432, 1, 100}, -- fire axe
    82.                 {2462, 1, 100}, -- devil helmet
    83.                 {7590, 1, 100}, -- great mana potion
    84.                 {2179, 1, 100}, -- gold ring
    85.                 {2151, 1, 100}, -- talon
    86.             },
    87.  
    88.             semi_raro = {
    89.                 {2195, 1, 100}, -- boots of haste
    90.                 {2436, 1, 100}, -- skull staff
    91.                 {2393, 1, 100}, -- giant sword
    92.                 {5954, 5, 100}, -- demon horn
    93.             },
    94.  
    95.             raro = {
    96.                 {2470, 1, 100}, -- golden legs
    97.                 {2472, 1, 100}, -- magic plate armor
    98.                 {2514, 1, 100}, -- mastermind shield
    99.                 {2520, 1, 100}, -- demon shield
    100.                 {1982, 1, 100}, -- purple tome
    101.                 {2123, 1, 100}, -- ring of the sky
    102.             },
    103.  
    104.             muito_raro = {
    105.                 {8890, 1, 100}, -- Robe of the underworld
    106.                 {2421, 1, 100}, -- thunder hammer
    107.             },
    108.          
    109.             sempre = {
    110.                 {5808, 1, 100}, -- orshabaals brain
    111.                 {2171, 1, 100}, -- platinum amulet
    112.                 {2148, 90, 100}, -- gold coin
    113.                 {2146, 10, 100}, -- small sapphire
    114.             },
    115.          
    116.             storage = 65480,
    117.         },
    118.      
    119.         ["ferumbras"] =
    120.         {
    121.             comum = {
    122.                 {2143, 10, 100}, -- white pearl
    123.                 {2146, 10, 100}, -- small sapphire
    124.                 {2145, 10, 100}, -- small diamond
    125.                 {2144, 10, 100}, -- black pearl
    126.                 {2149, 10, 100}, -- small emeralds
    127.                 {7416, 1, 100}, -- Bloody Edge
    128.                 {7896, 1, 100}, -- glacier kilt
    129.                 {2432, 1, 100}, -- fire axe
    130.                 {2462, 1, 100}, -- devil helmet
    131.                 {7590, 1, 100}, -- great mana potion
    132.                 {2179, 1, 100}, -- gold ring
    133.                 {2151, 1, 100}, -- talon
    134.             },
    135.  
    136.             semi_raro = {
    137.                 {2195, 1, 100}, -- boots of haste
    138.                 {2472, 1, 100}, -- magic plate armor
    139.                 {2393, 1, 100}, -- giant sword
    140.                 {2470, 1, 100}, -- golden legs
    141.                 {2514, 1, 100}, -- mastermind shield
    142.             },
    143.             raro = {
    144.                 {8885, 1, 100}, -- divine plate
    145.                 {2520, 1, 100}, -- demon shield
    146.                 {8930, 1, 100}, -- emerald sword
    147.                 {2522, 1, 100}, -- great shield
    148.                 {2421, 1, 100}, -- thunder hammer
    149.             },
    150.  
    151.             muito_raro = {
    152.                 {5903, 1, 100}, -- ferumbras hat
    153.             },
    154.          
    155.             sempre = {
    156.                 {2171, 1, 100}, -- platinum amulet
    157.                 {2148, 90, 100}, -- gold coin
    158.                 {2146, 10, 100}, -- small sapphire
    159.             },
    160.          
    161.             storage = 65481,
    162.         },
    163.         ["zulazza the corruptor"] =
    164.         {
    165.             comum = {
    166.                 {2158, 1, 100}, -- blue gem
    167.                 {2156, 1, 100}, -- red gem
    168.                 {2155, 1, 100}, -- green gem
    169.                 {2154, 1, 100}, -- yellow gem
    170.                 {2153, 1, 100}, -- violet gem
    171.             },
    172.  
    173.             semi_raro = {
    174.                 {5944, 5, 100}, -- soul orb
    175.             },
    176.  
    177.             raro = {
    178.                 {2514, 1, 100}, -- mastermind shield
    179.             },
    180.  
    181.             muito_raro = {
    182.                 {11114, 1, 100}, -- dragon scale boots
    183.                 {8882, 1, 100}, -- earthborn titan armor
    184.             },
    185.          
    186.             sempre = {
    187.                 {2152, 90, 100}, -- platinum coin
    188.                 {9971, 5, 100}, -- gold ingot
    189.             },
    190.          
    191.             storage = 65482,
    192.         },
    193.         ["morgaroth"] =
    194.         {
    195.             comum = {
    196.                 {2143, 10, 100}, -- white pearl
    197.                 {2146, 10, 100}, -- small sapphire
    198.                 {2145, 10, 100}, -- small diamond
    199.                 {2144, 10, 100}, -- black pearl
    200.                 {2149, 10, 100}, -- small emeralds
    201.                 {5954, 3, 100}, -- demon horn
    202.                 {7896, 1, 100}, -- glacier kilt
    203.                 {2432, 1, 100}, -- fire axe
    204.                 {2462, 1, 100}, -- devil helmet
    205.                 {7590, 1, 100}, -- great mana potion
    206.                 {2179, 1, 100}, -- gold ring
    207.                 {2151, 1, 100}, -- talon
    208.             },
    209.  
    210.             semi_raro = {
    211.                 {2195, 1, 100}, -- boots of haste
    212.                 {2393, 1, 100}, -- giant sword
    213.                 {5954, 5, 100}, -- demon horn
    214.                 {2123, 1, 100}, -- ring of the sky
    215.             },
    216.  
    217.             raro = {
    218.                 {8886, 1, 100}, -- molten plate
    219.                 {2472, 1, 100}, -- magic plate armor
    220.                 {8867, 1, 100}, -- dragon robe
    221.                 {2514, 1, 100}, -- mastermind shield
    222.                 {2520, 1, 100}, -- demon shield
    223.                 {1982, 1, 100}, -- purple tome
    224.                 {8851, 1, 100}, -- Royal Crossbow
    225.             },
    226.  
    227.             muito_raro = {
    228.                 {2421, 1, 100}, -- thunder hammer
    229.                 {2522, 1, 100}, -- great shield
    230.                 {8850, 1, 100}, -- chain bolter
    231.             },
    232.          
    233.             sempre = {
    234.                 {5943, 1, 100}, -- morgaroths brain
    235.                 {2171, 1, 100}, -- platinum amulet
    236.                 {2148, 90, 100}, -- gold coin
    237.                 {2146, 10, 100}, -- small sapphire
    238.             },
    239.             storage = 65483,
    240.         },
    241.     }
    242. }
    reward pontos
    Code (Text):
    1. dofile('data/sistemas/rewardchest.lua')
    2.  
    3. function onLogin(cid)
    4.     for key, value in pairs(REWARDCHEST.bosses) do
    5.         if getPlayerStorageValue(cid, value.storage) > 0 then
    6.             setPlayerStorageValue(cid, value.storage, 0)
    7.         end
    8.     end
    9.     registerCreatureEvent(cid, "RewardChestStats")
    10.     return true
    11. end
    12.  
    13. function onStatsChange(cid, attacker, type, combat, value)
    14.     if isMonster(attacker) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) then
    15.         local boss = REWARDCHEST.bosses[getCreatureName(attacker):lower()]
    16.         if boss then
    17.             setPlayerStorageValue(cid, boss.storage, getPlayerStorageValue(cid, boss.storage) + math.ceil((value / REWARDCHEST.formula.block)))
    18.             setPlayerStorageValue(cid, REWARDCHEST.storageExaust, os.time() + 5)
    19.         end
    20.     elseif (isPlayer(attacker) and (type == STATSCHANGE_HEALTHGAIN or type == STATSCHANGE_MANAGAIN) and (getCreatureHealth(cid) < getCreatureMaxHealth(cid)) and (getPlayerStorageValue(cid, REWARDCHEST.storageExaust) >= os.time())) then
    21.         for key, valor in pairs(REWARDCHEST.bosses) do
    22.             if getPlayerStorageValue(cid, valor.storage) > 0 then
    23.                 if getCreatureHealth(cid) + value > getCreatureMaxHealth(cid) then
    24.                     local add = getCreatureMaxHealth(cid) - getCreatureHealth(cid)
    25.                     setPlayerStorageValue(attacker, valor.storage, getPlayerStorageValue(attacker, valor.storage) + math.ceil((add / REWARDCHEST.formula.suport)))
    26.                 else
    27.                     setPlayerStorageValue(attacker, valor.storage, getPlayerStorageValue(attacker, valor.storage) + math.ceil((value / REWARDCHEST.formula.suport)))
    28.                 end
    29.             end
    30.         end
    31.     end
    32.     return true
    33. end
     
    Last edited: Aug 8, 2018
  2. Jo3Bingham

    Jo3Bingham Well-Known Member

    Joined:
    Mar 3, 2008
    Messages:
    967
    Likes Received:
    403
    Best Answers:
    3
    Your error is happening on this line:
    Code (Text):
    1.  
    2. setPlayerStorageValue(attacker, boss.storage, getPlayerStorageValue(attacker, boss.storage) + math.ceil((value / REWARDCHEST.formula.hit)))
    3.  
    My guess is, more specifically, here:
    Code (Text):
    1.  
    2. (value / REWARDCHEST.formula.hit)
    3.  
    value shouldn't be a string, so it's more likely that REWARDCHEST.formula.hit is. However, you didn't include your rewardchest.lua code, so it's hard to say for certain.
     
    dervin13 likes this.
  3. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    Yes, is something wrong with this formula I think, but I dont know what... I put the reward chest
     
  4. Jo3Bingham

    Jo3Bingham Well-Known Member

    Joined:
    Mar 3, 2008
    Messages:
    967
    Likes Received:
    403
    Best Answers:
    3
    Ok, so REWARDCHEST.formula.hit isn't a string so value must be. Use print(type(value)) to confirm it's the variable that's actually a string. Did you write this reward chest system, or are you using a public one? You might want to look at the code that calls onStatsChange and see if value is being passed as a string.
     
    dervin13 likes this.
  5. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,870
    Likes Received:
    1,754
    Best Answers:
    292
    in older versions storage values use strings
    check the storage value using print(getPlayerStorageValue(attacker, boss.storage))
     
    dervin13 likes this.
  6. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    I'm using a public one @Jo3Bingham

    Code (Text):
    1.  stack traceback:
    2. data/creaturescripts/scripts/rewardchest_boss.lua:105: in function <data/creaturescripts/scripts/rewardchest_boss.lua:100>
    3. 12983534
    4. 12985205
    5. 21152557
    6. 21153224
    7. └ e
    8.  
    9. [Error - CreatureScript Interface]
    10. data/creaturescripts/scripts/rewardchest_boss.lua:onStatsChange
    11. Description:
    12. data/creaturescripts/scripts/rewardchest_boss.lua:105: attempt to perform arithmetic on a string value
    13. stack traceback:
    14. data/creaturescripts/scripts/rewardchest_boss.lua:105: in function <data/creaturescripts/scripts/rewardchest_boss.lua:100>
    15. 21153224
    16. 21161710
    17. 12986585
    18. 12987734
    19. 21161710
    20. 21162472
    21. └ e
    22.  
     
  7. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    I put all scripts related to the this system in the first post
     
  8. Jo3Bingham

    Jo3Bingham Well-Known Member

    Joined:
    Mar 3, 2008
    Messages:
    967
    Likes Received:
    403
    Best Answers:
    3
    In rewardchest_boss.lua, change your onStatsChange() method to this and then show me the output.
    Code (Text):
    1.  
    2. function onStatsChange(cid, attacker, type, combat, value)
    3.     if isMonster(cid) and type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
    4.         local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
    5.         if boss and attacker then
    6.             local storageValue = getPlayerStorageValue(attacker, boss.storage)
    7.  
    8.             print('storageValue is ' .. storageValue .. ', and of type ' .. type(storageValue))
    9.             print('value is ' .. value .. ', and of type ' .. type(value))
    10.  
    11.             -- We'll leave this so we can see when the error occurs after the prints above.
    12.             setPlayerStorageValue(attacker, boss.storage, storageValue + math.ceil((value / REWARDCHEST.formula.hit)))
    13.         end
    14.     end
    15.     return true
    16. end
    17.  
     
  9. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    Code (Text):
    1.  [Error - CreatureScript Interface]
    2. data/creaturescripts/scripts/rewardchest_boss.lua:onStatsChange
    3. Description:
    4. data/creaturescripts/scripts/rewardchest_boss.lua:106: attempt to call local 'type' (a number value)
    5. stack traceback:
    6. data/creaturescripts/scripts/rewardchest_boss.lua:106: in function <data/creaturescripts/scripts/rewardchest_boss.lua:100>
     
  10. Jo3Bingham

    Jo3Bingham Well-Known Member

    Joined:
    Mar 3, 2008
    Messages:
    967
    Likes Received:
    403
    Best Answers:
    3
    My apologies, I didn’t realize there was a parameter ‘type’. Just rename the parameter to something else and rename any uses of that parameter to the new name and try it again.
     
    dervin13 and Xikini like this.
  11. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    But I can use anything? I tried _type and I had the same problem. type isn't the param to the statschange?
     
  12. Xikini

    Xikini I whore myself out for likes

    Joined:
    Nov 17, 2010
    Messages:
    3,572
    Likes Received:
    1,828
    Best Answers:
    80
    I think he means like this.
    Code (Lua):
    1. function onStatsChange(cid, attacker, _type, combat, value)
    2.     if isMonster(cid) and _type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
    3.         local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
    4.         if boss and attacker then
    5.             local storageValue = getPlayerStorageValue(attacker, boss.storage)
    6.    
    7.             print('storageValue is ' .. storageValue .. ', and of type ' .. type(storageValue))
    8.             print('value is ' .. value .. ', and of type ' .. type(value))
    9.    
    10.             -- We'll leave this so we can see when the error occurs after the prints above.
    11.             setPlayerStorageValue(attacker, boss.storage, storageValue + math.ceil((value / REWARDCHEST.formula.hit)))
    12.         end
    13.     end
    14.     return true
    15. end
     
    Jo3Bingham likes this.
  13. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    I tried this, the script was working good then this problem happened... maybe this had happened when more than 1 player start killing the boss.

    Code (Text):
    1. value is 5037182, and of type number
    2. storageValue is 3235067, and of type number
    3. value is 4730396, and of type number
    4. storageValue is └ , and of type string
    5. value is 4688775, and of type number
    6.  
    7. [Error - CreatureScript Interface]
    8. data/creaturescripts/scripts/rewardchest_boss.lua:onStatsChange
    9. Description:
    10.  data/creaturescripts/scripts/rewardchest_boss.lua:109: attempt to perform arithmetic on local 'storageValue' (a string value)
    11. stack traceback:
    12. data/creaturescripts/scripts/rewardchest_boss.lua:109: in function <data/creaturescripts/scripts/rewardchest_boss.lua:99>
    13. storageValue is └ , and of type string
    14. value is 4401966, and of type number
     
  14. Xikini

    Xikini I whore myself out for likes

    Joined:
    Nov 17, 2010
    Messages:
    3,572
    Likes Received:
    1,828
    Best Answers:
    80
    mmm I wonder..
    Is there a maximum value that the database allows storage values to hold?

    When you are attacking the monsters, the storage value continues to add to itself and increases, correct?
    So if there is a maximum value that the database is allowing for the storage value, it might be like.. overflowing?
    and at that point it doesn't know what number the storage value is since it's changed to a symbol or nil..
    which of course would cause the error we are seeing, as a symbol or nil would both not be a number.

    Just spit-balling, since I don't know the correct/definite answer to your issue.
     
    dervin13 likes this.
  15. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,870
    Likes Received:
    1,754
    Best Answers:
    292
    the problem is here (looks like you put a value that corrupted it)
    not sure we can do much to help unless you show everywhere that you change boss.storage values
     
  16. dervin13

    dervin13 Member

    Joined:
    Apr 26, 2008
    Messages:
    339
    Likes Received:
    5
    Best Answers:
    0
    Maybe was that, It was varchar 255, I had changed to varchar 2550 and the error keep occurring, now I changed to TEXT tested once and didn't have the error.

    I'll do more tests and hope to dont have any troubles this change to text :D
     

Share This Page

Loading...