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

Wysłany: 2015-01-30, 13:13


piotr172







Wiek: 26
Na forum: 4417 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

Witam. Mam ma?y problem, poniewa? mam kod na zapis aut, ale ja chcia?bym aby zapisywa?o tylko pojazdy z wyznaczon? Data. Kod zapisuje wszytskie auta z mapy, a ja chcia?bym ?eby zapisywa? auto o Dacie np "pojazd". Co trzeba zrobic ?eby to dzia?a?o tak jak chce. Z g?ry dzi?kuje za pomoc.

kod:

addCommandHandler "zapisz", function ( plr )
    local accName getAccountName getPlayerAccount plr ) )
    if not isObjectInACLGroup ("user."..accNameaclGetGroup "Admin" ) ) then
        return outputChatBox "Nie posiadasz praw Administratora"plr2550end
    xml xmlLoadFile "pojazdy.xml" )
    for _,v in ipairs xmlNodeGetChildren xml ) ) do
        xmlDestroyNode )
    end
    xmlSaveFile xml )
for _,v in ipairs getElementsByType "vehicle" ) ) do
            local model getElementModel(v)
            local zycie getElementHealth(v)
            local x,y,getElementPosition(v)
            local r1,r2,r3 getElementRotation(v)
            local c1,c2,c3,c4 getVehicleColor(v)
            local opis getElementData(v"pojazd_opis")
            local owner getElementData(v"pojazd_owner")
            child xmlCreateChild xml"pojazdy" )
            if not tonumber getElementData v"pojazd_id" ) ) then
            pojazd_id tonumber math.random 11000 ) ) end
        xmlNodeSetAttribute(child"pojazd_id"tonumber(pojazd_id))
        xmlNodeSetAttribute child"model"tonumber(model) )
        xmlNodeSetAttribute child"x"tonumber(x) )
        xmlNodeSetAttribute child"y"tonumber(y) )
        xmlNodeSetAttribute child"z"tonumber(z) )
        xmlNodeSetAttribute child"color1"tonumber(c1) )
        xmlNodeSetAttribute child"color2"tonumber(c2) )
        xmlNodeSetAttribute child"color3"tonumber(c3) )
        xmlNodeSetAttribute child"color4"tonumber(c4) )
        xmlNodeSetAttribute child"rotation1"tonumber(r1) )
        xmlNodeSetAttribute child"rotation2"tonumber(r2) )
        xmlNodeSetAttribute child"rotation3"tonumber(r3) )
        xmlNodeSetAttribute child"pojazd_owner"tonumber(owner) )
        xmlNodeSetAttribute(child"pojazd_opis"tonumber(opis) )
        xmlNodeSetAttribute(child"zycie"tonumber(zycie) )
    end
    xmlSaveFile xml )
    if xml then
        outputChatBox "Pojazdy zapisane"plr )
        xmlUnloadFile xml )
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-30, 13:30


TheTroll

Pan Majster






Wiek: 38
Na forum: 4764 dni
Posty: 219
Nick w MP: TheTroll

Piwa: 1114

Respekt: 120
Respekt: 120

Pami?taj aby nada? pojazdowi setElementData(pojazd,"Pojazd_zapis",true)

addCommandHandler "zapisz", function ( plr )
    local accName getAccountName getPlayerAccount plr ) )
    if not isObjectInACLGroup ("user."..accNameaclGetGroup "Admin" ) ) then
        return outputChatBox "Nie posiadasz praw Administratora"plr2550end
    xml xmlLoadFile "pojazdy.xml" )
    for _,v in ipairs xmlNodeGetChildren xml ) ) do
        xmlDestroyNode )
    end
    xmlSaveFile xml )
for _,v in ipairs getElementsByType "vehicle" ) ) do
    if getElementData(v,"Pojazd_zapis") == true then
        local model getElementModel(v)
        local zycie getElementHealth(v)
        local x,y,getElementPosition(v)
        local r1,r2,r3 getElementRotation(v)
        local c1,c2,c3,c4 getVehicleColor(v)
        local opis getElementData(v"pojazd_opis")
        local owner getElementData(v"pojazd_owner")
        child xmlCreateChild xml"pojazdy" )
        if not tonumber getElementData v"pojazd_id" ) ) then
        pojazd_id tonumber math.random 11000 ) ) end
        xmlNodeSetAttribute(child"pojazd_id"tonumber(pojazd_id))
        xmlNodeSetAttribute child"model"tonumber(model) )
        xmlNodeSetAttribute child"x"tonumber(x) )
        xmlNodeSetAttribute child"y"tonumber(y) )
        xmlNodeSetAttribute child"z"tonumber(z) )
        xmlNodeSetAttribute child"color1"tonumber(c1) )
        xmlNodeSetAttribute child"color2"tonumber(c2) )
        xmlNodeSetAttribute child"color3"tonumber(c3) )
        xmlNodeSetAttribute child"color4"tonumber(c4) )
        xmlNodeSetAttribute child"rotation1"tonumber(r1) )
        xmlNodeSetAttribute child"rotation2"tonumber(r2) )
        xmlNodeSetAttribute child"rotation3"tonumber(r3) )
        xmlNodeSetAttribute child"pojazd_owner"tonumber(owner) )
        xmlNodeSetAttribute(child"pojazd_opis"tonumber(opis) )
        xmlNodeSetAttribute(child"zycie"tonumber(zycie) )
        end
    end
    xmlSaveFile xml )
    if xml then
        outputChatBox "Pojazdy zapisane"plr )
        xmlUnloadFile xml )
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-30, 19:30


piotr172







Wiek: 26
Na forum: 4417 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

Dzi?ki, dzia?a, leci piwko.

Postaw piwo autorowi tego posta
 

 
Tagi: zapis :: pojazdów.
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zapis pojazdów. Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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