Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-01-26, 03:46


VVrongVVay







Wiek: 37
Na forum: 4486 dni
Posty: 47
Nick w MP: VVrongVVay

Piwa: 1

Respekt: 50

Ostrzeżeń: 40%
Witam, b??d polega na tym, ?e w momencie gdy pr?buj? zapisa? pojazdy lub namiotu komend? w DB3 wyskakuje taki b??d:
ERROR: [SYSTEM]/GD_DayZ/SaveSystem/VSS.lua 48: bad argument #1 to 'pairs' (table expected, got nil)

ERROR: [SYSTEM]/GD_DayZ/SaveSystem/TSS.lua:29: bad argument #1 to 'pairs' (table expected, got nil)

W czym mo?e by? problem? Na innym gamemodzie normalnie dzia?a.


function SaveTents(player)
  if isElement(playerthen
    if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      return
    end
  end
  fileDelete("SaveSystem/XTents.xml")
  xml xmlCreateFile("SaveSystem/XTents.xml","config")
  xmlSaveFile(xml)
  count 0
  for _,tentCol in pairs(getElementsByType("colshape")) do
    if getElementData(tentCol,"tent"then
      count count 1
      Tent getElementData(tentCol,"parent")
      x,y,getElementPosition(Tent)
      rx,ry,rz getElementRotation(Tent)
      TentInfos xmlCreateChild(xml,"Tent")
      xmlNodeSetAttribute(TentInfos,"ID",getElementModel(Tent))
      xmlNodeSetAttribute(TentInfos,"Scale",getObjectScale(Tent))
      xmlNodeSetAttribute(TentInfos,"Slots",getElementData(tentCol,"MAX_Slots"))
      xmlNodeSetAttribute(TentInfos,"X",x)
      xmlNodeSetAttribute(TentInfos,"Y",y)
      xmlNodeSetAttribute(TentInfos,"Z",z)
      xmlNodeSetAttribute(TentInfos,"RX",rx)
      xmlNodeSetAttribute(TentInfos,"RY",ry)
      xmlNodeSetAttribute(TentInfos,"RZ",rz)
      xmlNodeSetAttribute(TentInfos,"Visible",tostring(getElementData(tentCol,"visible") or false))
      TentItens xmlCreateChild(TentInfos,"Itens")
      for _,item in pairs(vehicleDataTable) do
        if getElementData(tentCol,item[1]) and getElementData(tentCol,item[1]) >= 1 then
          Item2 xmlCreateChild(TentItens,"Item")
          xmlNodeSetAttribute(Item2,"Item",item[1])
          xmlNodeSetAttribute(Item2,"Quant",getElementData(tentCol,item[1]))
        end
      end
    end
  end
  xmlSaveFile(xml)
  xmlUnloadFile(xml)
  if isElement(playerthen
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      outputChatBox("Ilo?? zapisanych namiot?w: ["..count.."] #000000- Ghost DayZ",player,255,0,0,true)
    end
  end
end
addEventHandler("onResourceStop",getResourceRootElement(),SaveTents)
setTimer(SaveTents,600000,0)

function LoadTents(player)
  if isElement(playerthen
    if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      return
    end
  end
  xml xmlLoadFile("SaveSystem/XTents.xml")
  for i,node in pairs(xmlNodeGetChildren(xml)) do
    ID tonumber(xmlNodeGetAttribute(node,"ID"))
    Scale tonumber(xmlNodeGetAttribute(node,"Scale"))
    Slots tonumber(xmlNodeGetAttribute(node,"Slots"))
    tonumber(xmlNodeGetAttribute(node,"X"))
    tonumber(xmlNodeGetAttribute(node,"Y"))
    tonumber(xmlNodeGetAttribute(node,"Z"))
    rx tonumber(xmlNodeGetAttribute(node,"RX"))
    ry tonumber(xmlNodeGetAttribute(node,"RY"))
    rz tonumber(xmlNodeGetAttribute(node,"RZ"))
    visible xmlNodeGetAttribute(node,"Visible")
    tent createObject(ID,x,y,z,rx,ry,rz)
    setObjectScale(tent,Scale)
    tentCol createColSphere(x,y,z,4)
    attachElements(tentCol,tent,0,0,0)
    setElementData(tentCol,"parent",tent)
    setElementData(tent,"parent",tentCol)
    setElementData(tentCol,"tent",true)
    setElementData(tentCol,"vehicle",true)
    if visible == "true" then vis true else vis false end
    setElementData(tentCol,"visible",vis)
    setElementData(tentCol,"MAX_Slots",Slots)
    for i,Item in pairs(xmlNodeGetChildren(xmlFindChild(node,"Itens",0))) do
      setElementData(tentCol,xmlNodeGetAttribute(Item,"Item"),tonumber(xmlNodeGetAttribute(Item,"Quant")))
    end
  end
  xmlUnloadFile(xml)
  if isElement(playerthen
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      outputChatBox("Wszystkie namioty zosta?y zapisane! #000000- Ghost DayZ",player,255,0,0,true)
    end
  end
end
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),LoadTents)

addCommandHandler("savetents",SaveTents)
addCommandHandler("loadtents",LoadTents)



needToSave = {
  {"MAX_Slots"},
  {"Tire_inVehicle"},
  {"Engine_inVehicle"},
  {"Parts_inVehicle"},
  {"Tire_inVehicledam"},
  {"Engine_inVehicledam"},
  {"Parts_inVehicledam"},
  {"vehicle_armor"},
  {"armorPointsMax"},
  {"fuel"},
  {"maxfuel"},
  {"needengines"},
  {"needtires"},
  {"needparts"},
}

function SaveVehicles(player)
  if isElement(playerthen
    if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      return
    end
  end
  fileDelete("SaveSystem/XVehicles.xml")
  xml xmlCreateFile("SaveSystem/XVehicles.xml","config")
  xmlSaveFile(xml)
  count 0
  for _,vehCol in pairs(getElementsByType("colshape")) do
    if getElementData(vehCol,"vehicle") and not getElementData(vehCol,"tent"then
      count count 1
      if getElementData(vehCol,"parent") and isElement(getElementData(vehCol,"parent")) then
        veh getElementData(vehCol,"parent")
        slots getElementData(vehCol,"MAX_Slots")
        health getElementHealth(veh)
        x,y,getElementPosition(veh)
        rx,ry,rz getElementRotation(veh)
        VehInfos xmlCreateChild(xml,"Veh")
        xmlNodeSetAttribute(VehInfos,"Name",getVehicleName(veh))
        xmlNodeSetAttribute(VehInfos,"ID",getElementModel(veh))
        xmlNodeSetAttribute(VehInfos,"Health",math.floor(health))
        xmlNodeSetAttribute(VehInfos,"X",x)
        xmlNodeSetAttribute(VehInfos,"Y",y)
        xmlNodeSetAttribute(VehInfos,"Z",z)
        xmlNodeSetAttribute(VehInfos,"RX",rx)
        xmlNodeSetAttribute(VehInfos,"RY",ry)
        xmlNodeSetAttribute(VehInfos,"RZ",rz)
        VehItens xmlCreateChild(VehInfos,"Itens")
        for _,item in pairs(vehicleDataTable)do
          if(tonumber(getElementData(vehCol,item[1])) and getElementData(vehCol,item[1]) >= 1then
            Item2 xmlCreateChild(VehItens,"Item")
            xmlNodeSetAttribute(Item2,"Item",item[1])
            xmlNodeSetAttribute(Item2,"Quant",getElementData(vehCol,item[1]) or 0)
          end
        end
        for _,item in pairs(needToSave)do
          Item2 xmlCreateChild(VehItens,"Item")
          xmlNodeSetAttribute(Item2,"Item",item[1])
          xmlNodeSetAttribute(Item2,"Quant",getElementData(vehCol,item[1]) or 0)
        end
      end
    end
  end
  xmlSaveFile(xml)
  xmlUnloadFile(xml)
  if isElement(playerthen
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      outputChatBox("Wszystkie pojazdy zosta?y zapisane! ["..count.."] #000000- Ghost DayZ",player,255,0,0,true)
    end
  end
end
addEventHandler("onResourceStop",getResourceRootElement(),SaveVehicles)
setTimer(SaveVehicles,600000,0)

function LoadVehicles(player)
  if isElement(playerthen
    if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      return
    end
  end
  xml xmlLoadFile("SaveSystem/XVehicles.xml")
  for i,node in pairs(xmlNodeGetChildren(xml)) do
    tonumber(xmlNodeGetAttribute(node,"X"))
    tonumber(xmlNodeGetAttribute(node,"Y"))
    tonumber(xmlNodeGetAttribute(node,"Z"))
    rx tonumber(xmlNodeGetAttribute(node,"RX"))
    ry tonumber(xmlNodeGetAttribute(node,"RY"))
    rz tonumber(xmlNodeGetAttribute(node,"RZ"))
    veh createVehicle(tonumber(xmlNodeGetAttribute(node,"ID")),x,y,z,rx,ry,rz)
    vehCol createColSphere(x,y,z,4)
    setElementData(vehCol,"spawn",{tonumber(xmlNodeGetAttribute(node,"ID")),x,y,z})
    attachElements(vehCol,veh,0,0,0)
    setElementData(vehCol,"parent",veh)
    setElementData(veh,"parent",vehCol)
    setElementData(vehCol,"vehicle",true)
    setElementHealth(veh,tonumber(math.floor(xmlNodeGetAttribute(node,"Health"))))
    for i,Item in pairs(xmlNodeGetChildren(xmlFindChild(node,"Itens",0))) do
      setElementData(vehCol,xmlNodeGetAttribute(Item,"Item"),tonumber(xmlNodeGetAttribute(Item,"Quant")))
    end
  end
  xmlUnloadFile(xml)
  if isElement(playerthen
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
      outputChatBox("Wszystkie namioty zosta?y zapisane! #000000- Ghost DayZ",player,255,0,0,true)
    end
  end
end
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),LoadVehicles)
addCommandHandler("savevehs",SaveVehicles)
addCommandHandler("loadvehs",LoadVehicles)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-26, 09:23


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Pr?bujesz wykona? p?tle, na z?ej zmiennej kt?rej nie definiujesz.
Sprawdz czy nie zrobi?e? liter?wki albo zdefiniuj te tabele jesli tego nie robisz nigdzie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-26, 14:08


VVrongVVay







Wiek: 37
Na forum: 4486 dni
Posty: 47
Nick w MP: VVrongVVay

Piwa: 1

Respekt: 50

Ostrzeżeń: 40%
"Wilq" napisał/a:

Pr?bujesz wykona? p?tle, na z?ej zmiennej kt?rej nie definiujesz.
Sprawdz czy nie zrobi?e? liter?wki albo zdefiniuj te tabele jesli tego nie robisz nigdzie.


Liter?wki nie ma, poniewa? dzia?a na innym gamemodzie. A Gdzie to mog? sprawdzi??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-26, 18:37


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

W obu przypadkach nie ma zdefiniowanej zmiennej vehicleDataTable.
By? mo?e w oryginalnym zasobie istnieje jeszcze jeden plik, kt?ry definiuje j? globalnie, przez co jest widoczna w pliku kt?rego zawarto?? skopiowa?e?.
Je?li nie, to zapomnia?e? zmieni? nazwy zmiennej przy przerabianiu kodu.

Postaw piwo autorowi tego posta
 

 
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku