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

Wysłany: 2016-04-07, 18:21


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

Witam, chc? ?eby nikt nie m?g? rozwali? auta kiedy nie ma kierowcy w nim i ?eby nie da?o si? wchodzi? na "G" bez kierowcy.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 19:02


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3


Więcej informacji znajdziesz w Wikipedii MTA:

setVehicleDamageProof



Więcej informacji znajdziesz w Wikipedii MTA:

onVehicleStartEnter


Więcej informacji znajdziesz w Wikipedii MTA:

cancelEvent


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 19:47


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

"AteX" napisał/a:


Więcej informacji znajdziesz w Wikipedii MTA:

setVehicleDamageProof



Więcej informacji znajdziesz w Wikipedii MTA:

onVehicleStartEnter


Więcej informacji znajdziesz w Wikipedii MTA:

cancelEvent

Jaki? przyk?adzik? :x

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 20:02


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

Na wiki s? bardzo dobre przyk?ady wraz z wyja?nieniem dzia?ania funkcji. Wystarczy chcie? poczyta?. :x

Spr?buj napisa? kod i jak co? nie b?dzie dzia?a? to pomo?emy.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 20:35


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

"AteX" napisał/a:

Na wiki s? bardzo dobre przyk?ady wraz z wyja?nieniem dzia?ania funkcji. Wystarczy chcie? poczyta?. :x

Spr?buj napisa? kod i jak co? nie b?dzie dzia?a? to pomo?emy.

Na nie niszczenie si? aut.
local function bezkierowcy(veh)
    local occupants getVehicleOccupants(veh)
    local seats getVehicleMaxPassengers(veh)
    if (not seatsthen return true end
    for i=0,seats do
    local occupant occupants[seat]
    if occupant and (getElementType(occupant)=="player" or getElementType(occupant)=="ped"then
        return false
    end
    end
    return true
end


for i,v in ipairs(getElementsByType("vehicle")) do
    if (bezkierowcy(v)) then
        setVehicleDamageProof(v,true)
    else
    if getElementData(v,"damageproof"then setVehicleDamageProof(vtrue) return end
    setVehicleDamageProof(v,false)
    end
end

addEventHandler "onVehicleEnter"root, function()
    if getElementData(source,"damageproof"then setVehicleDamageProof(sourcetrue) return end
    setVehicleDamageProof(sourcefalse)
end)

addEventHandler "onVehicleExit"root, function()
    if (bezkierowcy(source)) then
        setVehicleDamageProof(sourcetrue)
    else
        if getElementData(source,"damageproof"then setVehicleDamageProof(sourcetrue) return end
        setVehicleDamageProof(sourcefalse)
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 21:00


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
I co teraz ? , dzia?a ?

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 21:23


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

"_Wicek_" napisał/a:

I co teraz ? , dzia?a ?

Nie dzia?a.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:04


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8


    local vehTimers = { };
    setTimer(
        function ( )
            for _vehicle in ipairs getElementsByType "vehicle" ) ) do
                if getElementHealth(vehicle) < 260 then
                    setElementHealthvehicle250 ); -- set vehicle health to "fire" health which is ~250
                    if not vehTimersvehicle then -- if we haven't set the timer 1 second earlier then:
                        setVehicleDamageProof( vehicle, true) -- it only need to be called once so set the bulletproof property
                        vehTimers[ vehicle ] = setTimer( setVehicleDamageProof, 120000, 1, vehicle, false); -- 5mins = 5 * 60sec = 300sec = 300000ms! It's NOT 500000ms
                    end
                elseif vehTimersvehicle ] and isTimervehTimersvehicle ] ) then -- if we set a timer earlier but the vehicle was repaired within the 5mins then:
                    setVehicleDamageProofvehiclefalse) -- disable bulletproof property
                    killTimervehTimersvehicle ] ); -- kill the timer
                    vehTimersvehicle ] = nil; -- remove the variable from the memory since we killed the timer and it's no longer timer variable
                end
            end
        end,1000, 0
    )


meta:
Kod:

<meta>
<script src="nazwa.lua" type="server"/>
</meta>


Musi dzia?a?, mi dzia?a;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:33


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

"noose" napisał/a:


    local vehTimers = { };
    setTimer(
        function ( )
            for _vehicle in ipairs getElementsByType "vehicle" ) ) do
                if getElementHealth(vehicle) < 260 then
                    setElementHealthvehicle250 ); -- set vehicle health to "fire" health which is ~250
                    if not vehTimersvehicle then -- if we haven't set the timer 1 second earlier then:
                        setVehicleDamageProof( vehicle, true) -- it only need to be called once so set the bulletproof property
                        vehTimers[ vehicle ] = setTimer( setVehicleDamageProof, 120000, 1, vehicle, false); -- 5mins = 5 * 60sec = 300sec = 300000ms! It's NOT 500000ms
                    end
                elseif vehTimersvehicle ] and isTimervehTimersvehicle ] ) then -- if we set a timer earlier but the vehicle was repaired within the 5mins then:
                    setVehicleDamageProofvehiclefalse) -- disable bulletproof property
                    killTimervehTimersvehicle ] ); -- kill the timer
                    vehTimersvehicle ] = nil; -- remove the variable from the memory since we killed the timer and it's no longer timer variable
                end
            end
        end,1000, 0
    )


meta:
Kod:

<meta>
<script src="nazwa.lua" type="server"/>
</meta>


Musi dzia?a?, mi dzia?a;)

Nie dziala ;/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:36


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
Patrix100, No to zapraszamy na wiki , gotowca nie dostaniesz...
Czasami musisz zacz?? u?ywa? wiki a nie liczy? ?e kto? da Ci gotowy kod.

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:43


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

"Patrix100" napisał/a:

Nie dziala ;/

To jest kod kt?ry znalaz?em spory kawa?ek czasu temu na oficjalnym forum mta,napis?? go moderator. :)
Stw?rz plik nazwa.lua, i wklej do niego kod kt?ry Ci wys?a?em, potem stw?rz met? i wklej:
Kod:

<meta>
<script src="nazwa.lua" type="server"/>
</meta>


Musi dzia?a?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:45


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

"_Wicek_" napisał/a:

Patrix100, No to zapraszamy na wiki , gotowca nie dostaniesz...
Czasami musisz zacz?? u?ywa? wiki a nie liczy? ?e kto? da Ci gotowy kod.

Poda?em kod kt?ry nie dzia?a w celu uzyskania pomocy a ty mi piszesz ?e gotowca biore... Noose wys?a? kod - okej sprawdzi?em czy dzia?a jednak ma jaki? b?ad to napisa?em mu ?e nie dzia?a.

[ Dodano: 2016-04-07, 22:49 ]
"noose" napisał/a:

"Patrix100" napisał/a:

Nie dziala ;/

To jest kod kt?ry znalaz?em spory kawa?ek czasu temu na oficjalnym forum mta,napis?? go moderator. :)
Stw?rz plik nazwa.lua, i wklej do niego kod kt?ry Ci wys?a?em, potem stw?rz met? i wklej:
Kod:

<meta>
<script src="nazwa.lua" type="server"/>
</meta>


Musi dzia?a?.

Zrobilem tak jak piszesz i nic.
Jak chcesz zobaczy? to szybko wbijaj na srv:
--

Ostatnio zmieniony przez Patrix100 2016-04-07, 22:57, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:52


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

Nie mam aktualnie czasu, aby wbi? ale wy?lij tre?? tego b??du, postaram si? pom?c:)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 22:58


Patrix100

Amator LUA.






Wiek: 26
Na forum: 3887 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 952

Respekt: 40,5

"noose" napisał/a:

Nie mam aktualnie czasu, aby wbi? ale wy?lij tre?? tego b??du, postaram si? pom?c:)

W db3 nie ma ?adnego.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-07, 23:04


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

"Patrix100" napisał/a:

ednak ma jaki? b?ad

W takim razie co? musisz robi? ?le.
Wy?lij mi logi z konsoli, od momentu startu serwera, pierwsze kilkana?cie linijek, sprawdz? czy skrypt si? za?adowa?

Postaw piwo autorowi tego posta
 

 
Tagi: nie :: rozwalanie :: sie :: aut :: wchodzenie :: quotgquot
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA 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