TalkAction Equipment Spy!

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
Hello, i made command for gm's to lookup players equipment (with containers contains)

Command:
!equipment PLAYER_NAME

Info Screen:


into data/talkactions/talkactions.xml under:
PHP:
<talkactions>
add:
PHP:
<talkaction log="yes" access="3" words="!equipment" event="script" value="equipment.lua"/>
and in data/talkactions/scripts make new file: equipment.lua
and put here code:
PHP:
-- Equipment spy by Azi [ersiu] --
function getItemsInContainer(cont, sep)
	local text = ""
	local tsep = ""
	local count = ""
	for i=1, sep do
		tsep = tsep.."-"
	end
	tsep = tsep..">"
	for i=0, getContainerSize(cont.uid)-1 do
		local item = getContainerItem(cont.uid, i)
		if isContainer(item.uid) == FALSE then
			if item.type > 0 then
				count = "("..item.type.."x)"
			end
			text = text.."\n"..tsep..getItemNameById(item.itemid).." "..count
		else
			if getContainerSize(item.uid) > 0 then
				text = text.."\n"..tsep..getItemNameById(item.itemid) 
				text = text..getItemsInContainer(item, sep+2)
			else
				text = text.."\n"..tsep..getItemNameById(item.itemid)
			end
		end
	end
	return text
end

function onSay(cid, words, param, channel)
	if(param == "") then
		doPlayerSendCancel(cid, "Command requires param.")
		return TRUE
	end
	local slotName = {"Head Slot", "Amulet Slot", "Backpack Slot", "Armor Slot", "Right Hand", "Left Hand", "Legs Slot", "Feet Slot", "Ring Slot", "Ammo Slot"}
	local player = getPlayerByNameWildcard(param)
	if isPlayer(player) == TRUE then
		local text = getPlayerName(player).."'s Equipment: "	
		for i=1, 10 do
			text = text.."\n\n"
			local item = getPlayerSlotItem(player, i)
			if item.itemid > 0 then
				if isContainer(item.uid) == TRUE then
					text = text..slotName[i]..": "..getItemNameById(item.itemid)..getItemsInContainer(item, 1)
				else
					text = text..slotName[i]..": "..getItemNameById(item.itemid)
				end
			else
				text = text..slotName[i]..": Empty"
			end
		end
		doShowTextDialog(cid, 6579, text)
	else
		doPlayerSendCancel(cid, "This player is not online.")
	end
    return TRUE
end
Thanks,
Azi!
 
Last edited:

Sizaro

Intermediate OT User
Joined
Aug 20, 2007
Messages
5,061
Best answers
2
Reaction score
117
Location
Sweden
Can u fix so you can remove the item and put a new item :p?
 

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Best answers
0
Reaction score
6
Location
London, Ontario
I noticed that it only shows your own equipment (As pointed out by Grehy), so I changed one word in the script and got it working. All script credits go to Azi.

For advanced users:
Change:
Code:
local item = getPlayerSlotItem(cid, i)
To:
Code:
local item = getPlayerSlotItem(player, i)
For not so advanced users:
Just replace the coding:
Code:
-- Equipment spy by Azi [ersiu] -- 
function getItemsInContainer(cont, sep) 
    local text = "" 
    local tsep = "" 
    local count = "" 
    for i=1, sep do 
        tsep = tsep.."-" 
    end 
    tsep = tsep..">" 
    for i=0, getContainerSize(cont.uid)-1 do 
        local item = getContainerItem(cont.uid, i) 
        if isContainer(item.uid) == FALSE then 
            if item.type > 0 then 
                count = "("..item.type.."x)" 
            end 
            text = text.."\n"..tsep..getItemNameById(item.itemid).." "..count 
        else 
            if getContainerSize(item.uid) > 0 then 
                text = text.."\n"..tsep..getItemNameById(item.itemid)  
                text = text..getItemsInContainer(item, sep+2) 
            else 
                text = text.."\n"..tsep..getItemNameById(item.itemid) 
            end 
        end 
    end 
    return text 
end 

function onSay(cid, words, param, channel) 
    if(param == "") then 
        doPlayerSendCancel(cid, "Command requires param.") 
        return TRUE 
    end 
    local slotName = {"Head Slot", "Amulet Slot", "Backpack Slot", "Armor Slot", "Right Hand", "Left Hand", "Legs Slot", "Feet Slot", "Ring Slot", "Ammo Slot"} 
    local player = getPlayerByNameWildcard(param) 
    if isPlayer(player) == TRUE then 
        local text = getPlayerName(player).."'s Equipment: "     
        for i=1, 10 do 
            text = text.."\n\n" 
            local item = getPlayerSlotItem(player, i) 
            if item.itemid > 0 then 
                if isContainer(item.uid) == TRUE then 
                    text = text..slotName[i]..": "..getItemNameById(item.itemid)..getItemsInContainer(item, 1) 
                else 
                    text = text..slotName[i]..": "..getItemNameById(item.itemid) 
                end 
            else 
                text = text..slotName[i]..": Empty" 
            end 
        end 
        doShowTextDialog(cid, 6579, text) 
    else 
        doPlayerSendCancel(cid, "This player is not online.") 
    end 
    return TRUE 
end
 
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
ohh, my fail ; )
Im testing on one char and i don't see this mistake!
thanks, rep++!
 

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,628
Best answers
0
Reaction score
30
Location
United States
I noticed that it only shows your own equipment (As pointed out by Grehy), so I changed one word in the script and got it working. All script credits go to Azi.

For advanced users:
Change:
Code:
local item = getPlayerSlotItem(cid, i)
To:
Code:
local item = getPlayerSlotItem(player, i)
For not so advanced users:
Just replace the coding:
Code:
-- Equipment spy by Azi [ersiu] -- 
function getItemsInContainer(cont, sep) 
    local text = "" 
    local tsep = "" 
    local count = "" 
    for i=1, sep do 
        tsep = tsep.."-" 
    end 
    tsep = tsep..">" 
    for i=0, getContainerSize(cont.uid)-1 do 
        local item = getContainerItem(cont.uid, i) 
        if isContainer(item.uid) == FALSE then 
            if item.type > 0 then 
                count = "("..item.type.."x)" 
            end 
            text = text.."\n"..tsep..getItemNameById(item.itemid).." "..count 
        else 
            if getContainerSize(item.uid) > 0 then 
                text = text.."\n"..tsep..getItemNameById(item.itemid)  
                text = text..getItemsInContainer(item, sep+2) 
            else 
                text = text.."\n"..tsep..getItemNameById(item.itemid) 
            end 
        end 
    end 
    return text 
end 

function onSay(cid, words, param, channel) 
    if(param == "") then 
        doPlayerSendCancel(cid, "Command requires param.") 
        return TRUE 
    end 
    local slotName = {"Head Slot", "Amulet Slot", "Backpack Slot", "Armor Slot", "Right Hand", "Left Hand", "Legs Slot", "Feet Slot", "Ring Slot", "Ammo Slot"} 
    local player = getPlayerByNameWildcard(param) 
    if isPlayer(player) == TRUE then 
        local text = getPlayerName(player).."'s Equipment: "     
        for i=1, 10 do 
            text = text.."\n\n" 
            local item = getPlayerSlotItem(player, i) 
            if item.itemid > 0 then 
                if isContainer(item.uid) == TRUE then 
                    text = text..slotName[i]..": "..getItemNameById(item.itemid)..getItemsInContainer(item, 1) 
                else 
                    text = text..slotName[i]..": "..getItemNameById(item.itemid) 
                end 
            else 
                text = text..slotName[i]..": Empty" 
            end 
        end 
        doShowTextDialog(cid, 6579, text) 
    else 
        doPlayerSendCancel(cid, "This player is not online.") 
    end 
    return TRUE 
end
Thanks for fixing that stupid bug :p
 
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
:)) thx for raport, im already edited first post too today at morning. : )
 

turdz

New Member
Joined
Apr 30, 2009
Messages
7
Best answers
0
Reaction score
0
w00t w00t, thanks! this helps a lot...especially with the vip feature in my ot...
rep++
 

Belthazor

New Member
Joined
Sep 20, 2008
Messages
528
Best answers
0
Reaction score
4
hey,

this is a greath script but small bug when i use like /eq player name it works but if there is space in players name example

/eq Belthazor = Works fine
/eq Test Belthazor = My Tibia Client crash and no error in consule

so maby u can fix this bug would then it will be really good script ;p
 

Mazen

Developer
Joined
Aug 20, 2007
Messages
612
Best answers
0
Reaction score
36
Location
Sweden
hey,

this is a greath script but small bug when i use like /eq player name it works but if there is space in players name example

/eq Belthazor = Works fine
/eq Test Belthazor = My Tibia Client crash and no error in consule

so maby u can fix this bug would then it will be really good script ;p
I don't think that bug can be fixed. I've got the same problem too and I think it's because the player has too many items and the client can't read the whole string.

What does Test Belthazor wear?
 

Belthazor

New Member
Joined
Sep 20, 2008
Messages
528
Best answers
0
Reaction score
4
he wares nothing i jsut made the char
only rook eq leatehr set you know
 
Top