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

Solved NPC's gives person 2 golden nuggets and other Error! :)

  • Thread starter Thread starter LordVissie
  • Start date Start date
L

LordVissie

Guest
Hi, I got a problem with ( I think ) my Changegold.lua:

When I buy for example 100 strong mana pots I'll get the pots and 2 golden nuggets like this:
48c8a6359b72bbf3a81996903cd0e7bd.png


Also if I change 100cc to a golden nugget it gives me this error:
Code:
[03/10/2015 20:12:09] [Error - Action Interface]
[03/10/2015 20:12:09] data/actions/scripts/other/changegold.lua:onUse
[03/10/2015 20:12:09] Description:
[03/10/2015 20:12:09] data/actions/scripts/other/changegold.lua:26: attempt to index field '?' (a nil value)
[03/10/2015 20:12:09] stack traceback:
[03/10/2015 20:12:09]     data/actions/scripts/other/changegold.lua:26: in function <data/actions/scripts/other/changegold.lua:13>

Changing 100cc to 1 golden nugget or vice-versa works good but It still gives me the error. If I need to post any more scripts please tell me.

My Changegold.lua:
Code:
local coins = {
[ITEM_GOLD_COIN] = {
to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
},
[ITEM_PLATINUM_COIN] = {
from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
},
[ITEM_CRYSTAL_COIN] = {
from = ITEM_PLATINUM_COIN, to = 2157, effect = TEXTCOLOR_TEAL
},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
return false
end

local coin = coins[item.itemid]
if(not coin) then
return false
end

if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
doChangeTypeItem(item.uid, item.type - item.type)
doPlayerAddItem(cid, coin.to, 1)
doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
elseif(coin.from ~= nil) then
doChangeTypeItem(item.uid, item.type - 1)
doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
end
return true
end

My Changenugget.lua:
Code:
--Configurations
local ITEM_NUGGET = 2157 -- Nugget ID
--End of Configs

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == ITEM_NUGGET then --Nugget to Crystal Coin
    doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "Crystal", TEXTCOLOR_TEAL)
      else
        return FALSE
    end
    return TRUE
end

I'm using version 0.3.6!
__________________
Thanks for the help.

Cya :D
 
Last edited by a moderator:
Which version of TFS are you using?
The error says it's in changegold.lua, not Changenugget.lua, and there is no line 26 in that script.
Looks like Changenugget.lua is for changing nuggets to crystal coins and not the other way around.

Could you post data/actions/scripts/other/changegold.lua?
 
It's this line:
Code:
doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
coin.to for crystal coins is 2157 (I'm assuming golden nugget), but there is no field in the table with that index. Either you use the effect (textcolor) from the coin you used, coin.effect, or add golden nugget to the list:
Code:
local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = 2157, effect = TEXTCOLOR_TEAL
    },
    [2157] = {
        from = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_TEAL
    },
}
 
It's this line:
Code:
doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
coin.to for crystal coins is 2157 (I'm assuming golden nugget), but there is no field in the table with that index. Either you use the effect (textcolor) from the coin you used, coin.effect, or add golden nugget to the list:
Code:
local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = 2157, effect = TEXTCOLOR_TEAL
    },
    [2157] = {
        from = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_TEAL
    },
}
Thanks for the help, error is gone :)

I fixed the first bug (Free 2 gn bug) I apperently had 1 "zero" to less in "value" it needed to be 1000000 instead of 100000 mb :confused:
 
Back
Top