Ir para conteúdo
  • Cadastre-se

Normal getSpecialAttribute on all items


Posts Recomendados

Hi
Is it possible to consult the special attributes in all the items?
Depot, Players, Houses, Tiles Etc.

I USE TFS 1.2

I want to transform items with a certain attribute.

Example:

If Allitems(itemid):getSpecialAttribute <= 12345 then
transformto()
end

to place it in a globalevent

Link para o post
Compartilhar em outros sites
51 minutos atrás, luanluciano93 disse:

 

Please describe your question better ... what kind of attribute? 

What do you intend to do?

 

functions: setSpecialAttribute and getSpecialAttribute()

Example:

i put SpecialAttrubute with:

local new_item = player:addItem(itemId, 1)            
new_item:setSpecialAttribute("timerOnExp", os.time()+60*60)

----------------------------------------------------------------------------------

and call with:

item:getSpecialAttribute("timerOnExp") this return valor "os.time()+60*60"

----------------------------------------------------------------------------------

 

need call all items in globalevents:

 

If Allitems:getSpecialAttribute("timerOnExp") <= os.time() then
transformto(itemId)
end

Link para o post
Compartilhar em outros sites

 

Sorry for the delay ... I'd like to know the purpose of your script, so I could help you better ... 

 

 

• To do this sort of fetch you I think you want, you would need to use sql commands in table 'player_items': 

CREATE TABLE IF NOT EXISTS `player_items` (
  `player_id` int(11) NOT NULL DEFAULT '0',
  `pid` int(11) NOT NULL DEFAULT '0',
  `sid` int(11) NOT NULL DEFAULT '0',
  `itemtype` smallint(6) NOT NULL DEFAULT '0',
  `count` smallint(5) NOT NULL DEFAULT '0',
  `attributes` blob NOT NULL,
  FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
  KEY `sid` (`sid`)
) ENGINE=InnoDB;

 

• I'll assume that you want to turn the item over after your time runs out ... this exists in items.xml, an example is soft boots, keys: durations e decayTo. ... 

	<item id="2640" article="a" name="pair of soft boots (faster regeneration)">
		<attribute key="weight" value="800" />
		<attribute key="slotType" value="feet" />
		<attribute key="decayTo" value="10021" />
		<attribute key="transformDeEquipTo" value="6132" />
		<attribute key="duration" value="14400" />
		<attribute key="healthGain" value="1" />
		<attribute key="healthTicks" value="2000" />
		<attribute key="manaGain" value="2" />
		<attribute key="manaTicks" value="1000" />
		<attribute key="showduration" value="1" />
		<attribute key="showattributes" value="1" />
	</item>

 

• Or you can also have the server do this automatically by putting a duration and a decayTo on the item you create ... use these functions and keys

functions:
	item:getAttribute(key)
	item:setAttribute(key, value)
	item:removeAttribute(key)
	item:hasAttribute(key)

keys:
	ITEM_ATTRIBUTE_OWNER
	ITEM_ATTRIBUTE_DESCRIPTION
	ITEM_ATTRIBUTE_DURATION
	ITEM_ATTRIBUTE_DECAYSTATE

I hope I have helped. Hugs!
 

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

 

Sorry for the delay ... I'd like to know the purpose of your script, so I could help you better ... 

 

 

• To do this sort of fetch you I think you want, you would need to use sql commands in table 'player_items': 


CREATE TABLE IF NOT EXISTS `player_items` (
  `player_id` int(11) NOT NULL DEFAULT '0',
  `pid` int(11) NOT NULL DEFAULT '0',
  `sid` int(11) NOT NULL DEFAULT '0',
  `itemtype` smallint(6) NOT NULL DEFAULT '0',
  `count` smallint(5) NOT NULL DEFAULT '0',
  `attributes` blob NOT NULL,
  FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
  KEY `sid` (`sid`)
) ENGINE=InnoDB;

 

• I'll assume that you want to turn the item over after your time runs out ... this exists in items.xml, an example is soft boots, keys: durations e decayTo. ... 


	<item id="2640" article="a" name="pair of soft boots (faster regeneration)">
		<attribute key="weight" value="800" />
		<attribute key="slotType" value="feet" />
		<attribute key="decayTo" value="10021" />
		<attribute key="transformDeEquipTo" value="6132" />
		<attribute key="duration" value="14400" />
		<attribute key="healthGain" value="1" />
		<attribute key="healthTicks" value="2000" />
		<attribute key="manaGain" value="2" />
		<attribute key="manaTicks" value="1000" />
		<attribute key="showduration" value="1" />
		<attribute key="showattributes" value="1" />
	</item>

 

• Or you can also have the server do this automatically by putting a duration and a decayTo on the item you create ... use these functions and keys


functions:
	item:getAttribute(key)
	item:setAttribute(key, value)
	item:removeAttribute(key)
	item:hasAttribute(key)

keys:
	ITEM_ATTRIBUTE_OWNER
	ITEM_ATTRIBUTE_DESCRIPTION
	ITEM_ATTRIBUTE_DURATION
	ITEM_ATTRIBUTE_DECAYSTATE

I hope I have helped. Hugs!
 

 

if I know those functions, the problem that the decay stops when the character logout, or when they put it in the depot, then I'm trying to make a system where certain items expire in a certain time.

 

as in tibia rl

11:53 You see a temple teleport scroll that will expire in 7 days.
It weighs 1.20 oz.

 

If you do not use the item in 7 days, it disappears.

Link para o post
Compartilhar em outros sites

 

Maybe if you use it like this ... 

item:setAttribute(ITEM_ATTRIBUTE_DATE, X)
And then search by sql command: 
table player_depotitems:
	SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_depotitems` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%data%'

table player_items:
	SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%data%'

 

Link para o post
Compartilhar em outros sites
5 horas atrás, luanluciano93 disse:

 

Maybe if you use it like this ... 


item:setAttribute(ITEM_ATTRIBUTE_DATE, X)

And then search by sql command: 

table player_depotitems:
	SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_depotitems` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%data%'

table player_items:
	SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%data%'

 

 

I do not have much experience with MySQL.

How could I use it in global event, to find atribute

item:setSpecialAttribute("timerOnExp", os.time()+60*60)

 

how declare delete items, if os.time() > getSpecialAttribute("timerOnExp") ?

 

I plan to implement it in a globalevent.xml

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

First of all, you need to know how is your attribute stored. Try executing the MySQL command that luanluciano posted. For example:

SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%timerOnExp%'


After that, you'll get the results and know how the attribute is stored, then you need to figure out how to retrieve the data. If you're not able to do it yourself, post the results so we can try to help you with that.

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites
7 horas atrás, Rusherzin disse:

First of all, you need to know how is your attribute stored. Try executing the MySQL command that luanluciano posted. For example:


SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%timerOnExp%'


After that, you'll get the results and know how the attribute is stored, then you need to figure out how to retrieve the data. If you're not able to do it yourself, post the results so we can try to help you with that.

 

my results:

consulta.png

I would appreciate your' help, since I do not know how to finish it

 

Link para o post
Compartilhar em outros sites

I'm not sure if it's going to work because I did not test the code.
Anyway, I think you can do something like this:
 

local TItoDelete = db.storeQuery("SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) AS `attr` FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%timerOnExp%'")

    if TItoDelete then -- if the MySQL result is not empty
        repeat
            local attrstring = result.getString(TItoDelete, "attr") -- get the attribute
            local attrnumber = tonumber(string.sub(attrstring, -12, string.len(attrstring)-2)) -- here I try to get only the number (I'm not sure if it will work)
            if (os.time() >= attrnumber) then
		local playerid = result.getNumber(TItoDelete, "player_id")
		local pid      = result.getNumber(TItoDelete, "pid")
                local sid      = result.getNumber(TItoDelete, "sid")
            	db.storeQuery("DELETE FROM `player_items` WHERE `player_id`="..playerid.." AND `pid` = "..pid.." AND `sid` ="..sid) -- deletes item
           	end
        until not result.next(TItoDelete)
    end

By the way, this one is just an example that should work for `player_items`.

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites
7 minutos atrás, Rusherzin disse:

I'm not sure if it's going to work because I did not test the code.
Anyway, I think you can do something like this:
 


local TItoDelete = db.storeQuery("SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) AS `attr` FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%timerOnExp%'")

    if TItoDelete then -- if the MySQL result is not empty
        repeat
            local attrstring = result.getString(TItoDelete, "attr") -- get the attribute
            local attrnumber = tonumber(string.sub(attrstring, -12, string.len(attrstring)-2)) -- here I try to get only the number (I'm not sure if it will work)
            if (os.time() >= attrnumber) then
		local playerid = result.getNumber(TItoDelete, "player_id")
		local pid      = result.getNumber(TItoDelete, "pid")
                local sid      = result.getNumber(TItoDelete, "sid")
            	db.storeQuery("DELETE FROM `player_items` WHERE `player_id`="..playerid.." AND `pid` = "..pid.." AND `sid` ="..sid) -- deletes item
           	end
        until not result.next(TItoDelete)
    end

By the way, this one is just an example that should work for `player_items`.

 

:7: bad argument #1 to 'len' <string expected, got boolean)

Line 7:

            local attrnumber = tonumber(string.sub(attrstring, -12, string.len(attrstring)-2)) -- here I try to get only the number (I'm not sure if it will work)

 

 

Can not this be adapted to do what I'm looking for?

Anti-Dupe - Delete all items with duplicated serial from your database.

tablesToCheck = {"player_items", "player_depotitems", "tile_items", {"player_items", {"player_depotitems", "tile_items"}}, {"player_depotitems", "tile_items"}}
 
function onStartup()
    local text, final = "", ""
    local filex = "data/logs/duplicated.txt"
    local f = io.open(filex, "a+")
    local count = 0
    for i = 1, table.maxn(tablesToCheck) do
        if type(tablesToCheck[i]) == "string" then
            local query = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM " .. tablesToCheck[i] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM " .. tablesToCheck[i] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 1)")
            if query:getID() ~= -1 then
                while(true) do
                    local delete = db.executeQuery("delete from " .. tablesToCheck[i] .. " where SUBSTRING(CONVERT(attributes USING latin1) FROM 18) = " .. db.escapeString(query:getDataString("track")) .. " and player_id = " .. query:getDataInt("player_id") .. ";")
                    text = "[!] -> Deleting items with duplicated serial from '" .. tablesToCheck[i] .. "': [Player: " .. getPlayerNameByGUID(query:getDataInt("player_id")) .. ", Item: " .. query:getDataInt("itemtype") .. ", Count: " .. query:getDataInt("count") .. ", Serial: " .. query:getDataString("track") .."]... " .. (delete and "Success!" or "Failed!")
                    count = (delete and count + 1 or count)
                    final = final .. (final ~= "" and "\n" or "") .. text
                    print(text)
                    if not query:next() then break end
                end
            end
        else
            if type(tablesToCheck[i][2]) == "string" then
                local query = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM " .. tablesToCheck[i][1] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM " .. tablesToCheck[i][2] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 0)")
                if query:getID() ~= -1 then
                    while(true) do
                        local query_ = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM " .. tablesToCheck[i][2] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM " .. tablesToCheck[i][1] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 0)")
                        local delete = db.executeQuery("delete from " .. tablesToCheck[i][1] .. " where SUBSTRING(CONVERT(attributes USING latin1) FROM 18) = " .. db.escapeString(query:getDataString("track")) .. ";")
                        count = (delete and count + 1 or count)
                        local delete2 = db.executeQuery("delete from " .. tablesToCheck[i][2] .. " where SUBSTRING(CONVERT(attributes USING latin1) FROM 18) = " .. db.escapeString(query:getDataString("track")) .. ";")
                        count = (delete2 and count + 1 or count)
                        text = "[!] -> Deleting item with duplicated serial from '" .. tablesToCheck[i][1] .. "' [Player: " .. getPlayerNameByGUID(query:getDataInt("player_id")) .. ", Item: " .. query:getDataInt("itemtype") .. ", Count: " .. query:getDataInt("count") .. ", Serial: " .. query:getDataString("track") .."]... " .. (delete and "Success!" or "Failed!") ..
                        "\n[!] -> Deleting item with duplicated serial from '" .. tablesToCheck[i][2] .. "' [Player: " .. getPlayerNameByGUID(query_:getDataInt("player_id")) .. ", Item: " .. query_:getDataInt("itemtype") .. ", Count: " .. query_:getDataInt("count") .. ", Serial: " .. query_:getDataString("track") .."]... " .. (delete and "Success!" or "Failed!")
                        final = final .. (final ~= "" and "\n" or "") .. text
                        print(text)
                        if not query:next() then break end
                    end
                end
            else
                for j = 1, #tablesToCheck[i][2] do
                    local query = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM " .. tablesToCheck[i][1] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM " .. tablesToCheck[i][2][j] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 0)")
                    if query:getID() ~= -1 then
                        while(true) do
                            local query_ = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM " .. tablesToCheck[i][2][j] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM " .. tablesToCheck[i][1] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 0)")
                            local delete = db.executeQuery("delete from " .. tablesToCheck[i][1] .. " where SUBSTRING(CONVERT(attributes USING latin1) FROM 18) = " .. db.escapeString(query:getDataString("track")) .. ";")
                            count = (delete and count + 1 or count)
                            local delete2 = db.executeQuery("delete from " .. tablesToCheck[i][2][j] .. " where SUBSTRING(CONVERT(attributes USING latin1) FROM 18) = " .. db.escapeString(query:getDataString("track")) .. ";")
                            count = (delete2 and count + 1 or count)
                            text = "[!] -> Deleting item with duplicated serial from '" .. tablesToCheck[i][1] .. "' [Player: " .. getPlayerNameByGUID(query:getDataInt("player_id")) .. ", Item: " .. query:getDataInt("itemtype") .. ", Count: " .. query:getDataInt("count") .. ", Serial: " .. query:getDataString("track") .."]... " .. (delete and "Success!" or "Failed!") ..
                            "\n[!] -> Deleting item with duplicated serial from '" .. tablesToCheck[i][2][j] .. "' [Player: " .. getPlayerNameByGUID(query_:getDataInt("player_id")) .. ", Item: " .. query_:getDataInt("itemtype") .. ", Count: " .. query_:getDataInt("count") .. ", Serial: " .. query_:getDataString("track") .."]... " .. (delete and "Success!" or "Failed!")
                            final = final .. (final ~= "" and "\n" or "") .. text
                            print(text)
                            if not query:next() then break end
                        end
                    end
                end
            end
        end
    end
    if f ~= nil then
        f:write("[" .. os.date("%d %B %Y %X ", os.time()) .. "] >> [Anti-Dupe] " .. count .. " duplicated items have been deleted from the database.\n" .. (final == "" and "[!] -> No duplicated item was found in the database" or final) .. "\n\n")
        f:close()
    else
        print("[!] -> [Anti-Dupe] Cannot save info to file!")
    end
    return true
end
 

 

Link para o post
Compartilhar em outros sites

I'm sorry, but I don't know why it's returning a bool instead of a string.

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

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.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo