Ir para conteúdo

Featured Replies

Postado

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)

Resolvido por Vodkart

Ir para solução
  • Respostas 15
  • Visualizações 884
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • 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

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

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

Postado

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

 

Postado
  • Autor
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>

 

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

 

Postado
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

 

 

 

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo