Ir para conteúdo

72 votos

  1. 1. Aparecer o nome do owner no item?

    • Sim
      69
    • Não
      3

Por favor faça o login ou crie uma conta para votar nesta enquete.

Featured Replies

Postado

Bem o sistema é basicamente isso: Fazer com que so um player possa equipar determinado item.

Eu fiquei em duvida se botava ou nao botava para aparecer o nome do owner no item, por isso fiz uma enquete para esse topico, a que vencer eu faço.

O script esta em mod, voce nao precisa nem mexer no mod.

Crie um arquivo.xml na pasta mods do seu ot e nomeie-o de ownersystem (é extremamente importante que o nome seja esse.) e bote esse script:

<?xml version="1.0" encoding="UTF-8"?>

<mod name="OwnerSystem" enabled="yes" author="MatheusMkalo" credits="Cezar (Patterns)">             


<config name="OwnerLib"><![CDATA[

function getSlotIds(tag)

    local file = "mods/ownersystem.xml"

    local input = assert(io.open(file))

    local content = assert(input:read("*a"))

    local tag = content:match("(<movevent[^>]*slot=[\"']".. tag .."[\"'][^>]*>)")

    local itemid = tag:match("itemid=[\"'](.-)[\"']")

    input:close()

    return itemid:explode(";")

end


function writeId(tag, id)

        local file = "mods/ownersystem.xml"

        local input = assert(io.open(file))

	local content = assert(input:read("*a"))

	local tag = content:match("(<movevent[^>]*slot=[\"']".. tag .."[\"'][^>]*>)")

	local itemid = tag:match("itemid=[\"'](.-)[\"']")

	input:close()

	if(itemid:match(tostring(id))) then return true end

 	if(itemid == "") then

		itemid = id

	else

		itemid = itemid .. ";" .. id

	end

	local ntag = tag:gsub("itemid=[\"'](.-)[\"']", "itemid=\"" .. itemid .. "\"")

	local content = content:gsub(tag, ntag)

	local output = assert(io.open(file, "w"))

	output:write(content)

	output:close()

        addEvent(doReloadInfo, 1000, 22)

end


function getItemType(itemid)

    local slottypes = {"head", "body", "legs", "feet"}

    local arq = io.open("data/items/items.xml", "r"):read("*all")

    local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>')

    local slot = ""

    for i,x in pairs(slottypes) do

        if attributes:find(x) then

	        slot = x

		    break

	    end

    end

    if slot == "body" then

        slot = "armor"

    end

return slot

end


function isHandedWeapon(itemuid)

    local typee = getItemWeaponType(itemuid) or 0

    if typee >= 1 and typee <= 6 then

        return TRUE

    end

end


function isPlayerOwnerItem(cid, itemuid)

    return not getItemAttribute(itemuid, "ownerguid") or getItemAttribute(itemuid, "ownerguid") == getPlayerGUID(cid)

end


function setItemOwner(itemuid, cid)

    if isHandedWeapon(itemuid) then

        local equips = getSlotIds("hand")

        if not table.find(equips, getItemIdByName(getItemName(itemuid))) then

            writeId("hand", getItemIdByName(getItemName(itemuid)))

        end

        doItemSetAttribute(itemuid, "ownerguid", getPlayerGUID(cid))

    elseif getItemType(getItemIdByName(getItemName(itemuid))) then

        local equips = getSlotIds(getItemType(getItemIdByName(getItemName(itemuid))))

        if not table.find(equips, getItemIdByName(getItemName(itemuid))) then

            writeId(getItemType(getItemIdByName(getItemName(itemuid))), getItemIdByName(getItemName(itemuid)))

        end

        doItemSetAttribute(itemuid, "ownerguid", getPlayerGUID(cid))

    end

end

]]></config>


<movevent type="Equip" itemid="" slot="head" event="script"><![CDATA[

    domodlib("OwnerLib")

    if not isPlayerOwnerItem(cid, item.uid) then

        addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.")

    else

        return TRUE

    end

]]></movevent>


<movevent type="Equip" itemid="" slot="hand" event="script"><![CDATA[

    domodlib("OwnerLib")

    if not isPlayerOwnerItem(cid, item.uid) then

        addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.")

    else

        return TRUE

    end

]]></movevent>


<movevent type="Equip" itemid="" slot="legs" event="script"><![CDATA[

    domodlib("OwnerLib")

    if not isPlayerOwnerItem(cid, item.uid) then

        addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.")

    else

        return TRUE

    end

]]></movevent>


<movevent type="Equip" itemid="" slot="armor" event="script"><![CDATA[

    domodlib("OwnerLib")

    if not isPlayerOwnerItem(cid, item.uid) then

        addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.")

    else

        return TRUE

    end

]]></movevent>


<movevent type="Equip" itemid="" slot="feet" event="script"><![CDATA[

    domodlib("OwnerLib")

    if not isPlayerOwnerItem(cid, item.uid) then

        addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.")

    else

        return TRUE

    end

]]></movevent>


</mod>
Agora vá na pasta libs e abra o arquivo.lua que tem o nome de functions ou 050-functions (pode variar de ot pra ot) e adicione essa funçao:
function setItemOwner(itemuid, cid)

    domodlib("OwnerLib")

    return setItemOwner(itemuid, cid)

end

Agora vá em data/talkactions/scripts e abra o arquivo createitem.lua e mude o script para esse:
function onSay(cid, words, param, channel)

	if(param == '') then

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")

		return true

	end


	local t = string.explode(param, ",")

	local ret = RETURNVALUE_NOERROR

	local pos = getCreaturePosition(cid)


	local id = tonumber(t[1])

	if(not id) then

		id = getItemIdByName(t[1], false)

		if(not id) then

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")

			return true

		end

	end


	local amount = 100

	if(t[2]) then

		amount = t[2]

	end


	local item = doCreateItemEx(id, amount)

	if(t[3] and getBooleanFromString(t[3])) then

		if(t[4] and getBooleanFromString(t[4])) then

			pos = getCreatureLookPosition(cid)

		end


		ret = doTileAddItemEx(pos, item)

	else

		doPlayerAddItem(cid, id, amount)

		ret = RETURNVALUE_NOERROR

	end


	if(ret ~= RETURNVALUE_NOERROR) then

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[1])

		return true

	end


	doDecayItem(item)

	if(not isPlayerGhost(cid)) then

		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)

	end


	return true

end

É de extrema importancia que voce mude o script do /i, pois o i que vem nos ots contem um bug que arruina com o sistema de owner.

Pronto agora você so precisa juntar a minha funçao setItemOwner(itemuid, cid) com qualquer outro script de quest whatever.

Lembre-se se voce quizer algum script que use esse meu sistema, peça-o na sessao de pedidos de scripts, não aqui.

  • Respostas 10
  • Visualizações 4.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Vou falar apenas uma vez... Não irei tolerar discussões vindas de outros fórums. Se vocês tem alguma diferença, resolvam por MSN ou onde a criaram. @Kibe Quando achar que algum membro ripou

  • como ficaria para executar o comando /i? estou tentando /i spike sword, player e não vai.

  • 1 month later...

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo