marcin778, ten b??d si? naprawi? ale teraz wyskoczy? mi tutaj jak wpisa?em komende aby zapisa?.
function automat(gracz)
if gracz and isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(gracz)), aclGetGroup("Admin")) then
outputChatBox("Saving of tents was initiated!",gracz,0,255,0,true)
else
return
end
namiot = xmlCreateFile("tents.xml","root")
id = 0
ilosc = 0
for i, col in ipairs(getElementsByType("colshape")) do
if col then
local tent = getElementData(col, "tent")
if tent then
local namiotek = getElementData(col, "parent")
local x, y, z = getElementPosition(namiotek)
local rx, ry, rz = getElementRotation(namiotek)
local namiote = xmlCreateChild (namiot,"Namiot")
local namiot = xmlCreateChild (namiote,"wsp")
local namioti = xmlCreateChild (namiote,"itemy")
xmlNodeSetValue (xmlCreateChild ( namiot, "PX"), tostring(x) )
xmlNodeSetValue (xmlCreateChild ( namiot, "PY"), tostring(y) )
xmlNodeSetValue (xmlCreateChild ( namiot, "PZ"), tostring(z) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RX"), tostring(rx) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RY"), tostring(ry) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RZ"), tostring(rz) )
id = 0
for i, v in ipairs(tabelazapisu) do
local item = getElementData(col, v[1])
if item then
if item >= 1 then
itemID = PobierzIDItemu(v[1])
xmlNodeSetValue (xmlCreateChild ( namioti, tostring(itemID)), tostring(item) )
end
end
end
end
end
end
xmlSaveFile(namiot)
xmlUnloadFile(namiot)
if gracz then
outputChatBox("Tents saved!",gracz,0,255,0,true)
end
end
addCommandHandler("tent-save",automat)
W ERROR wystakuje co? takiego :
tentsave.lua:27: bad argument #1 to 'ipairs' (table expected, go nil)
marcin778, a m?g? by? mi to zrobi? czy naprawd? ci si? nie chce bo potrzebuje skryptu na zapis namiot?w jak i pojazd? na dayz a nie ogarniam tego naprawd? wi?c prosz? ci o pomoc
local tabelazapisu = {
{"jakas elementdata na item"},
{"jakas elementdata na item"},
{"jakas elementdata na item"}
}
function automat(gracz)
if gracz and isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(gracz)), aclGetGroup("Admin")) then
outputChatBox("Saving of tents was initiated!",gracz,0,255,0,true)
else
return
end
namiot = xmlCreateFile("tents.xml","root")
id = 0
ilosc = 0
for i, col in ipairs(getElementsByType("colshape")) do
if col then
local tent = getElementData(col, "tent")
if tent then
local namiotek = getElementData(col, "parent")
local x, y, z = getElementPosition(namiotek)
local rx, ry, rz = getElementRotation(namiotek)
local namiote = xmlCreateChild (namiot,"Namiot")
local namiot = xmlCreateChild (namiote,"wsp")
local namioti = xmlCreateChild (namiote,"itemy")
xmlNodeSetValue (xmlCreateChild ( namiot, "PX"), tostring(x) )
xmlNodeSetValue (xmlCreateChild ( namiot, "PY"), tostring(y) )
xmlNodeSetValue (xmlCreateChild ( namiot, "PZ"), tostring(z) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RX"), tostring(rx) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RY"), tostring(ry) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RZ"), tostring(rz) )
id = 0
for i, v in ipairs(tabelazapisu) do
local item = getElementData(col, v[1])
if item then
if item >= 1 then
itemID = PobierzIDItemu(v[1])
xmlNodeSetValue (xmlCreateChild ( namioti, tostring(itemID)), tostring(item) )
end
end
end
end
end
end
xmlSaveFile(namiot)
xmlUnloadFile(namiot)
if gracz then
outputChatBox("Tents saved!",gracz,0,255,0,true)
end
end
addCommandHandler("tent-save",automat)
Ale po uzupe?nieniu na sprawdzenie 2 przedmiot?w co? nie pyka.
local tabelazapisu = {
{"Painkiller"},
{"M4"},
}
function automat(gracz)
if gracz and isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(gracz)), aclGetGroup("Admin")) then
outputChatBox("Saving of tents was initiated!",gracz,0,255,0,true)
else
return
end
namiot = xmlCreateFile("tents.xml","root")
id = 0
ilosc = 0
for i, col in ipairs(getElementsByType("colshape")) do
if col then
local tent = getElementData(col, "tent")
if tent then
local namiotek = getElementData(col, "parent")
local x, y, z = getElementPosition(namiotek)
local rx, ry, rz = getElementRotation(namiotek)
local namiote = xmlCreateChild (namiot,"Namiot")
local namiot = xmlCreateChild (namiote,"wsp")
local namioti = xmlCreateChild (namiote,"itemy")
xmlNodeSetValue (xmlCreateChild ( namiot, "PX"), tostring(x) )
xmlNodeSetValue (xmlCreateChild ( namiot, "PY"), tostring(y) )
xmlNodeSetValue (xmlCreateChild ( namiot, "PZ"), tostring(z) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RX"), tostring(rx) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RY"), tostring(ry) )
xmlNodeSetValue (xmlCreateChild ( namiot, "RZ"), tostring(rz) )
id = 0
for i, v in ipairs(tabelazapisu) do
local item = getElementData(col, v[1])
if item then
if item >= 1 then
itemID = PobierzIDItemu(v[1])
xmlNodeSetValue (xmlCreateChild ( namioti, tostring(itemID)), tostring(item) )
end
end
end
end
end
end
xmlSaveFile(namiot)
xmlUnloadFile(namiot)
if gracz then
outputChatBox("Tents saved!",gracz,0,255,0,true)
end
end
addCommandHandler("tent-save",automat)
Tak to wygl?da a ERROR jaki wyskakuje masz tutaj :
tentsave.lua:37: attempt to call gloval 'PobierzIDItemu' (a nil value)
A gdy ju? robie ?e zamiast nazwy przedmiotu jest jego ID to nic nie wyskakuje w debugscript3 ale po wczytaniu ponownie namiot?w nie ma w nim przedmiot?w.
marcin778, To jak ja mam to zrobi? aby si? all zapisywa?o w tym .xml bo m?j kolega programista nie wie i te? si? go pyta?em a powiedzia?a ?e nie ma poj?cia.. Prosze o pomoc bo nie radze sobie ..
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