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

Can someone remake a script ?

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,324
Reaction score
136
is it posible to make this script works for 8.60 , 0.3.6 ?

script taked from 9.81 server
please if someone can remake it fo 8.60 , 0.3.6


Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function greetCallback(cid)
talkState[talkUser] = 0
return true
end

local itemsSellMinor = {
    {itemId = 18215, quantCt = 2},
    {itemId = 18395, quantCt = 8},
    {itemId = 18509, quantCt = 10},
    {itemId = 18388, quantCt = 15},
    {itemId = 18393, quantCt = 15},
    {itemId = 18521, quantCt = 70},
    {itemId = 18518, quantCt = 70}
}
local minorCrystalId = 18422

local itemsSellMajor = {
    {itemId = 18398, quantCt = 10},
    {itemId = 18399, quantCt = 10},
    {itemId = 18400, quantCt = 10},
    {itemId = 18401, quantCt = 10},
    {itemId = 18403, quantCt = 10},
    {itemId = 18404, quantCt = 10},
    {itemId = 18405, quantCt = 10},   
    {itemId = 18406, quantCt = 10},
    {itemId = 18410, quantCt = 10},   
    {itemId = 18520, quantCt = 20},
    {itemId = 18517, quantCt = 20},
    {itemId = 18447, quantCt = 20},
    {itemId = 18448, quantCt = 20}
}
local majorCrystalId = 18423

function getMinor()
local textM = ""
for i=1, #itemsSellMinor do
    if i < #itemsSellMinor then
        textM = textM.. getItemNameById(itemsSellMinor[i].itemId) ..", "
    else
        textM = textM.. getItemNameById(itemsSellMinor[i].itemId) .."."
    end
end
return textM
end

function getMajor()
local textJ = ""
for i=1, #itemsSellMajor do
    if i < #itemsSellMajor then
        textJ = textJ.. getItemNameById(itemsSellMajor[i].itemId) ..", "
    else
        textJ = textJ.. getItemNameById(itemsSellMajor[i].itemId) .."."
    end
end
return textJ
end

function getArrayMinor()
local arrayMinor = {}
for i=1, #itemsSellMinor do
    arrayMinor[#arrayMinor+1] = getItemNameById(itemsSellMinor[i].itemId)
end
return arrayMinor
end

function getArrayMajor()
local arrayMajor = {}
for i=1, #itemsSellMajor do
    arrayMajor[#arrayMajor+1] = getItemNameById(itemsSellMajor[i].itemId)
end
return arrayMajor
end

function creatureSayCallback(cid, type, msg)

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storageNpc = 495021

if(not npcHandler:isFocused(cid)) then 
    return false 
end

if msgcontains(msg, 'yes') and  getPlayerStorageValue(cid, storageNpc) > 0 then
    local item = getPlayerStorageValue(cid, storageNpc)
    for i=1, #itemsSellMinor do
        if itemsSellMinor[i].itemId == item then
            if doPlayerRemoveItem(cid, minorCrystalId, itemsSellMinor[i].quantCt) then
                doPlayerAddItem(cid, item, 1)
                selfSay("Pick up your item.", cid)
                setPlayerStorageValue(cid, storageNpc, -1)
            else
                selfSay("I dont have crystals for buy item!", cid)
                setPlayerStorageValue(cid, storageNpc, -1)
            end
            break
        end
    end
    for i=1, #itemsSellMajor do
        if itemsSellMajor[i].itemId == item then
            if doPlayerRemoveItem(cid, majorCrystalId, itemsSellMajor[i].quantCt) then
                doPlayerAddItem(cid, item, 1)
                selfSay("Pick up your item.", cid)
                setPlayerStorageValue(cid, storageNpc, -1)
            else
                selfSay("I dont have crystals for buy item!", cid)
                setPlayerStorageValue(cid, storageNpc, -1)
            end
            break
        end
    end
end

if msgcontains(msg, 'minor') then
    selfSay("I selling for minor crystals: "..getMinor(), cid)
elseif msgcontains(msg, 'major') then
    selfSay("I selling for major crystals: "..getMajor(), cid)
elseif isInArray(getArrayMinor(), msg)  then
    local item = getItemIdByName(msg)
    for i=1, #itemsSellMinor do
        if itemsSellMinor[i].itemId == item then
            selfSay("I selling ".. msg .." for ".. itemsSellMinor[i].quantCt .." minor, you accept my offer?", cid)
            setPlayerStorageValue(cid, storageNpc, item)
            break
        end
    end
elseif isInArray(getArrayMajor(), msg) then
    local item = getItemIdByName(msg)
    for i=1, #itemsSellMajor do
        if itemsSellMajor[i].itemId == item then
            selfSay("I selling ".. msg .." for ".. itemsSellMajor[i].quantCt .." minor, you accept my offer?", cid)
            setPlayerStorageValue(cid, storageNpc, item)
            break
        end
    end
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Just try it and post the errors. Its hard for us to know if it works or not.
 
oke little bit sec :)


- - - Updated - - -


how i can copy bug on console ?


- - - Updated - - -


Rg0j0_.png

there is the error , npc works fine , than i say words"minor or major i get this error
 
Last edited by a moderator:
wooot ? i dont get what you put here

microsoft lol ? what should i do with it ? :D

someone help please :(
 
Last edited by a moderator:
its script from real map ots npc Called Gnomally , i think you know what it does.

i want that the npc trades x tokens for xxxx item
and x itmes for xxxx item.
understand ? :)
 
Weird, the script uses really nice things from lua, but all makes sense! I see no obvious flaws or erros that might ring a bell.
The scripts that bugs are function getMinor() on line 48 and function getMajor() on line 60. It sais that something is wrong with getItemNameById. But in this case it takes the index value of the arrar, and gets the value of the itemId at that spot. Then moving on to the next.
Try to stream comment these lines, and reload to see if these functions really are the things that causes the error.
Like the following:
Lua:
[CODE]function getMinor()
local textM = "TestMinor"
--for i=1, #itemsSellMinor do
--    if i < #itemsSellMinor then
--        textM = textM.. getItemNameById(itemsSellMinor[i].itemId) ..", "
--    else
--        textM = textM.. getItemNameById(itemsSellMinor[i].itemId) .."."
--    end
--end
return textM
end

function getMajor()
local textJ = "TestMajor"
--for i=1, #itemsSellMajor do
--    if i < #itemsSellMajor then
--        textJ = textJ.. getItemNameById(itemsSellMajor[i].itemId) ..", "
--    else
--        textJ = textJ.. getItemNameById(itemsSellMajor[i].itemId) .."."
--    end
--end
return textJ
end
[/code]
 
Paste the code I gave you in your document, and delete what was there.
So replace your functions getMinor and getMajor with the code I gave you. (they are at line 48 to 58 and line 60 to 70 in your script)
 
same error happens than i try it :( any ideas?

- - - Updated - - -

i think 8.60 client , 0.3.6 tfs doesnt have the things it loads , or something like that
 
Last edited by a moderator:
i think 8.60 client , 0.3.6 tfs doesnt have the things it loads , or something like that

This.

8.6 didn't have the items that came with the 9.6 update.
Try changing out all the new itemIDs that does not exist in your server and replace them with some you have.
 
i was thinking about the same , but error is not about the items in my eyes its something with the script thing. i think so, gonna try it ofc
 
so lol why u ask us what to change?

do:
Code:
local itemsSellMinor = {
{itemId = 5215, quantCt = 2, itemName = "Tibia Map"},

and where appears somthing like "getItemNameById(itemsSellMinor.itemId)"
Code:
itemsSellMinor[i].itemName

Same for Major
 
Back
Top