Ir para conteúdo
  • Cadastre-se

(Resolvido)Upgrade no comando /finditem


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Fala galera, sei que ando enchendo muito saco ultimamente hehe mas eu uso um script do @Vodkart que verifica tal item do jogador.

Script:

Spoiler

function onSay(cid, words, param)
    if param == '' or tonumber(param) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
    local item_id = getItemIdByName(tostring(param), false) 
    if not item_id then
        doPlayerSendCancel(cid, "This item does not exist.") return true
    end
    local str, player_depotitems, players_items, tile_items = "",{},{},{}
    local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
    if (dp:getID() ~= -1) then
        repeat
            player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
        until not(dp:next())
        dp:free()
    end
    local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
    if (pi:getID() ~= -1) then
        repeat
            players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
        until not(pi:next())
        pi:free()
    end
    local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
    if (hi:getID() ~= -1) then
        repeat
            local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
            tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
        until not(hi:next())
        hi:free()
    end     
    if #player_depotitems > 0 then
        str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
        for i = 1, table.maxn(player_depotitems) do
            str = str .. player_depotitems[2] .. ' ' .. getPlayerNameByGUID(player_depotitems[1]) ..' \n'
        end
    end
    if #players_items > 0 then
        str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
        for i = 1, table.maxn(players_items) do
            str = str .. players_items[2] .. ' ' .. getPlayerNameByGUID(players_items[1]) ..' \n'
        end
    end
    if #tile_items > 0 then
        str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
        for i = 1, table.maxn(tile_items) do
            str = str .. tile_items[1] .. ' - {x = ' .. tile_items[2] ..', y = ' .. tile_items[3] ..', z = ' .. tile_items[4] ..'} \n'
        end
    end
    return doShowTextDialog(cid,item_id, str)
end

 

E eu tenho um outro script aqui também que é muito bom. O que eu queria era pegar desse outro script(que estarei deixando tbm) pegar a opcao de online e offline. E por na script do Vodkart. E gostaria de por para procurar o item tanto por nome quanto para ID

Segundo script:

Spoiler

function onSay(cid, words, param, channel)
        param = tonumber(param) or ""
        if param == "" then
                return doPlayerSendCancel(cid, words .." [itemid]")
        end

        local result = db.getResult("SELECT name, online FROM players WHERE id IN (SELECT player_id FROM player_items WHERE itemtype = ".. param ..");")

        local msg = "Resultados da busca pelo item ".. param .." em seu banco de dados:\n\n"
        if result:getID() ~= -1 then
                while true do
                        local name = result:getDataString("name")
                        local online = result:getDataInt("online")

                        msg = msg .. name .." [".. (online == 1 and "Online" or "Offline") .."]\n"
                        if not result:next() then
                                break
                        end
                end
        else
                msg = msg .. "O item não foi encontrado em nenhum jogador."
        end
        doShowTextDialog(cid, param, msg)
        return true
end

-- by Yan Liima(Night)

 

REP+

Editado por Matheuus (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

kkk assim que tiver um tempo ja adiciono e edito aqui!!

function onSay(cid, words, param)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
    local str, player_depotitems, players_items, tile_items = "",{},{},{}
    local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
    if (dp:getID() ~= -1) then
        repeat
            player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
        until not(dp:next())
        dp:free()
    end
    local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
    if (pi:getID() ~= -1) then
        repeat
            players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
        until not(pi:next())
        pi:free()
    end
    local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
    if (hi:getID() ~= -1) then
        repeat
            local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
            tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
        until not(hi:next())
        hi:free()
    end     
    if #player_depotitems > 0 then
        str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
        for i = 1, table.maxn(player_depotitems) do
            local name = getPlayerNameByGUID(player_depotitems[1])
            local target_online = getPlayerByNameWildcard(name)
            str = str .. player_depotitems[2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
        end
    end
    if #players_items > 0 then
        str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
        for i = 1, table.maxn(players_items) do
            local name = getPlayerNameByGUID(players_items[1])
            local target_online = getPlayerByNameWildcard(name)
            str = str .. players_items[2] .. ' ' .. getPlayerNameByGUID(players_items[1]) ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
        end
    end
    if #tile_items > 0 then
        str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
        for i = 1, table.maxn(tile_items) do
            str = str .. tile_items[1] .. ' - {x = ' .. tile_items[2] ..', y = ' .. tile_items[3] ..', z = ' .. tile_items[4] ..'} \n'
        end
    end
    return doShowTextDialog(cid,item_id, str)
end

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
4 horas atrás, Vodkart disse:

kkk assim que tiver um tempo ja adiciono e edito aqui!!


function onSay(cid, words, param)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
    local str, player_depotitems, players_items, tile_items = "",{},{},{}
    local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
    if (dp:getID() ~= -1) then
        repeat
            player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
        until not(dp:next())
        dp:free()
    end
    local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
    if (pi:getID() ~= -1) then
        repeat
            players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
        until not(pi:next())
        pi:free()
    end
    local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
    if (hi:getID() ~= -1) then
        repeat
            local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
            tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
        until not(hi:next())
        hi:free()
    end     
    if #player_depotitems > 0 then
        str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
        for i = 1, table.maxn(player_depotitems) do
            local name = getPlayerNameByGUID(player_depotitems[1])
            local target_online = getPlayerByNameWildcard(name)
            str = str .. player_depotitems[2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
        end
    end
    if #players_items > 0 then
        str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
        for i = 1, table.maxn(players_items) do
            local name = getPlayerNameByGUID(players_items[1])
            local target_online = getPlayerByNameWildcard(name)
            str = str .. players_items[2] .. ' ' .. getPlayerNameByGUID(players_items[1]) ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
        end
    end
    if #tile_items > 0 then
        str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
        for i = 1, table.maxn(tile_items) do
            str = str .. tile_items[1] .. ' - {x = ' .. tile_items[2] ..', y = ' .. tile_items[3] ..', z = ' .. tile_items[4] ..'} \n'
        end
    end
    return doShowTextDialog(cid,item_id, str)
end

 

 

Quando uso o comando em um item que nenhum jogador tem exibe a tela vazia e não da nenhum erro. Quando uso o comando com algum item que o jogador tem da o seguinte erro:

Spoiler

[14/12/2018 12:32:23] [Error - TalkAction Interface] 
[14/12/2018 12:32:23] data/talkactions/scripts/finditem.lua:onSay
[14/12/2018 12:32:23] Description: 
[14/12/2018 12:32:23] (luaGetPlayerNameByGUID) Player not found

[14/12/2018 12:32:23] [Error - TalkAction Interface] 
[14/12/2018 12:32:23] data/talkactions/scripts/finditem.lua:onSay
[14/12/2018 12:32:23] Description: 
[14/12/2018 12:32:23] (luaGetPlayerNameByGUID) Player not found

[14/12/2018 12:32:23] [Error - TalkAction Interface] 
[14/12/2018 12:32:23] data/talkactions/scripts/finditem.lua:onSay
[14/12/2018 12:32:23] Description: 
[14/12/2018 12:32:23] data/talkactions/scripts/finditem.lua:49: attempt to concatenate a nil value
[14/12/2018 12:32:23] stack traceback:
[14/12/2018 12:32:23]     data/talkactions/scripts/finditem.lua:49: in function <data/talkactions/scripts/finditem.lua:1>

 

Link para o post
Compartilhar em outros sites
  • Solução

entendi, faltou o "i" do for... vocês copiam o código e não colocam no code box, ai induz ao erro mesmo.

 

function onSay(cid, words, param)
	if param == '' or tonumber(param) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
		return true
	end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerNameByGUID(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerNameByGUID(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
	end
	return doShowTextDialog(cid,item_id, str)
end

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
41 minutos atrás, Vodkart disse:

entendi, faltou o "i" do for... vocês copiam o código e não colocam no code box, ai induz ao erro mesmo.

 


function onSay(cid, words, param)
	if param == '' or tonumber(param) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
		return true
	end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerNameByGUID(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerNameByGUID(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
	end
	return doShowTextDialog(cid,item_id, str)
end

 

 

Opa, kk
coloquei essa tag aqui, quando eu uso um nome errado só pra teste da isso aqui, e quando eu escrevo o nome certo do item da esse erro aqui na distro, e não aparece nada no jogo, até pensei fosse o mesmo erro que o rapaz a cima, mas acho que não é.
 

<talkaction log="yes" words="!find;/find" access="4" event="script" value="finditem.lua"/>
14:13 /find teste staff of time 
14:13 Item wich such name does not exists.
[14:14:33.474] [Error - TalkAction Interface]
[14:14:33.484] data/talkactions/scripts/finditem.lua:onSay
[14:14:33.485] Description:
[14:14:33.493] data/talkactions/scripts/finditem.lua:41: attempt to concatenate local 'name' (a nil value)
[14:14:33.496] stack traceback:
[14:14:33.497]  data/talkactions/scripts/finditem.lua:41: in function <data/talkactions/scripts/finditem.lua:1>

 

       112674.gif

 

 

 

Link para o post
Compartilhar em outros sites
1 hora atrás, Vodkart disse:

entendi, faltou o "i" do for... vocês copiam o código e não colocam no code box, ai induz ao erro mesmo.

 


function onSay(cid, words, param)
	if param == '' or tonumber(param) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
		return true
	end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerNameByGUID(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerNameByGUID(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
	end
	return doShowTextDialog(cid,item_id, str)
end

 

 

Agora funcionou show. so faltou funcionar com o ID tbm. ta so pelo nome

Link para o post
Compartilhar em outros sites
4 horas atrás, Matheuus disse:

Agora funcionou show. so faltou funcionar com o ID tbm. ta so pelo nome

 

Spoiler

function onSay(cid, words, param)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerNameByGUID(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerNameByGUID(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
    else
		str = str .. (str ~= "" and "" or "O item não foi encontrado em nenhum jogador.")
	end
	return doShowTextDialog(cid,item_id, str)
end

 

 

Acho que agora vai! Como o Vodkart teve que pegar o script original por causa do code box ele esqueceu de alterar uma parte. Aproveitei e adicionei a msg caso o item não seja encontrado.

Editado por Yan Liima (veja o histórico de edições)

════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═══╗

Te Ajudei? Rep + e ficamos Quits

166420979_logoyanliimaornight.png.33f822b8970081a5b3646e85dbfd5934.png

Precisando de ajuda?

discord.png.1ecd188791d0141f74d99db371a2e0a4.png.890d5a38d7bcde75543c72b624a65de1.pngDiscord: Yan Liima #3702

Programador Júnior de LUA, PHP e JavaScript

Juntos somos lendas, separados somos Mitos!

╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝

Link para o post
Compartilhar em outros sites
17 minutos atrás, Matheuus disse:

Agora funcionou show. so faltou funcionar com o ID tbm. ta so pelo nome

 

 

Já está pelo ID também, olha:

 

	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end

 

 

o seu servidor é otx?

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
1 minuto atrás, Vodkart disse:

 

Já está pelo ID também, olha:

 


	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end

 

 

Nao estava indo, mas nem dava erro tbm

 

6 minutos atrás, Yan Liima disse:
  Mostrar conteúdo oculto


function onSay(cid, words, param)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerNameByGUID(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerNameByGUID(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
		else
		str = str .. "O item não foi encontrado em nenhum jogador."
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
	end
	return doShowTextDialog(cid,item_id, str)
end

 

 

Acho que agora vai! Como o Vodkart teve que pegar o script original por causa do code box ele esqueceu de alterar uma parte. Aproveitei e adicionei a msg caso o item não seja encontrado.

 

Deu certooo vlwwws vcs sao de mais. Pra quem dou melhor resposta?

Link para o post
Compartilhar em outros sites
Agora, Matheuus disse:

Nao estava indo, mas nem dava erro tbm

 

Deu certooo vlwwws vcs sao de mais. Pra quem dou melhor resposta?

 

Pro Vod né irmão, o merito é dele kkkk

 

Aproveitando aqui, @Vodkart responde mensagem.

════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═══╗

Te Ajudei? Rep + e ficamos Quits

166420979_logoyanliimaornight.png.33f822b8970081a5b3646e85dbfd5934.png

Precisando de ajuda?

discord.png.1ecd188791d0141f74d99db371a2e0a4.png.890d5a38d7bcde75543c72b624a65de1.pngDiscord: Yan Liima #3702

Programador Júnior de LUA, PHP e JavaScript

Juntos somos lendas, separados somos Mitos!

╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝

Link para o post
Compartilhar em outros sites
11 minutos atrás, Yan Liima disse:

Pro Vod né irmão, o merito é dele kkkk

 

Aproveitando aqui, @Vodkart responde mensagem.

 

tem como olhar o comentario que eu fiz ali em cima? kk

       112674.gif

 

 

 

Link para o post
Compartilhar em outros sites

@Zzyzx 

 

Seu servidor é otx? não sei te dizer porque deu esse erro, estranho, testou com outro item além desse "teste staff time" ?

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
15 minutos atrás, Zzyzx disse:

tem como olhar o comentario que eu fiz ali em cima? kk

 

Cara olhei um dos teus topicos e vi que você usa TFS, e se com o amigo ali funcionou deveria funcionar contigo também.

Verifique o seu arquivo .lua e vê se o formato não está bugado

════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═══╗

Te Ajudei? Rep + e ficamos Quits

166420979_logoyanliimaornight.png.33f822b8970081a5b3646e85dbfd5934.png

Precisando de ajuda?

discord.png.1ecd188791d0141f74d99db371a2e0a4.png.890d5a38d7bcde75543c72b624a65de1.pngDiscord: Yan Liima #3702

Programador Júnior de LUA, PHP e JavaScript

Juntos somos lendas, separados somos Mitos!

╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝

Link para o post
Compartilhar em outros sites
Agora, Vodkart disse:

@Zzyzx 

 

Seu servidor é otx? não sei te dizer porque deu esse erro, estranho, testou com outro item além desse "teste staff time" ?

 

TFS 0.4

 

Estranho tem item que da certo, e item que buga a distro, se der, da um visu no video pra entender certinho.

6 minutos atrás, Yan Liima disse:

Cara olhei um dos teus topicos e vi que você usa TFS, e se com o amigo ali funcionou deveria funcionar contigo também.

Verifique o seu arquivo .lua e vê se o formato não está bugado

 

Ta não, da um visu no video que acabei de manda ai!

       112674.gif

 

 

 

Link para o post
Compartilhar em outros sites

 

3 horas atrás, Zzyzx disse:

TFS 0.4

 

Estranho tem item que da certo, e item que buga a distro, se der, da um visu no video pra entender certinho.

Ta não, da um visu no video que acabei de manda ai!

 

Sinceramente não faço ideia do motivo disso estar acontecendo. É como se uma hora ele reconhessece a função getPlayerNameByGUID e outra hora não. De qualquer forma tente dessa meneira:

function onSay(cid, words, param)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerByNameWildcard(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerByNameWildcard(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
    else
		str = str .. (str ~= "" and "" or "O item não foi encontrado em nenhum jogador.")
	end
	return doShowTextDialog(cid,item_id, str)
end

 

Editado por Yan Liima (veja o histórico de edições)

════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═══╗

Te Ajudei? Rep + e ficamos Quits

166420979_logoyanliimaornight.png.33f822b8970081a5b3646e85dbfd5934.png

Precisando de ajuda?

discord.png.1ecd188791d0141f74d99db371a2e0a4.png.890d5a38d7bcde75543c72b624a65de1.pngDiscord: Yan Liima #3702

Programador Júnior de LUA, PHP e JavaScript

Juntos somos lendas, separados somos Mitos!

╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝

Link para o post
Compartilhar em outros sites
15 minutos atrás, Yan Liima disse:

 

Sinceramente não faço ideia do motivo disso estar acontecendo. É como se uma hora ele reconhessece a função getPlayerNameByGUID e outra hora não. De qualquer forma tente dessa meneira:


function onSay(cid, words, param)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "/find item name")
        return true
    end
	local item_id = tonumber(param)
		if(not item_id) then
			item_id = getItemIdByName(tostring(param), false)
				if(not item_id) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true
				end
		end
	local str, player_depotitems, players_items, tile_items = "",{},{},{}
	local dp = db.getResult("SELECT `player_id`, `count` FROM `player_depotitems` WHERE `itemtype` = "..item_id),{}
	if (dp:getID() ~= -1) then
		repeat
			player_depotitems[#player_depotitems+1] = {dp:getDataInt("player_id"), dp:getDataInt("count") }
		until not(dp:next())
		dp:free()
	end
	local pi = db.getResult("SELECT `player_id`, `count` FROM `player_items` WHERE `itemtype` = "..item_id),{}
	if (pi:getID() ~= -1) then
		repeat
			players_items[#players_items+1] = {pi:getDataInt("player_id"), pi:getDataInt("count") }
		until not(pi:next())
		pi:free()
	end
	local hi = db.getResult("SELECT `tile_id`, `count` FROM `tile_items` WHERE `itemtype` = "..item_id),{}
	if (hi:getID() ~= -1) then
		repeat
			local tile = db.getResult("SELECT `house_id`, `x`, `y`, `z` FROM `tiles` WHERE `id` = "..hi:getDataInt("tile_id")),{}
			tile_items[#tile_items+1] = {tile:getDataInt("house_id"),tile:getDataInt("x"),tile:getDataInt("y"),tile:getDataInt("z")}
		until not(hi:next())
		hi:free()
	end	 
	if #player_depotitems > 0 then
		str = str .. "#DEPOT ITEMS#\nQuantidade - Jogador\n"
		for i = 1, table.maxn(player_depotitems) do
			local name = getPlayerByNameWildcard(player_depotitems[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. player_depotitems[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #players_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#PLAYER ITEMS#\nQuantidade - Jogador\n" or "#PLAYER ITEMS#\nQuantidade - Jogador\n") 
		for i = 1, table.maxn(players_items) do
			local name = getPlayerByNameWildcard(players_items[i][1])
			local target_online = getPlayerByNameWildcard(name)
			str = str .. players_items[i][2] .. ' ' .. name ..' | '..(not isPlayer(target_online) and 'Offline' or 'Online')..'\n'
		end
	end
	if #tile_items > 0 then
		str = str .. (str ~= "" and "--------------//-------------\n\n#TILE ITEMS#\nHouse ID - Tile Position\n" or "#TILE ITEMS#\nHouse ID -Tile Position\n") 
		for i = 1, table.maxn(tile_items) do
			str = str .. tile_items[i][1] .. ' - {x = ' .. tile_items[i][2] ..', y = ' .. tile_items[i][3] ..', z = ' .. tile_items[i][4] ..'} \n'
		end
    else
		str = str .. (str ~= "" and "" or "O item não foi encontrado em nenhum jogador.")
	end
	return doShowTextDialog(cid,item_id, str)
end

 

 

Estranho né, mas ta dando a mesma coisa =\

       112674.gif

 

 

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo