Szerző Téma: Item lekérés  (Megtekintve 959 alkalommal)

Nem elérhető Jason

Item lekérés
« Dátum: 2018. Augusztus 12. - 13:02:46 »
0
Sziasztok!
Elakadtam és a segítségeteket szeretném kérni. Csinálok egy fegyver vásárlós cuccot, amihez x mennyiségű itemre is szüksége van az adott játékosnak, azonban a lekérdezésnél mindig 0-t hoz vissza. Íme a kód:
 
 

if getElementData(localPlayer, \"char:money\") >= 8000 then
         outputChatBox(\"Pénz van\")
         if exports.item:hasItem(localPlayer, 82, 8) then--ezzel se jó
            outputChatBox(\"Vas van\")
            if exports.item:hasItem(83,8) then--és ezzel se
               outputChatBox(\"Van minden\")
            else
               outputChatBox(\"Nincs\")
            end
         else
            outputChatBox(\"Nincs vas\")
         end
      else
         outputChatBox(\"Nincs pénz\")
      end

 
 

Item lekérés
« Válasz #1 Dátum: 2018. Augusztus 12. - 15:36:07 »
0
Az \'item\' nevű resource saját? Ha igen akkor ott lesz a gond, mivel ott magadnak kell megcsinálni, hogy mikor mit adjon vissza az exportált funkció.
« Utoljára szerkesztve: 2018. Augusztus 13. - 01:15:21 írta TrickeY »

Nem elérhető Jason

Item lekérés
« Válasz #2 Dátum: 2018. Augusztus 13. - 13:52:49 »
0
Nem saját..itt van a hasItem a resource-ból:
 
 

function hasItem(itemID, itemValue)
if (not itemValue) then
   if (playerItems[\"bag\"] and playerItems[\"key\"] and playerItems[\"licens\"]) then
      for i = 1, row * column do
         if (playerItems[\"bag\"][i]) then
            if (itemID == playerItems[\"bag\"][i][\"id\"]) then
               return true, itemID, itemValue, i, \"bag\", countItemsInInventory(itemID)
            end
         end
      end
      for i = 1, row * column do
         if (playerItems[\"key\"][i]) then
            if (itemID == playerItems[\"key\"][i][\"id\"]) then
               return true, itemID, itemValue, i, \"key\"
            end
         end
      end
      for i = 1, row * column do
         if (playerItems[\"licens\"][i]) then
            if (itemID == playerItems[\"licens\"][i][\"id\"]) then
               return true, itemID, itemValue, i, \"licens\"
            end
         end   
      end
      return false
   end
   return false
else
   if (playerItems[\"bag\"] and playerItems[\"key\"] and playerItems[\"licens\"]) then
      for i = 1, row * column do
         if (playerItems[\"bag\"][i]) then
            if (itemID == playerItems[\"bag\"][i][\"id\"] and itemValue == playerItems[\"bag\"][i][\"value\"]) then
               return true, itemID, itemValue, i
            end
         end
      end
      for i = 1, row * column do
         if (playerItems[\"key\"][i]) then
            if (itemID == playerItems[\"key\"][i][\"id\"] and itemValue == playerItems[\"key\"][i][\"value\"]) then
               return true, itemID, itemValue, i
            end
         end
      end
      for i = 1, row * column do
         if (playerItems[\"licens\"][i]) then
            if (itemID == playerItems[\"licens\"][i][\"id\"] and itemValue == playerItems[\"licens\"][i][\"value\"]) then
               return true, itemID, itemValue, i
            end
         end   
      end
      return false
   end
   return false
end
return false
end

 
 

Item lekérés
« Válasz #3 Dátum: 2018. Augusztus 13. - 14:56:53 »
0
Ennél a funkciónál nincs element/player argumentum, csak itemID és itemValue. Talán az a gond, hogy az első hasItem funkcióra nem true értéket adott vissza, nem futott tovább a második If elágazásra. Talán ez segít:
 
 

if getElementData(localPlayer, \"char:money\") >= 8000 then
    outputChatBox(\"Pénz van\")
    if exports.item:hasItem(82, 8) then
        outputChatBox(\"Vas van\")
    else
        outputChatBox(\"Nincs vas\")
    end
else
    outputChatBox(\"Nincs pénz\")
end

 
 

Nem elérhető Jason

Item lekérés
« Válasz #4 Dátum: 2018. Augusztus 13. - 16:02:50 »
0
Én is próbáltam már ugyan ezzel, de így sem jó :/

Item lekérés
« Válasz #5 Dátum: 2018. Augusztus 13. - 17:45:46 »
0
Meddig jut el? Csak azt írja hogy van pénz/nincs pénz?

Nem elérhető Jason

Item lekérés
« Válasz #6 Dátum: 2018. Augusztus 13. - 17:48:55 »
0
Rájöttem :D Vagy is igazából csak arra, hogy ezzel csak azt tudom lekérdezni, hogy van-e neki ilyen item...viszont azt továbbra sem tudom, hogy hogyan tudnám azt lekérni, hogy abból az x itemből hány db van neki :/

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal