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

Remove Item

Gazzy

Server Owner
Joined
Sep 25, 2013
Messages
55
Reaction score
3
I need to make a command (talkaction) that removes an item on the map and then puts the item back. I need this command to only be usable by staff and I need it to broadcast a message too. I need this for 2 positions so the params will be:
Code:
!barrier off (1 or 2) - Removes the item
!barrier on (1 or 2) - Adds the item
Code:
Item ID: 5313
Position 1:545 789 7
Position 2:551 789 7
I really need help for this so can I get help urgently? Thanks

TFS 1.0
 
You are missing cid in the other cancel messages.

Code:
if not getPlayerAccess(cid) then
     return false
end

This should be:
Code:
if getPlayerAccess(cid) < 1 then
     return false
end
 
Last edited:
How did you added it, do you get errors? Do you get cancel messages.

If you add
Code:
print("script load test")
Under function onSay, do you see this message in your console when you do the talkactions?

You can also add similar messages in other parts in the script to see where it goes wrong.
 
I added the message under function onSay and it didn't show but I also added it at the start and it didn't show either, could you try to remake the script again as best as you can?
Code:
local config = {
     [1] = {pos = {x = 545, y = 789, z = 7}, itemid = 5313, text = {"Event area #1 is open. Event will be broadcasted soon", "Event area #1 has been closed and the event will begin shortly."}},
     [2] = {pos = {x = 551, y = 789, z = 7}, itemid = 5313, text = {"Event area #2 is open. Event will be broadcasted soon", "Event area #2 has been closed and the event will begin shortly."}}
}

function onSay(cid, words, param)
    if getPlayerAccess(cid) < 1 then
     return false
end

     local split = {}
     for s in string.gmatch(param, "%S+") do
         table.insert(split, s)
     end
     if not tonumber(split[2]) then
         doPlayerSendCancel(cid, "Missing or invalid param. Example: !barrier on 1")
         return false
     end

     local x, message = config[tonumber(split[2])], ""
    local thing = getTileItemById(x.pos, x.itemid).uid
     if split[1] == "off" then
         if thing > 0 then
             doRemoveItem(thing, 1)
             message = x.text[2]
         else
             doPlayerSendCancel("Item is already removed.")
         end
     elseif split[1] == "on" then
         if thing < 1 then
    doCreateItem(x.itemid, 1, x.pos)
             message = x.text[1]
         else
             doPlayerSendCancel("Item is already created.")
         end
     else
         doPlayerSendCancel("Choose between off and on.")
     end
     if message ~= "" then
         broadcastMessage(message)
     end
     return true
end
 
You still didn't add cid to the cancelmessages, but other than that it should already work like this.
If you added print under function onSay and you didn't see the message in your console this means it doesn't load the script.
So it gives errors or you didn't add it correct.

If it gives error, post the errors.
 
Last edited:
Back
Top