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

Solved Function getItemNameById returns error

whiteblXK

Active Member
Joined
Apr 20, 2011
Messages
315
Solutions
9
Reaction score
32
Location
Poland
Hello, I have small bug with my script. When I use my item on players, I want see his helmet name that works fine but if players don't equip helmet server give me errors:
Code:
[Error - Action Interface]
data/actions/scripts/scouter_system.lua:onUse
Description:
data/lib/050-function.lua:222: attempt to index a boolean value
stack traceback:
  data/lib/050-function.lua:222: in function 'getItemNameById'
  data/actions/scripts/scouter_system.lua:4: in function <data/actions/scr
ipts/scouter_system.lua:1>

Here is my script,
Code:
function onUse(cid, item, frompos, item2, topos)
local head = getItemNameById(getPlayerSlotItem(item2.uid, CONST_SLOT_HEAD).itemid)
   if isPlayer(item2.uid) then
     doPlayerPopupFYI(cid, 'Head: '..head..' ')
   else
     doPlayerSendCancel(cid,"Error")
   end 
return true
end

How to do when checked player don't equip helmet script return 'nothink'?
 
Last edited:
Code:
function onUse(cid, item, frompos, item2, topos)
     if isPlayer(item2.uid) then
         local head, helmet = 'None', getPlayerSlotItem(item2.uid, CONST_SLOT_HEAD).itemid
         if helmet > 0 then
             head = getItemNameById(helmet)
         end
         doPlayerPopupFYI(cid, 'Head: '..head..' ')
     else
         doPlayerSendCancel(cid,"Error")
     end
     return true
end
 
Back
Top