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

Script being loaded but not working.

magoale1

New Member
Joined
Jun 12, 2014
Messages
22
Reaction score
1
Location
Brazil
Hello there!

I am learning more on how to code custom stuff to Tibia, and recently I've been trying to do some experiments but none of them worked so far. Could you help me understand why?

I have created a file named test_script.lua inside my data/scripts/custom folder. The script is straightforward: When somebody equips anything, it will print "It works?".

However, despite the server successfully loading the script "Because when I removed the end for example to see if some error would pop up, it said that the script file had errors, so it might be loading it" It does not do anything.


LUA:
function onEquip(cid, item, slot)
    print("Testing!")
    return TRUE
end
 
Do you want to learn about Revscripts, which is located directly in the data/scripts folder, right? Here's a tutorial from the wiki that will explain how it works correctly.

LUA:
local moveevent = MoveEvent()

function moveevent.onEquip(player, item, slot, isCheck)
print("Testing!")
    return true
end
moveevent:slot("ring")
moveevent:register()
 
Do you want to learn about Revscripts, which is located directly in the data/scripts folder, right? Here's a tutorial from the wiki that will explain how it works correctly.

LUA:
local moveevent = MoveEvent()

function moveevent.onEquip(player, item, slot, isCheck)
print("Testing!")
    return true
end
moveevent:slot("ring")
moveevent:register()
Oh, so these are called Revscripts? Yes, that is exactly what I want to learn and test.

Thank you ❤️
 
Heyy @Mateus Robeerto, I gave it a read and tried to make some changes in my code. However, it is throwing a very weird error:

LUA:
local moveevent = MoveEvent()

function moveevent.onEquip(player, item, slot, isCheck)
    if item.itemid == 3365 then
        player:say("The Golden Helmet was Equiped!", TALKTYPE_YELL)
    end
    return true
end

moveevent:register()

The error was:
[error] [Script::loadCallback] scriptid is not zero, scriptid = 1000, scriptName test.lua

Do you have any idea on how I can fix it?
 
Heyy @Mateus Robeerto, I gave it a read and tried to make some changes in my code. However, it is throwing a very weird error:

LUA:
local moveevent = MoveEvent()

function moveevent.onEquip(player, item, slot, isCheck)
    if item.itemid == 3365 then
        player:say("The Golden Helmet was Equiped!", TALKTYPE_YELL)
    end
    return true
end

moveevent:register()

The error was:
[error] [Script::loadCallback] scriptid is not zero, scriptid = 1000, scriptName test.lua

Do you have any idea on how I can fix it?
moveevent:register()
to
moveevent:register(slot, itemid)
 
moveevent:register()
to
moveevent:register(slot, itemid)
Hmm.. It is still throwing the scriptid is not zero error and these two more:
1729816674489.webp
Post automatically merged:

Actually I fixed it!
I had to assign an ID to it, and the ID must be the same of the item I am working with:


LUA:
local moveevent = MoveEvent()

function moveevent.onEquip(player, item, slot, isCheck)
    if item.itemid == 3365 then
        player:say("The Golden Helmet has been equippped!", TALKTYPE_YELL)
    end
    return true
end

moveevent:id(3365)
moveevent:register()
 
Last edited:
Back
Top