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

Wysłany: 2018-10-17, 20:32


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Siema jak doda? tutaj inny pojazd ni? holownik

addEventHandler("onMarkerHit",oddanie,function(el,md)
if getElementType(el) ~= "player" then return end
local veh getPedOccupiedVehicle(el)
if not veh then return end
if veh and getElementModel(veh) ~= 525 or getElementModel(veh) ~= 578 then return end
local duty getElementData(el,"player:faction")
if not duty or (duty and duty ~= "SARA"then return end
local tow getVehicleTowedByVehicle(veh)
if not tow then return end
triggerClientEvent(el,"glownyparking:refresh",root,tow)
end)
addEventHandler("onMarkerLeave",oddanie,function(el,md)
if getElementType(el) ~= "player" then return end
local veh getPedOccupiedVehicle(el)
if not veh then return end
if veh and getElementModel(veh) ~= 525 or getElementModel(veh) ~= 578 then return end
local duty getElementData(el,"player:faction")
if not duty or (duty and duty ~= "SARA"then return end
local tow getVehicleTowedByVehicle(veh)
if not tow then return end
triggerClientEvent(el,"glownyparking:chowaj",root)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:38


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

AkossPL, Robisz ifa sprawdzaj?cego, czy id pojazdu jest r?wne 576(laweta), p??niej sprawdzasz, czy s? przyczepione do lawety, czyli getAttachedElements(jak chcesz lawet?, jak nie to do czego? tam innego), je?li tak to sprawdzasz ile ich jest, je?eli jest 1 to kod puszczasz dalej.
Robisz p?tl?(najlepiej), np.

    for i,v in ipairs(pojazdy) do
        if getElementType(zmiennaPojazdu) == "vehicle" then
            --TODO
        end
    end

I w tym ifie, kt?ry Ci poda?em na g?rze(W miejscu --TODO) wpisujesz, co ma si? dzia? dalej.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:41


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kuks*,
if getAttachedElements (578)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:42


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

AkossPL, Robisz if getElementModel(zmiennaPojazdu) == 578 then.

A w getAttachedElements argumentem nie jest INT, tylko element.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:42


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kuks*, if getElementModel(veh) == 578 then

[ Dodano: 2018-10-17, 20:44 ]
Kuks*,
if getElementModel(veh) == 578 then
  for i,v in ipairs(pojazdy) do
        if getElementType(zmiennaPojazdu) == "vehicle" then
            --TODO
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:45


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

AkossPL, W TODO dodajesz, co ma si? dzia?, je?eli warunek jest spe?niony.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:50


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kuks*, tak to ma by?
if getElementModel(veh) == 578 then
  for i,v in ipairs(578) do
        if getElementType(veh) == "vehicle" then
        getElementModel(veh) ~= 578 then
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:52


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

A 578 to nie jest przypadkiem liczba ca?kowita?
2 linijka

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:54


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kuks*,
if veh and getElementModel(veh) ~= 525 or getElementModel(veh) ~= 578 then return end
if getElementModel(veh) == 578 then
  for i,v in ipairs(578) do
        if getElementType(veh) == "vehicle" then
        getElementModel(veh) ~= "vehicle" then
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:55


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

AkossPL, W 3 linijce powinna by? nazwa tabeli, w kt?rej zawarte s? elementy przymocowane do pojazdu, a nie INT
A po 2. po co ci getElementModel() w miejscu --TODO, skoro to ju? sprawzi?e??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 20:57


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kuks*,
if veh and getElementModel(veh) ~= 525 or getElementModel(veh) ~= 578 then return end
if getElementModel(veh) == 578 then
  for i,v in ipairs(578) do
        if getElementType(veh) == "578" then
        getElementModel(veh) ~= "vehicle" then
        end
    end
end


[ Dodano: 2018-10-17, 21:02 ]
Kuks*,
if getElementModel(veh) == 578 then
  for i,v in ipairs(veh) do
        if getElementType(veh) == "578" then
        getElementModel(veh) ~= "vehicle" then
        end
    end
end


Dobrze

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 21:02


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

AkossPL
1. 578 to nie jesty typ elementu, tylko liczba ca?kowita,
2. "578" nast?pnym razem zapisuj jako int, nie jako string
3. Nie sprawdzaj, czy pojazd, w kt?rym siedzisz jest pojazdem, bo na 100 % warunek zostanie spe?niony
4. Sprawdzaj?c typ elementu sprawdzaj v, a nie veh(bo to jest pojazd, w kt?rym si? znadujesz)
5. getElementModel(veh) ~= "vehicle" then Tutaj to ju? dostaniesz error, wyrzu? t? linijk?
6. Pomiesza?e? model z typem, powinno by? odwrotnie
7. for i,v in ipairs(578) do 578 to nie jest table tylko INT(l. ca?kowita)

Linki:
Poprawne u?ywanie funkcji:
https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions

Poprawne stosowanie instrukcji warunkowej, p?tli, wyja?nienie czym jest tabela, czym string si? r??ni od int:
http://lua.org.pl/

Liczba ca?kowita:
https://pl.wikipedia.org/wiki/Liczby_ca%C5%82kowite

My?l?, ?e pomog?em, licz? na :piwo: :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 21:16


AkossPL







Wiek: 25
Na forum: 4079 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kuks*, Dobrze

if veh and getElementModel(veh) ~= 525 or getElementModel(veh) ~= 578 then return end
if getElementModel(veh) == 578 then
  for i,v in ipairs(tabelka) do
        if getElementType(v) == "vehicle" then
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-17, 21:17


Kuks*







Wiek: 15
Na forum: 3030 dni
Posty: 246
Nick w MP: Kuks*

Piwa: 2208

Respekt: 115,8
Respekt: 115,8

AkossPL, Tak

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: dodać :: tutaj :: pojazd :: inny :: niż :: holownik
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