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

Wysłany: 2016-10-13, 23:22


Kradus







Wiek: 28
Na forum: 4311 dni
Posty: 100
Nick w MP: Salldan

Piwa: 78

Respekt: 50

Witam. Chcia?em doda? wi?cej czo?g?w aby by?o ma?e zr??nicowanie w zakresie pojazd?w wojskowych. Ta funkcja idealnie mi przypasowa?a i uda?o mi si? j? zastosowa? w praktyce. Ale tutaj zaczyna si? zabawa. Nie wiem jak zrobi? aby si? synchronizowa?a wraz z ruchem myszki tak jak w oryginalnym czo?gu i pojazdach z wie?ami. Nie mog? pobra? odpowiednich danych aby m?c ustawi? rotacj? dw?ch rzeczy "misc_a" i "misc_c"(chyba albo misc_b). Kt?r? funkcj? b?d? m?g? pobra? odpowiednie dane oraz jak to zrobi? aby synchronizowa?o si?. Z g?ry dzi?ki za odpowied?.

Edit

W wolnym czasie znalaz?em co? co mi pomog?o i zrobi?em taki oto skrypt ale jest jeszcze niedopracowany. Mianowicie kamera nie obraca si? razem z pojazdem tzn. jak jad? prosto czyli na po?udnie patrz?c na mapk? to mam wie?yczk? normalnie ale jak zawr?c? to si? obr?ci o 180 wie kto? jak to wyklepa??

function move()
if isPedInVehicle(localPlayer) and not isCursorShowing() then
local veh = getPedOccupiedVehicle(localPlayer)
if (veh) then
if (getElementModel(veh) == 605) then
local rotX,_,rotZ = getCameraRotation()
setVehicleComponentRotation(veh,"misc_a",_,_,rotZ )
setVehicleComponentRotation(veh,"misc_b",rotX - 180,_,_)
else return end
end
end
end
setTimer(move,50,0)

function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = math.deg(rotz)    
    return rotx, 180, rotz
end 


Funkcj? getCameraRotation() znalaz?em w internecie a pojazd ma podmiank? czo?gu w kt?rym jest wie?a.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-14, 17:31


drekuu







Wiek: 46
Na forum: 3988 dni
Posty: 16
Nick w MP: drekuu

Piwa: 5

Respekt: 60

Powinno dzia?a?
function move()
if isPedInVehicle(localPlayer) and not isCursorShowing() then
local veh = getPedOccupiedVehicle(localPlayer)
if (veh) then
if (getElementModel(veh) == 605) then
local _,_,vrot=getElementRotation(veh)
local rotX,_,rotZ = getCameraRotation()
local newRotZ=rotZ-vrot
setVehicleComponentRotation(veh,"misc_a",0,0,newRotZ)
setVehicleComponentRotation(veh,"misc_b",rotX - 180,0,0)
else return end
end
end
end
setTimer(move,50,0)

function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = math.deg(rotz)    
    return rotx, 180, rotz
end 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-14, 20:06


Kradus







Wiek: 28
Na forum: 4311 dni
Posty: 100
Nick w MP: Salldan

Piwa: 78

Respekt: 50

Wiesz zrobi?em troch? inaczej i te? zadzia?a?o wi?c problem rotacji ju? rozwi?zany ale wyskoczy? drugi. Mianowicie synchronizacja mi?dzy wszystkimi tzn jak ja porusz? wie?? to u drugiego gracza nadal mam prosto. Pr?bowa?em na stron? serwera a potem z serwera na klienta ale no nie dzia?a. Czy wgl Trigger by zadzia?a?? Oto kod ale no nie chce mi za nic zadzia?a? tak jak bym tego chcia?.

c-side
function move()
if isPedInVehicle(localPlayer) and not isCursorShowing() then
local veh = getPedOccupiedVehicle(localPlayer)
if (veh) then
if (getElementModel(veh) == 605) or (getElementModel(veh) == 420) then
local rotX,_,rotZ = getCameraRotation()
local _,_,rZ = getElementRotation(veh)
setVehicleComponentRotation(veh,"misc_a",_,_,rotZ - rZ )
setVehicleComponentRotation(veh,"misc_b",rotX,_,_)
else return end
end
end
end
--addEventHandler("onClientVehicleEnter", root, move)
addEvent("turn",true)
addEventHandler("turn", root, move)

function server() 
triggerServerEvent( root, "server", root) 
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), server)

function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = math.deg(rotz)    
    return rotx, 180, rotz
end 


s-side

function server () 
triggerClientEvent ( root, "turn", root ) 
end 
addEvent( "server", true ) 
addEventHandler( "server", root, server ) 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-15, 12:12


drekuu







Wiek: 46
Na forum: 3988 dni
Posty: 16
Nick w MP: drekuu

Piwa: 5

Respekt: 60

Nie jest to chyba najlepsze rozwi?zanie, ale dzia?a

c-side:

function move()
if isPedInVehicle(localPlayer) and not isCursorShowing() then
local veh = getPedOccupiedVehicle(localPlayer)
if (veh and getPedOccupiedVehicleSeat(localPlayer)==0) then
if (getElementModel(veh) == 605) or (getElementModel(veh) == 420) then
local rotX,_,rotZ = getCameraRotation()
local _,_,rZ = getElementRotation(veh)
setVehicleComponentRotation(veh,"misc_a",0,0,rotZ - rZ )
setVehicleComponentRotation(veh,"misc_b",rotX,0,0)
setElementData(veh,"misc_a",rotZ-rZ)
setElementData(veh,"misc_b",rotX)
else return end
end
end
end
--addEventHandler("onClientVehicleEnter", root, move)
addEventHandler("onClientRender",root,move)

function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = math.deg(rotz)    
    return rotx, 180, rotz
end 

setTimer(function()
    for i,v in ipairs(getElementsByType("vehicle")) do
        if isElementStreamedIn(v) and not isVehicleBlown(v) and isElement(v) and (getElementModel(v) == 605 or getElementModel(v) == 420) then
            local misc_a=getElementData(v,"misc_a")
            local misc_b=getElementData(v,"misc_b")
            if misc_a and misc_b then
                setVehicleComponentRotation(v,"misc_a",0,0,misc_a)
                setVehicleComponentRotation(v,"misc_b",misc_b,0,0)
            end
        end
    end
end,500,0)

s-side zostaw pusty

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-15, 16:33


Kradus







Wiek: 28
Na forum: 4311 dni
Posty: 100
Nick w MP: Salldan

Piwa: 78

Respekt: 50

No nie do ko?ca. Spyta?em si? kolegi czy wida? ruch a on powiedzia?, ?e si? tylko raz ruszy?o. Tak to wygl?da?o z jego perspektywy ss'a mi podes?a?


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-15, 20:57


drekuu







Wiek: 46
Na forum: 3988 dni
Posty: 16
Nick w MP: drekuu

Piwa: 5

Respekt: 60

Testowa?em przed chwil? z koleg? i wszystko dzia?a?o, mo?e korzystasz z innego pojazdu ni? 605 lub 420?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-16, 15:08


Kradus







Wiek: 28
Na forum: 4311 dni
Posty: 100
Nick w MP: Salldan

Piwa: 78

Respekt: 50

A nie wybacz nie zauwa?y?em heh kopiowa?em kod a zupe?nie inny jest teraz :p Teraz dzia?a dzi?ki za pomoc. Do zamkni?cia

Postaw piwo autorowi tego posta
 

 
Tagi: setvehiclecomponentrotation
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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