How to check items on slot ammo and hands too? thanks
local items = {
2160,
}
local function checkItems(playerUid, items)
local player = Player(playerUid)
if not player then return false end
for i = 1, #items do
if player:getItemCount(items[i]) > 0 then
npcHandler:say('Remove the items first.', cid)
else
npcHandler:say('This is good.', cid)
end
end
return true
end
local items = {{itemid1, count}, {itemid2, count}}
local function checkItems(player)
for i = 1, #items do
if not player:hasItem(items[i][1], items[i][2]) then
return false
end
end
return true
end
LUA:local items = {{itemid1, count}, {itemid2, count}} local function checkItems(player) for i = 1, #items do if not player:hasItem(items[i][1], items[i][2]) then return false end end return true end
if player:getItem(itemId) or player:getItem(itemId) or player:getItem(itemId) then
end
local config = {
{id = 2160, count = 1},
}
local function checkItems(playerUid, items)
local player = Player(playerUid)
if not player then return false end
for i = 1, #items do
if player:getItemCount(items[i].id) < items[i].count then
return false
end
end
return true
end
just set the count to 1
LUA:local config = { {id = 2160, count = 1}, } local function checkItems(playerUid, items) local player = Player(playerUid) if not player then return false end for i = 1, #items do if player:getItemCount(items[i].id) < items[i].count then return false end end return true end
local config = {
{id = 2160, count = 1},
}
local function checkItems(playerUid, items)
local player = Player(playerUid)
if not player then return false end
for i = 1, #items do
if player:getItemCount(items[i].id) < items[i].count then
npcHandler:say('Remove the items first.', cid)
else
npcHandler:say('This is good.', cid)
end
end
return true
end
but this function work inside script npc.lua ?
I tested here and nothing happens
Change it to:
LUA:local config = { 2160, } local function checkItems(playerUid, items) local player = Player(playerUid) if not player then return false end for i = 1, #items do if player:getItemCount(items[i]) < items[i].count then npcHandler:say('Remove the items first.', cid) else npcHandler:say('This is good.', cid) end end return true end
local config = {
2160,
}
local function checkItems(playerUid, items)
local player = Player(playerUid)
if not player then return false end
for i = 1, #items do
if player:getItemCount(items[i]) > 0 then
npcHandler:say('Remove the items first.', cid)
else
npcHandler:say('This is good.', cid)
end
end
return true
end
LUA:local config = { 2160, } local function checkItems(playerUid, items) local player = Player(playerUid) if not player then return false end for i = 1, #items do if player:getItemCount(items[i]) > 0 then npcHandler:say('Remove the items first.', cid) else npcHandler:say('This is good.', cid) end end return true end
How to check items on slot ammo and hands too? thanks
local items = {
2160,
}
local function checkItems(playerUid, items)
local player = Player(playerUid)
if not player then return false end
for i = 1, #items do
if player:getItemCount(items[i]) > 0 then
npcHandler:say('Remove the items first.', cid)
else
npcHandler:say('This is good.', cid)
end
end
return true
end
nopSorry, didn't see it.
LUA:local items = { 2160, } local function checkItems(playerUid, items) local player = Player(playerUid) if not player then return false end for i = 1, #items do if player:getItemCount(items[i]) > 0 then npcHandler:say('Remove the items first.', cid) else npcHandler:say('This is good.', cid) end end return true end
nopbut, how we can check items on slot ammo and hands?
![]()
function checkItems(playerUid, items)
local player = Player(playerUid)
if not player then return false end
for i = 1, #items do
if player:getItemCount(items[i].id) < items[i].count then
return false
end
end
return true
end
local requiredItems= {
{id = 2160, count = 1},
}
if checkItems(cid, requiredItems) then
npcHandler:say('Remove the items first.', cid)
else
npcHandler:say('This is good.', cid)
end