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

Wysłany: 2015-07-25, 11:13


Tostuch







Wiek: 27
Na forum: 4931 dni
Posty: 483
Nick w MP: Tost

Piwa: 137

Respekt: 110
Respekt: 110

Cze??. Zrobi?em system pojazd?w oraz komend? do teleportowania do pojazdu o podanym UID. Problem w tym ?e ci?gle wy?wietla wiadomo??: "* Nie odnaleziono takiego pojazdu!". Nie mam poj?cia co jest ?le. W debugu nie ma ?adnego b??du.

addCommandHandler("ttv", function(plrcomid)
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("Admin")) then
        if id then
        local veh getVehiclesByUID(id)
            if veh then
            local x,y,getElementPosition(veh)
            setElementPosition(plrxyz+1)
            outputChatBox("* Teleportowa?e? si? do pojazdu o UID: "..getElementData(veh"uid").."."plr)
            else
            outputChatBox("* Nie odnaleziono takiego pojazdu!"plr)
            end
        else
        outputChatBox("* Musisz poda? ID pojazdu!"plr)
        end
    end
end)


getVehiclesByUID:
function getVehiclesByUID(id)
    if id then
        for k,v in ipairs(getElementsByType("vehicle")) do
            if getElementData(v"uid") == id then
            local veh v
            else
            local veh false
            end
        end
        return veh
    end
end



//EDIT:

UID jest nadane poprawnie, poniewa? komenda /getid kt?ra je sprawdza, zwraca poprawn? warto??.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-25, 11:29


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Rozumiem, ?e funkcje getVehicleByID masz w innym pliku, ta?
Spr?buj te funkcj? getVehicleByID da? do tego kodu w kt?rym masz /ttv

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-25, 11:45


Tostuch







Wiek: 27
Na forum: 4931 dni
Posty: 483
Nick w MP: Tost

Piwa: 137

Respekt: 110
Respekt: 110

Nie ona jest dok?adnie w tym samym pliku :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-25, 12:47


Wittx

8===D






Wiek: 26
Na forum: 4794 dni
Posty: 121
Nick w MP: wittula

Piwa: 1905

Respekt: 120
Respekt: 120

function getVehiclesByUID(id)
    if id then
        for k,v in ipairs(getElementsByType("vehicle")) do
            if getElementData(v"uid") == id then
            local veh v
            else
            local veh false
            end
        end
        return veh
    end
end


zmienna veh jest lokalna i istnieje tylko w warunku kt?ry jest w p?tli for, poza tym warunkiem nie istnieje. To powinno rozwi?za? Twoj problem:

function getVehiclesByUID(id)
    assert(id'id wymagane')
    for _,v in ipairs(getElementsByType("vehicle")) do
        if getElementData(v"uid") == id then
            return v;
        end
    end
        return false
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-25, 13:22


Tostuch







Wiek: 27
Na forum: 4931 dni
Posty: 483
Nick w MP: Tost

Piwa: 137

Respekt: 110
Respekt: 110

Niestety, nadal to nie rozwi?za?o problemu. Wci?? wy?wietla ten sam komunikat.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-25, 13:49


DaxRel69







Wiek: 30
Na forum: 4107 dni
Posty: 171
Nick w MP: DaxRel

Piwa: 4368

Respekt: 71,5

Ostrzeżeń: 60%
Zmie? to if getElementData(v, "uid") == id then na to if getElementData(v, "id") == id then

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-25, 13:53


Tostuch







Wiek: 27
Na forum: 4931 dni
Posty: 483
Nick w MP: Tost

Piwa: 137

Respekt: 110
Respekt: 110

Znalaz?em problem, argument ID w komendzie jest jako string, nie numer, dlatego nie zwraca?o nic, poniewa? UID to numer. Do zamkni?cia.

//EDIT:

DaxRel, nie to by nie pomog?o, poniewa? moja elementData to "uid" a nie "id" :)

Postaw piwo autorowi tego posta
 

 
Tagi: teleportowanie :: pojazdu
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