Ir para conteúdo
Entre para seguir isso  
ADM Bruninho

Sistema De Owner Para Equips

Recommended Posts

ADM Bruninho    3
ADM Bruninho

Galera vi esse sistema em um outro forum,achei muito interessante e resolvi trazer para a galera do Forum

 

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.

 

Galera quem gosto não se esqueça do REP+ :alegre:

Creditos

MatheusMkalo(por ter feito todo o sistema)

ADM Bruninho(por trazer para o forum)

Editado por ADM Bruninho

Compartilhar este post


Link para o post
iuniX    4
iuniX

Não encontrei nenhum problema aparente no script. Aprovado e movido.

Editado por iuniX

Compartilhar este post


Link para o post
luigilc    0
luigilc
É 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.

 

Não entendi isso, de resto mito bom esse sistema

Compartilhar este post


Link para o post
Asould Acalaylaa    5
Asould Acalaylaa

/\ Também não entendi.

_

 

O sistema é pra o que? Pra ter o seu nome escrito nos equips?

Compartilhar este post


Link para o post
ADM Bruninho    3
ADM Bruninho

para o script não bugar vc tem q mudar o createitem.lua q in-game eo /i que o god usa para fazer items

se não modificar ele o script não ira funcionar corretamente !

Compartilhar este post


Link para o post
Kekezito_LHP    1
Kekezito_LHP

Bom Falto ums Detalhes

Funçao?

Server Testado?

Ctrl+c e Ctrl + v é facil -.-

Compartilhar este post


Link para o post
grilo13    60
grilo13

Poderia estar bem organizado, ai não teria perguntas como a minha:

 

1º O que ele realmente faz? Coloca seu nome nos itens? Apenas você pode usar os itens?

2º O meu OT não tem a pasta MOD, o que devo fazer?

3º Quais são as TalkActions? Você criou um arquivo de Talkaction e não falou quais as talks

 

Acho que só neh ;/

Compartilhar este post


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

    Nenhum usuário registrado visualizando esta página.

×