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

Wysłany: 2014-10-18, 20:13


GumiS0000







Wiek: 30
Na forum: 4696 dni
Posty: 98
Nick w MP: After

Piwa: 227

Respekt: 40

Ostrzeżeń: 20%
Cze?? mam pytanie jak zrobi? aby auto jedno si? zapisywa?o a nie wszystkie np.Gracz siedzi w pojezdzie i wpisze komende /zapisz to tylko te auto si? zapisuje a nie wszystkie.

addCommandHandler ( "zapisz", function ( plr )
    local accName = getAccountName ( getPlayerAccount ( plr ) )
    if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "Urzad" ) ) then
        return outputChatBox ( "Nie jeste? Graczem", plr, 255, 0, 0 ) end
    xml = xmlLoadFile ( "auta.xml" )
    for _,v in ipairs ( xmlNodeGetChildren ( xml ) ) do
        xmlDestroyNode ( v )
    end
    xmlSaveFile ( xml )
    for _,v in ipairs ( getElementsByType ( "vehicle" ) ) do
        model = getElementModel ( v, thePlayer )
        x,y,z = getElementPosition ( v )
        c1,c2,c3,c4,c5,c6 = getVehicleColor ( v )
        r1,r2,r3 = getVehicleRotation ( v )
        child = xmlCreateChild ( xml, "pojazd" )
        id = tonumber ( getElementData ( v, "id" ) )
        owner = getElementData ( v, "owner" )
            if not tonumber ( getElementData ( v, "id" ) ) then
                id = tonumber ( math.random ( 1, 1000 ) ) end
            if not owner then
            owner = "Publiczne" end
        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, "color5", tonumber(c5) )
        xmlNodeSetAttribute ( child, "color6", tonumber(c6) )
        xmlNodeSetAttribute ( child, "rotation1", tonumber(r1) )
        xmlNodeSetAttribute ( child, "rotation2", tonumber(r2) )
        xmlNodeSetAttribute ( child, "rotation3", tonumber(r3) )
        xmlNodeSetAttribute ( child, "owner", owner )
        xmlNodeSetAttribute ( child, "id", tonumber(id) )
    end
    xmlSaveFile ( xml )
    if xml then
        outputChatBox ( "Pojazd zosta? Zapisany", plr,255,255,255 )
        xmlUnloadFile ( xml )
    end
end)



addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), function ()
    xml = xmlLoadFile ( "auta.xml" )
    for _,v in ipairs ( xmlNodeGetChildren ( xml ) ) do
        model = tonumber ( xmlNodeGetAttribute ( v, "model" ) )
        id = tonumber ( xmlNodeGetAttribute ( v, "id" ) )
        owner = xmlNodeGetAttribute ( v, "owner" )
        x,y,z = tonumber ( xmlNodeGetAttribute ( v, "x" ) ), tonumber ( xmlNodeGetAttribute ( v, "y" ) ), tonumber ( xmlNodeGetAttribute ( v, "z" ) )
        c1, c2, c3 = tonumber ( xmlNodeGetAttribute ( v, "color1" ) ), tonumber ( xmlNodeGetAttribute ( v, "color2" ) ), tonumber ( xmlNodeGetAttribute ( v, "color3" ) )
        c4, c5, c6 = tonumber ( xmlNodeGetAttribute ( v, "color4" ) ), tonumber ( xmlNodeGetAttribute ( v, "color5" ) ), tonumber ( xmlNodeGetAttribute ( v, "color6" ) )
        r1, r2, r3 = tonumber ( xmlNodeGetAttribute ( v, "rotation1" ) ), tonumber ( xmlNodeGetAttribute ( v, "rotation2" ) ), tonumber ( xmlNodeGetAttribute ( v, "rotation3" ) )
        auto = createVehicle ( model, x,y,z, r1, r2, r3 ) 
        setVehicleColor ( auto, c1, c2, c3, c4, c5, c6 )
        setElementData ( auto, "message",owner )
        setElementData ( auto, "owner", owner )
        setElementData ( auto, "id", id )
    end
end)


addEventHandler ( "onVehicleStartEnter", root, function ( gracz, miejsce, kierowca )
    if kierowca then
        name = getPlayerName ( kierowca )
        return outputChatBox ( "*"..name.." ju? prowadzi ten pojazd!", gracz, 255, 255, 255 ) end
        if miejsce ~= 0 then return end
        if getElementData ( source, "owner" ) == "Publiczne" then 
        return outputChatBox ( "Pami?taj, ?e prowadzenie publicznego pojazdu jest nielegalne!", plr, 255, 255, 255 ) end
        if getElementData ( source, "owner" ) ~= getPlayerName ( gracz ) then
        outputChatBox ( "* Ten pojazd nale?y do "..getElementData ( source, "owner" ).."!", gracz, 255, 255, 255 ) 
            return cancelEvent() end
end)


Mogliby?cie zmieni? kod?

Bo ja bardzo nie umiem jestem nowy wlua

Podpis
Jeśli pomogłem liczę na :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-10-19, 14:11


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Nie pozwoli?em na modyfikacj? kodu.

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-10-19, 14:14


Artysta

Lua, Lua, Czekolada






Wiek: 28
Na forum: 4607 dni
Posty: 240
Nick w MP: Artysta/Koojot

Piwa: 1427

Respekt: 205,8
Respekt: 205,8Respekt: 205,8

Zamiast p?tli zdefiniuj pojazd, w ktorym siedzi gracz wpisuj?cy cmd.

Podpis
Something is coming..
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-10-19, 17:44


Dixers

No-Life






Wiek: 26
Na forum: 4454 dni
Posty: 549
Nick w MP: Dixers

Piwa: 412

Respekt: 56,8

"Shuffle" napisał/a:

Nie pozwoli?em na modyfikacj? kodu.


Gumis, prawda. Powiniene? spyta?.

Postaw piwo autorowi tego posta
 

 
Tagi: zapis :: przez :: jedna :: osobe
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 przez jedna osobe 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