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

onUse Function

amr shalapy

Banned User
Joined
Aug 28, 2014
Messages
122
Reaction score
8
Hello everybody i was wondering how to check all local parts if you click on the one of them they will all be removed and if you missing any one of them it say you can't do this
thanks
This code that i reached but It's not working, don't know how to do it exactly may some one help please
Lua:
 local parts = {2198,7890,7888,7887,7889,2197,2131,2130,2201,2138,2141}
         function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerItemCount(cid, parts)  then
    doRemoveItem(cid, parts)
       if not playerhasItem(parts) then
        doPlayerSay(speaker, "sorry you can't do it", TALKTYPE_MONSTER_SAY, toPosition)
    end
    end
 
Solution
while using any items of them it remove by instead of keeping it... that if i have any item and do not give the message
"You do not have all required items"
change
Lua:
if not getPlayerItemCount(cid, parts[i]) then
to
Lua:
if getPlayerItemCount(cid, parts[i]) < 1 then
Hello everybody i was wondering how to check all local parts if you click on the one of them they will all be removed and if you missing any one of them it say you can't do this
thanks
This code that i reached but It's not working, don't know how to do it exactly may some one help please
Lua:
 local parts = {2198,7890,7888,7887,7889,2197,2131,2130,2201,2138,2141}
         function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerItemCount(cid, parts)  then
    doRemoveItem(cid, parts)
       if not playerhasItem(parts) then
        doPlayerSay(speaker, "sorry you can't do it", TALKTYPE_MONSTER_SAY, toPosition)
    end
    end

Lua:
local parts = {2198, 7890, 7888, 7887, 7889, 2197, 2131, 2130, 2201, 2138, 2141}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for i = 1, #parts do
        if not getPlayerItemCount(cid, parts[i]) then
            return doPlayerSay(speaker, "You do not have all required items.", TALKTYPE_MONSTER_SAY, toPosition)
        end
    end
    
    for i = 1, #parts do
        doRemoveItem(cid, parts[i])
    end
    
    return true
end
 
Lua:
local parts = {2198, 7890, 7888, 7887, 7889, 2197, 2131, 2130, 2201, 2138, 2141}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for i = 1, #parts do
        if not getPlayerItemCount(cid, parts[i]) then
            return doPlayerSay(speaker, "You do not have all required items.", TALKTYPE_MONSTER_SAY, toPosition)
        end
    end
  
    for i = 1, #parts do
        doRemoveItem(cid, parts[i])
    end
  
    return true
end
this error
Code:
[15:25:16.775] [Error - Action Interface]
[15:25:16.776] data/actions/scripts/demi parts.lua:onUse
[15:25:16.779] Description:
[15:25:16.780] (LuaInterface::luaDoRemoveItem) Item not found
 
this error
Code:
[15:25:16.775] [Error - Action Interface]
[15:25:16.776] data/actions/scripts/demi parts.lua:onUse
[15:25:16.779] Description:
[15:25:16.780] (LuaInterface::luaDoRemoveItem) Item not found
change
Lua:
doRemoveItem(cid, parts[i])
for
Lua:
doPlayerRemoveItem(cid, parts[i], 1)
 
Because getPlayerItemCount will always return true.
Change it for 'if getPlayerItemCount(cid, parts) == 0 then'.
Or something like that. Im not familiar with 0.x functions.
 
while using any items of them it remove by instead of keeping it... that if i have any item and do not give the message
"You do not have all required items"
change
Lua:
if not getPlayerItemCount(cid, parts[i]) then
to
Lua:
if getPlayerItemCount(cid, parts[i]) < 1 then
 
Solution
Back
Top