Szerző Téma: Chat System hiba  (Megtekintve 668 alkalommal)

Chat System hiba
« Dátum: 2015. Április 07. - 19:13:10 »
0 Show voters
Sziasztok!
Olyan problémám lenne, hogy amikor beírom, hogy /tuneradio akkor ezt a hiba üzenetet kapom:
[19:01:14] ERROR: chat-system\\pmS.lua:722: attempt to compare number with string
És erre a sorra írja a hibát: if v[2] > 0 then
 
function setRadioChannel(thePlayer, commandName, slot, channel)
slot = tonumber( slot )
channel = tonumber( channel )
if not channel then
channel = slot
slot = 1
end
if not (channel) then
outputChatBox(\"Használat:#e7d9b0 /\" .. commandName .. \" [frekvencia]\", thePlayer, 0, 206, 209,true)
else
if (exports.global:hasItem(thePlayer, 6)) then
   local count = 0
   local items = exports[\'itemsystem\']:getItems(thePlayer)
   for k, v in ipairs( items ) do
      if v[1] == 6 then
         count = count + 1
         if count == slot then
            if v[2] > 0 then
               if channel > 0 and channel < 1000000000 then
                  if exports[\'itemsystem\']:updateItemValue(thePlayer, k, channel) then
                     outputChatBox(\"Beállítottad a rádiódat a #\" .. channel .. \" frekvenciára.\", thePlayer)
                     exports.global:sendLocalMeAction(thePlayer, \"átálítja a rádiója frekvenciáját.\")
                  end
               else
                  outputChatBox(\"Tiltott frekvencia.\", thePlayer, 255, 0, 0)
               end
            else
               outputChatBox(\"A Rádiód ki van kapcsolva. ((/toggleradio))\", thePlayer, 255, 0, 0)
            end
            return
         end
      end
   end
   outputChatBox(\"Érvényltelen rádió ID! Nincs ennyi rádiód.\", thePlayer, 255, 0, 0)
else
   outputChatBox(\"Nincs rádiód!\", thePlayer, 255, 0, 0)
end
end
end
addCommandHandler(\"tuneradio\", setRadioChannel, false, false)

 
Segítségeteket előre is köszönöm!

Nem elérhető Feher

  • 123
    • Profil megtekintése
Chat System hiba
« Válasz #1 Dátum: 2015. Április 08. - 00:31:25 »
0 Show voters
Hali,
A stringet számmal nem lehet összehasonlítani, az item táblád 2. tagja szöveges ha azt akarod a feltételnek, hogy nem üres-e a v[2] akkor, csináld így if v[2] ~= nil then.

Nem elérhető Enigma

  • 391
    • Profil megtekintése
Chat System hiba
« Válasz #2 Dátum: 2015. Április 08. - 00:45:22 »
0 Show voters
ezis elég.
 
if v[2] then

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal