• 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 change gold script

megazx

Graphic designer
Joined
Mar 4, 2013
Messages
443
Solutions
2
Reaction score
32
Location
Egypt
this script change the 100 crystal coins to 1 gold nugget but whe i have 100 gold nuggets and i click on them the they vanish they dont change back to 99 gold nuggets and 100 cc so please i need a fix​
[12:45:37.653] [Error - Action Interface]
[12:45:37.653] data/actions/scripts/other/changegold.lua:eek:nUse
[12:45:37.653] Description:
[12:45:37.653] (luaDoPlayerAddItem) Item not found

this is the script​
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    elseif item.itemid == ITEM_GOLD_NUGGET and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

    elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
    elseif item.itemid == ITEM_CRYSTAL_COIN then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_GOLD_NUGGET then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    elseif item.itemid == ITEM_GOLD_INGOT then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    else
        return FALSE
    end
    return TRUE
end

 
Last edited:
Solution
i fixed it myself non of the above solve it
this is the right fix

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then...
this script change the 100 crystal coins to 1 gold nugget but whe i have 100 gold nuggets and i click on them the they vanish they dont change back to 99 gold nuggets and 100 cc so please i need a fix​
[12:45:37.653] [Error - Action Interface]
[12:45:37.653] data/actions/scripts/other/changegold.lua:eek:nUse
[12:45:37.653] Description:
[12:45:37.653] (luaDoPlayerAddItem) Item not found

this is the script​
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    elseif item.itemid == ITEM_GOLD_NUGGET and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

    elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
    elseif item.itemid == ITEM_CRYSTAL_COIN then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_GOLD_NUGGET then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    elseif item.itemid == ITEM_GOLD_INGOT then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    else
        return FALSE
    end
    return TRUE
end


If you didnt update your 000-constant.lua you have to do it.
open data/lib/000-constant.lua
then search for "ITEM_CRYSTAL_COIN"
and below it you have to add this
Lua:
ITEM_GOLD_NUGGET = 2157 -- This itemid might be wrong, check whit your server and change it.
ITEM_GOLD_INGOT = 9058 -- This itemid might be wrong, check whit your server and change it.
then your script should work, if you dont want to change your lib you can just change every ITEM_GOLD_NUGGET and ITEM_GOLD_INGOT to the itemid of the item.
 
If you didnt update your 000-constant.lua you have to do it.
open data/lib/000-constant.lua
then search for "ITEM_CRYSTAL_COIN"
and below it you have to add this
Lua:
ITEM_GOLD_NUGGET = 2157 -- This itemid might be wrong, check whit your server and change it.
ITEM_GOLD_INGOT = 9058 -- This itemid might be wrong, check whit your server and change it.
then your script should work, if you dont want to change your lib you can just change every ITEM_GOLD_NUGGET and ITEM_GOLD_INGOT to the itemid of the item.

so i need the last thing of that script is the gold nugget
i dont want the gold nugget to change to any thing else (gold >platinum>crystal>gold nugget) nothing more how i do it
 
ITEM_GOLD_NUGGET is maybe not defined. Try to put:
Code:
local ITEM_GOLD_NUGGET = 2157

outside the function onUse
 
i fixed it myself non of the above solve it
this is the right fix

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, 1)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)

    elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
    elseif item.itemid == ITEM_CRYSTAL_COIN then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_GOLD_NUGGET then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_GREEN)
    else
        return true
    end
    return true
end

i removed the part of the gold ingot up and down then i made it return true
 
Solution

Similar threads

Back
Top