gritness
Member
- Joined
- May 26, 2021
- Messages
- 33
- Reaction score
- 6
Hey Guys,
I have some problem with my script, else option does not work. "If condition" work well, but when player have not specific item in arrows slot (9742) its dont work
Bellow is my script :
local storage_id = 10006
local unique_id = 35056
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(storage_id) == 2 and item:getUniqueId() == unique_id and player:getSlotItem(CONST_SLOT_AMMO):getId() == 9742 then
player:teleportTo(fromPosition,true)
item:transform(1259 + 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR,"You must have a specific item in your arrows slot.")
end
end
AND HERE IS ERROR IN TFS CONSOLE :
Lua Script Error: [Action Interface]
data/actions/scripts/quests/nowe/drzwidoyala.luanUse
data/actions/scripts/quests/nowe/drzwidoyala.lua:5: attempt to index a nil value
stack traceback:
[C]: in metamethod '__index'
data/actions/scripts/quests/nowe/drzwidoyala.lua:5: in function <data/actions/scripts/quests/nowe/drzwidoyala.lua:4>
Problem occurs when i have not item in arrow slot, when i take another item than 9742 message work.
So, need any validate of nil value, someone can help ?
I have some problem with my script, else option does not work. "If condition" work well, but when player have not specific item in arrows slot (9742) its dont work
Bellow is my script :
local storage_id = 10006
local unique_id = 35056
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(storage_id) == 2 and item:getUniqueId() == unique_id and player:getSlotItem(CONST_SLOT_AMMO):getId() == 9742 then
player:teleportTo(fromPosition,true)
item:transform(1259 + 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR,"You must have a specific item in your arrows slot.")
end
end
AND HERE IS ERROR IN TFS CONSOLE :
Lua Script Error: [Action Interface]
data/actions/scripts/quests/nowe/drzwidoyala.luanUse
data/actions/scripts/quests/nowe/drzwidoyala.lua:5: attempt to index a nil value
stack traceback:
[C]: in metamethod '__index'
data/actions/scripts/quests/nowe/drzwidoyala.lua:5: in function <data/actions/scripts/quests/nowe/drzwidoyala.lua:4>
Post automatically merged:
Problem occurs when i have not item in arrow slot, when i take another item than 9742 message work.
So, need any validate of nil value, someone can help ?
Last edited: