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

Lua [OTHire 7.72] Show player equipments on map

namco

Alienbutserious
Joined
Sep 5, 2010
Messages
148
Solutions
2
Reaction score
38
Hello :)
I'm having some trouble trying to make this

The idea is:
When player is @ marked tiles, his equipments are shown on the respective displays.
When player leave, the equipments are removed.
JXsAShE.png


What I got: (+no clue of what to do XD)
error on line 4 ')' expected near ','
Lua:
function onStepIn(cid, item, position, fromPosition)

local displays = {
[up_oute] = {neck = (956, 943, 7), head = (957, 943, 7), bag = (958, 943, 7),
             left = (956, 944, 7), body = (957, 944, 7), right = (958, 944, 7),
             ring = (956, 945, 7), legs = (957, 945, 7), ammo = (958, 945, 7),
                                   feet = (957, 946, 7)},
                                       
[up_outd] = {neck = (978, 943, 7), head = (979, 943, 7), bag = (980, 943, 7),
             left = (978, 944, 7), body = (979, 944, 7), right = (980, 944, 7),
             ring = (978, 945, 7), legs = (979, 945, 7), ammo = (980, 945, 7),
                                   feet = (979, 946, 7)},
                                       
[d_oute] =  {neck = (956, 950, 7), head = (957, 950, 7), bag = (958, 950, 7),
             left = (956, 951, 7), body = (957, 951, 7), right = (958, 951, 7),
             ring = (956, 952, 7), legs = (957, 952, 7), ammo = (958, 952, 7),
                                   feet = (957, 953, 7)},
                           
[d_outd] =  {neck = (978, 950, 7), head = (979, 950, 7), bag = (980, 950, 7),
             left = (978, 951, 7), body = (979, 951, 7), right = (980, 951, 7),
             ring = (978, 952, 7), legs = (979, 952, 7), ammo = (980, 952, 7),
                                   feet = (979, 953, 7)},
                                       
[up] =        {neck = (967, 943, 7), head = (968, 943, 7), bag = (969, 943, 7),
             left = (967, 944, 7), body = (968, 944, 7), right = (969, 944, 7),
             ring = (967, 945, 7), legs = (968, 945, 7), ammo = (969, 945, 7),
                                   feet = (968, 946, 7)},
                                       
[d]  =        {neck = (967, 950, 7), head = (968, 950, 7), bag = (969, 950, 7),
             left = (967, 951, 7), body = (968, 951, 7), right = (969, 951, 7),
             ring = (967, 952, 7), legs = (968, 952, 7), ammo = (969, 952, 7),
                                   feet = (968, 953, 7)}
}

local slots = {[neck] = 2, [head] = 1, [bag] = 3,
               [left] = 6, [body] = 4, [right] = 5,
               [ring] = 9, [legs] = 7, [ammo] = 10,
                           [feet]= 8}

    if item.actionid == 60000 then --up
        if getPlayerSlotItem(cid, slots[head]) ~= nil then
        doCreateItem(getPlayerSlotItem(cid, slots[head]), 1, displays[up].head)
        end
    end

    return true
end
d917184e-bf89-49aa-a8e7-ff3fc7fced77
 
Code:
local t = {
    [hi] = 3
}
print(t[hi])
= error
Code:
local t = {
    ["hi"] = 3
}
print(t["hi"])
= 3

ty for the tip <3
so, i mage this to test only with the head slot and i get the following error when i step in the tile (with item equipped or not):
Lua:
function onStepIn(cid, item, position, fromPosition)
local displays = {
["up_oute"] = {neck = {x = 956, y = 943, z = 7}, head = {x = 957, y = 943, z = 7}, bag = {x = 958, y = 943, z = 7},
             left = {x = 956, y = 944, z = 7}, body = {x = 957, y = 944, z = 7}, right = {x = 958, y = 944, z = 7},
             ring = {x = 956, y = 945, z = 7}, legs = {x = 957, y = 945, z = 7}, ammo = {x = 958, y = 945, z = 7},
                                   feet = {x = 957, y = 946, z = 7}},
                                   
["up_outd"] = {neck = {x = 978, y = 943, z = 7}, head = {x = 979, y = 943, z = 7}, bag = {x = 980, y = 943, z = 7},
             left = {x = 978, y = 944, z = 7}, body = {x = 979, y = 944, z = 7}, right = {x = 980, y = 944, z = 7},
             ring = {x = 978, y = 945, z = 7}, legs = {x = 979, y = 945, z = 7}, ammo = {x = 980, y = 945, z = 7},
                                   feet = {x = 979, y = 946, z = 7}},
                                   
["d_oute"] =  {neck = {x = 956, y = 950, z = 7}, head = {x = 957, y = 950, z = 7}, bag = {x = 958, y = 950, z = 7},
             left = {x = 956, y = 951, z = 7}, body = {x = 957, y = 951, z = 7}, right = {x = 958, y = 951, z = 7},
             ring = {x = 956, y = 952, z = 7}, legs = {x = 957, y = 952, z = 7}, ammo = {x = 958, y = 952, z = 7},
                                   feet = {x = 957, y = 953, z = 7}},
                       
["d_outd"] =  {neck = {x = 978, y = 950, z = 7}, head = {x = 979, y = 950, z = 7}, bag = {x = 980, y = 950, z = 7},
             left = {x = 978, y = 951, z = 7}, body = {x = 979, y = 951, z = 7}, right = {x = 980, y = 951, z = 7},
             ring = {x = 978, y = 952, z = 7}, legs = {x = 979, y = 952, z = 7}, ammo = {x = 980, y = 952, z = 7},
                                   feet = {x = 979, y = 953, z = 7}},
                                   
["up"] =        {neck = {x = 967, y = 943, z = 7}, head = {x = 968, y = 943, z = 7}, bag = {x = 969, y = 943, z = 7},
             left = {x = 967, y = 944, z = 7}, body = {x = 968, y = 944, z = 7}, right = {x = 969, y = 944, z = 7},
             ring = {x = 967, y = 945, z = 7}, legs = {x = 968, y = 945, z = 7}, ammo = {x = 969, y = 945, z = 7},
                                   feet = {x = 968, y = 946, z = 7}},
                                   
["d"]  =        {neck = {x = 967, y = 950, z = 7}, head = {x = 968, y = 950, z = 7}, bag = {x = 969, y = 950, z = 7},
             left = {x = 967, y = 951, z = 7}, body = {x = 968, y = 951, z = 7}, right = {x = 969, y = 951, z = 7},
             ring = {x = 967, y = 952, z = 7}, legs = {x = 968, y = 952, z = 7}, ammo = {x = 969, y = 952, z = 7},
                                   feet = {x = 968, y = 953, z = 7}}
}
local slots = {["neck"] = 2, ["head"] = 1, ["bag"] = 3,
               ["left"] = 6, ["body"] = 4, ["right"] = 5,
               ["ring"] = 9, ["legs"] = 7, ["ammo"] = 10,
                           ["feet"]= 8}
    if item.actionid == 60000 then --up
        if getPlayerSlotItem(cid, slots["head"]) ~= nil then
        doCreateItem(getPlayerSlotItem(cid, slots["head"]), 1, displays["up"].head)
        end
    end
    return true
end
Code:
LuaScriptError: [MoveEvents Interface]
data/movements/scripts/arena.lua:onStepIn

LuaScriptInterface::luaDoCreateItem(). Item not found

ps: i have a royal helmet equipped for test
 
getPlayerSlotItem(cid, slots[head]).itemid
woah it workd XD
ty a lot
i'll try to continue the script then return here for the feedback
i also had to change
Lua:
if getPlayerSlotItem(cid, slots["head"]) ~= nil then
to
Lua:
if getPlayerSlotItem(cid, slots["head"]).itemid ~= 0 then

-- EDIT --
there is any way to make the script get all the equipments at the same time and put them on map?
 
Wtf is the d, up, d_outd, blah blah blah Why is that there?

Maybe something like this would be better?

Code:
function onStepIn(cid, item, position, fromPosition)
local positions = {
    [1] = {x = 1000, y = 1000, z = 7}, --Head
    [2] = {x = 1000, y = 1000, z = 7}, --Neck
    [3] = {x = 1000, y = 1000, z = 7}, --Bag
    [4] = {x = 1000, y = 1000, z = 7}, --Body
    [5] = {x = 1000, y = 1000, z = 7}, --Right
    [6] = {x = 1000, y = 1000, z = 7}, --Left
    [7] = {x = 1000, y = 1000, z = 7}, --Legs
    [8] = {x = 1000, y = 1000, z = 7}, -- Feet
    [9] = {x = 1000, y = 1000, z = 7}, -- Ring
    [10] = {x = 1000, y = 1000, z = 7} -- Ammo
}
    if item.actionid == 60000 then
    spotOpen = 1
        for i = 1, #positions do
            ITEM1 = getThingFromPos(positions[i]).itemid
                if ITEM1 ~= nil then
                    spotOpen = 0
                end
        end
       
        if spotOpen == 1 then
            for i = 1, #CONST_SLOT_LAST do
                ITEM2 = getPlayerSlotItem(cid, i).itemid
                    if ITEM ~= nil then
                        doCreateItem(ITEM2, 1, position[i])
                    end
            end
            addEvent(removeItems, 30 * 1000)
        end
    end
    return true
end
function removeItems()
local positions = {
    [1] = {x = 1000, y = 1000, z = 7}, --Head
    [2] = {x = 1000, y = 1000, z = 7}, --Neck
    [3] = {x = 1000, y = 1000, z = 7}, --Bag
    [4] = {x = 1000, y = 1000, z = 7}, --Body
    [5] = {x = 1000, y = 1000, z = 7}, --Right
    [6] = {x = 1000, y = 1000, z = 7}, --Left
    [7] = {x = 1000, y = 1000, z = 7}, --Legs
    [8] = {x = 1000, y = 1000, z = 7}, -- Feet
    [9] = {x = 1000, y = 1000, z = 7}, -- Ring
    [10] = {x = 1000, y = 1000, z = 7} -- Ammo
}
for i = 1, #positions do
    ITEM1 = getThingFromPos(positions[i]).itemid
        if ITEM1 ~= nil then
            doRemoveItem(ITEM1, 1, positions[i])
        end
end
end
 
Last edited:
Wtf is the d, up, d_outd, blah blah blah Why is that there?
the positions for equipments on display
the items are supposed to be shown on every color stroked display (for players and spectators) when the player on the respective color side step in
up / d = the center displays
_out = the outside displays
outd = right
oute = left
 
woah it workd XD
ty a lot
i'll try to continue the script then return here for the feedback
i also had to change
Lua:
if getPlayerSlotItem(cid, slots["head"]) ~= nil then
to
Lua:
if getPlayerSlotItem(cid, slots["head"]).itemid ~= 0 then

-- EDIT --
there is any way to make the script get all the equipments at the same time and put them on map?
rename your displays to ["head"] instead of head and so on and try:
Code:
for equipString,equipNumber in pairs(slots) do
    if getPlayerSlotItem(cid, equipNumber) ~= nil then
        doCreateItem(getPlayerSlotItem(cid, equipNumber), 1, displays["up"][equipString])
    end
end
Wtf is the d, up, d_outd, blah blah blah Why is that there?
It's the position map regarding his map.
 
My above code you could set up to a few different actionids. Use the actionids in the map tiles to explain where you want to put each armor. So for the armor to show on the top left spot. Put in the positions on my code, then, put the tiles they stand on to actionid 60000, then do the same again for the next spot but make the action id 60001. I think this is what you are wanting?

nvm i didnt see you are trying to make the armor appear in 3 different spots at once. You can use my code to figure out how to create yours a little better though.
 
Last edited:
rename your displays to ["head"] instead of head and so on and try:
Code:
for equipString,equipNumber in pairs(slots) do
    if getPlayerSlotItem(cid, equipNumber) ~= nil then
        doCreateItem(getPlayerSlotItem(cid, equipNumber), 1, displays["up"][equipString])
    end
end

It's the position map regarding his map.
y1vkOEA.png

worked XD tyyyyyyy
now i need an onStepOut function to remove only the items from the tiles
i'll try some things here
ty alot againnnnn <333
 
My above code you could set up to a few different actionids. Use the actionids in the map tiles to explain where you want to put each armor. So for the armor to show on the top left spot. Put in the positions on my code, then, put the tiles they stand on to actionid 60000, then do the same again for the next spot but make the action id 60001. I think this is what you are wanting?
i prefer my way
just tabled the locations
the items must be shown on all the 3 displays @ the same time
 
Yeah, I just saw exactly what you were doing. My bad. You should set it up how I did as far as it removing the items automatically. This way a player cant walk in and out fast and cause problems.
 
Yeah, I just saw exactly what you were doing. My bad. You should set it up how I did as far as it removing the items automatically. This way a player cant walk in and out fast and cause problems.
can you explain "This way a player cant walk in and out fast and cause problems."?

@post
trying this but without success
Lua:
function onStepOut(cid, item, position, fromPosition)
    if item.actionid == 60000 then --up
        for equipString in pairs(slots) do
            doRemoveItem(getThingFromPos(displays["up"][equipString]))
        end
    end
    return true
end

getting "Item not found" with the removeitem function
 
can you explain "This way a player cant walk in and out fast and cause problems."?

Every time a player walks in or walks out of that tile the server is going to create all those items and remove them. So if he walks in and out fast, it can cause lag.

Code:
function onStepOut(cid, item, position, fromPosition)
    if item.actionid == 60000 then --up
        for equipString in pairs(slots) do
            ITEM = getThingFromPos(displays["up"][equipString]).itemid
            if ITEM then
            doRemoveItem(ITEM)
            end
        end
    end
    return true
end
 
Every time a player walks in or walks out of that tile the server is going to create all those items and remove them. So if he walks in and out fast, it can cause lag.

Code:
function onStepOut(cid, item, position, fromPosition)
    if item.actionid == 60000 then --up
        for equipString in pairs(slots) do
            ITEM = getThingFromPos(displays["up"][equipString]).itemid
            if ITEM then
            doRemoveItem(ITEM)
            end
        end
    end
    return true
end
i'll try to something like a 5 seconds delay to stepin with storage
if you got a better ideia just tell :D
 
Is your code working for you now? You might want to try it without a full set on. The code right now might delete the ground tiles if there is no player items in the spot.
 
dJoZn81.png

Is your code working for you now? You might want to try it without a full set on. The code right now might delete the ground tiles if there is no player items in the spot.
nope, just creating one item onStepIn and getting an error for each position
 
Yeah, I just saw exactly what you were doing. My bad. You should set it up how I did as far as it removing the items automatically. This way a player cant walk in and out fast and cause problems.

So, I was just looking up this thread and realized that I don't need the script anymore.
But if someone's up to this, let your fingers type.
I don't know if it's against the rules 'cause it's in the Support board [for who else's going to need it (maybe myself?)].

- The player can't walk in and out fast since it's a considerable time consuming lobby for only 1 PvP combat.
- They need to pull the lever to remove the basins and get access to the arena and exit portals (entering the portal causes the items to disappear since the player is leaving the lobby).
- We need a way to update the items when the player changes his equipment.
- A system to protect the lobby tiles from trashing.

Aaaaaaand... I think it's it XD
Ty e um grande abraço!
 

Similar threads

Back
Top