• 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 Upgrade Item Script, continous errors.

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,740
Solutions
7
Reaction score
541
Location
Canada
Define the Error: When the items are on the ground they do not get removed (can make infinite sets), if player does not have items required in config it still makes it anyway!

Code:
local set = {
  [2491] = {Armor = 7902, Name = 'Frozen Mask', Item_Remove = { {2491, 1}, {8300, 1}, {5944, 5} }, Storage = 42824},
   [2487] = {Armor = 7897, Name = 'Frozen Robe', Item_Remove = { {2487, 1}, {8300, 1}, {5944, 5} }, Storage = 42825},
   [2488] = {Armor = 7896, Name = 'Frozen Kilt', Item_Remove = { {2488, 1}, {8300, 1}, {5944, 5} }, Storage = 42826},
   [2519] = {Armor = 8907, Name = 'Frozen Shield', Item_Remove = { {2519, 1}, {8300, 1}, {5944, 5} }, Storage = 42827}
}

-- Do not edit below, only edit the table 'set' that is above. You can add as many items to upgrade as possible.
function onUse(cid, item, fromPosition, itemEx, toPosition)
  if set[itemEx.itemid] then
  local give = set[itemEx.itemid]
  if getPlayerStorageValue(cid, give.Storage) == 10 then
  doCreatureSay(cid, 'You can only upgrade this piece once.', TALKTYPE_ORANGE_1)
  return false
  end
  doPlayerAddItem(cid, give.Armor, 1)
  for i = 1, #give.Item_Remove do
  doPlayerRemoveItem(cid, give.Item_Remove[i][1], give.Item_Remove[i][2])
  end
  setPlayerStorageValue(cid, give.Storage, 1)
  doCreatureSay(cid, 'Your item has been upgraded to a '.. give.Name .. '.', TALKTYPE_ORANGE_1)
  else
  doCreatureSay(cid, 'This item cannot be upgraded.', TALKTYPE_ORANGE_1)
  return false
  end
  
return true
end

Would be lovely to have a "You don't have the required items" message when it detects that the player does not have the items.
 
Last edited:
The errors are useless, since the errors pertain to me trying to switch the script to read multiple items. Some one that knows all the functions and how to use them will see the errors easily I hope, I just need this converted to upgrade an entire set instead of one item..
 
I cannot help you beyond this point, if you don't know how to read this code or even edit it, then put your nose to the grindstone and read up how to script/program on Lua.
Code:
local set = {
    ['1337'] = {Armor = 1234, Name = 'Frost Armor', Item_Remove = { {1235, 1}, {1236, 5} }, Storage = 42825}
}

-- Do not edit below, only edit the table 'set' that is above. You can add as many items to upgrade as possible.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if set[itemEx.itemid] then
        local give = set[itemEx.itemid]
        if getPlayerStorageValue(cid, give.Storage) == 1 then
            doCreatureSay(cid, 'You can only upgrade this piece once.', TALKTYPE_ORANGE_1)
            return false
        end
        doPlayerAddItem(cid, give.Armor, 1)
        for i = 1, #give.Item_Remove do
            doPlayerRemoveItem(cid, give.Item_Remove[i][1], give.Item_Remove[i][2])
        end
        setPlayerStorageValue(cid, give.Storage, 1)
        doCreatureSay(cid, 'Your item has been upgraded to a '.. give.Name .. '.', TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'This item cannot be upgraded.', TALKTYPE_ORANGE_1)
        return false
    end
   
return true
end
 
Thank you so much, I know how to read the code; but when it comes to actually reworking the functions I dont know which pointers to set to make sure the function works properly. With what you have provided I will be able to easily configure it, thank you so much!
 
if you want to get a small read on most of the functions on your server, go to "Your Server Folder"/docs/functions
it contains an "Up to date" list of all functions belonging to that server.
 
@Shinmaru - Thank you, I will start reading into this! By the way, am I doing something wrong? I am trying to allow a crown armor to be upgraded into a glacier robe (frozen armor), it looks right to me..

Using a Flawless Ice Crystal as the item to change the Crown Armor - I have also tried changing the item id to crown armor and it still doesnt work ;\
Code:
<action itemid="8300" event="script" value="war/frozen_stone.lua"/>

Code:
local set = {
  ['2487'] = {Armor = 7897, Name = 'Frozen Armor', Item_Remove = { {8300, 1}, {5944, 5} }, Storage = 42825}
}

-- Do not edit below, only edit the table 'set' that is above. You can add as many items to upgrade as possible.
function onUse(cid, item, fromPosition, itemEx, toPosition)
  if set[itemEx.itemid] then
  local give = set[itemEx.itemid]
  if getPlayerStorageValue(cid, give.Storage) == 1 then
  doCreatureSay(cid, 'You can only upgrade this piece once.', TALKTYPE_ORANGE_1)
  return false
  end
  doPlayerAddItem(cid, give.Armor, 1)
  for i = 1, #give.Item_Remove do
  doPlayerRemoveItem(cid, give.Item_Remove[i][1], give.Item_Remove[i][2])
  end
  setPlayerStorageValue(cid, give.Storage, 1)
  doCreatureSay(cid, 'Your item has been upgraded to a '.. give.Name .. '.', TALKTYPE_ORANGE_1)
  else
  doCreatureSay(cid, 'This item cannot be upgraded.', TALKTYPE_ORANGE_1)
  return false
  end

return true
end

2487 = crown armor, 8797 = glacier robe.. what seems to be the problem?
 
Last edited:
@Shinmaru - It just says "This item cannot be upgraded." ingame, no console errors. I have tried every possible way for the item ids to go, and nothing makes it work ;[
 
@Shinmaru - On this script, if a player uses on an ice crystal on a crown armor on the ground. The crown armor will stay on the ground, and the player will still get the frozen armor.

Is there any way to make it so the item MUST be in the backpack, or that it finds the item on the ground and removes it? I think the best would be to make the item be in backpack, but whoever fixes it do whatever works. Thanks in advance!
 
Correction: If you put both the crystal and the armor on the ground, you can keep both items and do it forever! Lol, it does not remove the items from the ground!
 
Updated the main post with the new configurations and a definition of the problems in the script. (No errors in console, just problems with the script)
 
Code:
local set = {
    [2491] = {Armor = 7902, Name = 'Frozen Mask', Item_Remove = { {2491, 1}, {8300, 1}, {5944, 5} }, Storage = 42824},
    [2487] = {Armor = 7897, Name = 'Frozen Robe', Item_Remove = { {2487, 1}, {8300, 1}, {5944, 5} }, Storage = 42825},
    [2488] = {Armor = 7896, Name = 'Frozen Kilt', Item_Remove = { {2488, 1}, {8300, 1}, {5944, 5} }, Storage = 42826},
    [2519] = {Armor = 8907, Name = 'Frozen Shield', Item_Remove = { {2519, 1}, {8300, 1}, {5944, 5} }, Storage = 42827}
}

-- Do not edit below, only edit the table 'set' that is above. You can add as many items to upgrade as possible.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if set[itemEx.itemid] then
        local give = set[itemEx.itemid]
        if getPlayerStorageValue(cid, give.Storage) == 10 then
            doCreatureSay(cid, 'You can only upgrade this piece once.', TALKTYPE_ORANGE_1)
            return false
        end
      
        for i = 1, #give.Item_Remove do
            if not (getPlayerItemCount(cid, give.Item_Remove[i][1]) >= give.Item_Remove[i][2]) then
                doCreatureSay(cid, 'Missing item...' .. getItemNameById(give.Item_Remove[i][1]), TALKTYPE_ORANGE_1)
                return false
            end
        end

        for i = 1, #give.Item_Remove do
            doPlayerRemoveItem(cid, give.Item_Remove[i][1], give.Item_Remove[i][2])
        end

        doPlayerAddItem(cid, give.Armor, 1)
        setPlayerStorageValue(cid, give.Storage, 1)
        doCreatureSay(cid, 'Your item has been upgraded to a '.. give.Name .. '.', TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'This item cannot be upgraded.', TALKTYPE_ORANGE_1)
        return false
    end

    return true
end
try this
 
Last edited:
Oh thank you so much sir, shocked me with this post - I know you're busy with OTList, much appreciated!
 
Last edited:
Back
Top