Ir para conteúdo
vankk

[TFS 1.x] Checar items da database in-game

Recommended Posts

vankk    16
vankk

Funções:

  • Ao utilizar o comando !checkitem, itemId irá visualizar todos os jogadores da database no qual possuí o item sendo carregado no personagem e irá falar in-game.

Script:

function onSay(player, words, param)
	if not player:getGroup():getAccess() then
		return true
	end

	if not param then
		player:sendCancelMessage('Please type the command: !checkItem, itemId')
		return false
	end

	local itemId = tonumber(param)
    if not itemId then
        player:sendCancelMessage('The value should be numeric.')
        return false
    end

	local resultId = db.storeQuery(string.format('SELECT `name`, `id` FROM `players` WHERE `id` IN (SELECT `player_id` FROM `player_items` WHERE `itemtype` = %d)', itemId))
	local message = string.format('Results from the search from the itemId %d in our database:\n\n', itemId)
	if resultId ~= false then
		repeat
   			local playerName = result.getDataString(resultId, "name")
   			local playerId = result.getDataInt(resultId, "id")

   			local checkOnline = db.storeQuery(string.format('SELECT `player_id` FROM `players_online` WHERE `players_online`.`player_id` = %d', playerId))
   			if checkOnline ~= false then 
   				status = 'Online'
   			else
   				status = 'Offline'
   			end

			message = message .. playerName .." [".. status .."]\n"

		until not result.next(resultId)
		result.free(resultId)
	else
		message = message .. "There is no players with this item at our server."
	end

	player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, message)
	return false
end

 

NOTAS:

  • Na tag do talkaction.xml precisa ter separator = " "
  • Esse script só funciona na versão TFS 1.x do The Forgotten Server

 

Créditos ao van key key AKA eu.

Compartilhar este post


Link para o post
Majesty    1755
Majesty

Muito obrigado pela sua contribuição, seu tópico de conteúdo foi aprovado!
Nós do OTServ Brasil agradecemos, seu conteúdo com certeza ajudará a muitos outros. 
Você recebeu +1 REP!

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×