Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,338
- Solutions
- 68
- Reaction score
- 1,022
Whenever I try to use the setCustomAttribute lua method the server crashes. I created a talkaction that works like /attr but will just set item rarity to whatever I want.
I upgraded my server from 1.4.2 but have made sure all source code related to custom attributes is up to date. Anyone got any ideas?
Side note the crash has to do with the hashing function.
Lua:
local talkaction = TalkAction("/rarity")
function talkaction.onSay(player, words, param)
if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end
local position = player:getPosition()
position:getNextPosition(player:getDirection())
local tile = Tile(position)
if not tile then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "There is no tile in front of you.")
return false
end
local thing = tile:getTopVisibleThing(player)
if not thing then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "There is an empty tile in front of you.")
return false
end
if thing:isItem() then
thing:setCustomAttribute("Rarity", param)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("Attribute Rarity set to: %s", param))
position:sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Thing in front of you is not supported.")
return false
end
return false
end
talkaction:separator(" ")
talkaction:register()
I upgraded my server from 1.4.2 but have made sure all source code related to custom attributes is up to date. Anyone got any ideas?
Side note the crash has to do with the hashing function.