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

Wysłany: 2024-05-19, 21:43


sabarupl







Wiek: 43
Na forum: 4825 dni
Posty: 347

Piwa: 163

Respekt: 230
Respekt: 230Respekt: 230

Mam tu taki fragment skryptu po stronie klienta, który ustawia teksturę w konkretnym miejscu. Tekstura jest ustawiona, jednak kiedy postać zmienia położenie to zmienia się też kierunek tej tekstury. Czy wie ktoś jak ustawić żeby tekstura była ustawiona cały czas pozioma i skierowana w górę?

Kod:

-- Ustawienie pozycji tarczy
local targetPosition = {1290.50659, -1119.45020, 53.00852}
local targetTexture = nil
local isDrawingTarget = false
local targetBlip = nil

-- Funkcja rysująca poziomą teksturę
local function drawHorizontalTexture(x, y, z, texture, size)
local x1, y1, z1 = x - size, y, z
local x2, y2, z2 = x + size, y, z

dxDrawMaterialLine3D(x1, y1, z1, x2, y2, z2, texture, size * 2, tocolor(255, 255, 255, 255))
end

-- Funkcja do sprawdzenia, czy gracz jest w strefie tarczy
local function isPlayerInTargetZone()
local x, y, z = getElementPosition(localPlayer)
local tx, ty, tz = targetPosition[1], targetPosition[2], targetPosition[3]
local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)
return distance <= 3
end

-- Funkcja do obsługi lądowania gracza
local function handlePlayerLanding()
if isDrawingTarget then
if isPlayerInTargetZone() then
-- Gracz wylądował w strefie tarczy
isDrawingTarget = false
if targetTexture then
destroyElement(targetTexture)
targetTexture = nil
end
if targetBlip then
destroyElement(targetBlip)
targetBlip = nil
end
triggerServerEvent("rewardPlayer", localPlayer)
else
-- Gracz nie trafił do strefy tarczy
isDrawingTarget = false
if targetTexture then
destroyElement(targetTexture)
targetTexture = nil
end
if targetBlip then
destroyElement(targetBlip)
targetBlip = nil
end
outputChatBox("Niestety nie udało się, ale przynajmniej przeżyłeś!", 255, 0, 0)
end
end
end

-- Funkcja do monitorowania gracza
local function monitorPlayerLanding()
setTimer(function()
if isElement(localPlayer) then
if isPedOnGround(localPlayer) then
handlePlayerLanding()
killTimer(sourceTimer)
elseif isPedDead(localPlayer) then
if isDrawingTarget then
isDrawingTarget = false
if targetTexture then
destroyElement(targetTexture)
targetTexture = nil
end
if targetBlip then
destroyElement(targetBlip)
targetBlip = nil
end
end
outputChatBox("Niestety zginąłeś podczas skoku.", 255, 0, 0)
killTimer(sourceTimer)
end
end
end, 500, 0)
end

-- Funkcja do rozpoczęcia monitorowania po opóźnieniu
local function startMonitoringAfterDelay()
outputChatBox("Masz 3 sekundy, aby oderwać się od ziemi, inaczej misja zostanie anulowana!", 255, 165, 0)
setTimer(function()
monitorPlayerLanding()
end, 3000, 1) -- 3 sekundy opóźnienia
end

-- Funkcja rysująca tarczę
local function drawTarget()
if isDrawingTarget and targetTexture then
drawHorizontalTexture(targetPosition[1], targetPosition[2], targetPosition[3], targetTexture, 2) -- Rysowanie poziomej tarczy
end
end
addEventHandler("onClientRender", root, drawTarget)

-- Obsługa zdarzenia stworzenia markera tarczy
addEvent("createTargetMarker", true)
addEventHandler("createTargetMarker", root, function()
targetTexture = dxCreateTexture("target.png")
targetBlip = createBlip(targetPosition[1], targetPosition[2], targetPosition[3], 0, 2, 255, 165, 0, 255) -- Tworzenie blipa na mapie
isDrawingTarget = true
startMonitoringAfterDelay()
end)

-- Obsługa zdarzenia powiadomienia o cooldownie
addEvent("notifyCooldown", true)
addEventHandler("notifyCooldown", root, function(timeLeft)
outputChatBox("Musisz poczekać jeszcze " .. math.ceil(timeLeft / 1000) .. " sekund, zanim ponownie podniesiesz spadochron!", 255, 0, 0)
end)

-- Obsługa zdarzenia nagrodzenia gracza
addEvent("rewardPlayer", true)
addEventHandler("rewardPlayer", root, function()
triggerServerEvent("rewardPlayer", localPlayer)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2024-08-26, 12:10


Hemoglobina

Tylko Hema






Wiek: 29
Na forum: 3397 dni
Posty: 89
Nick w MP: Answer

Piwa: 1386

Respekt: 90

https://wiki.multitheftauto.com/wiki/DxDrawMaterialLine3D

Argument opcjonalny:

- faceTowardX/Y/Z: The position the front of the line should face towards. If this is not set, the camera position is used, so the front of the line faces toward the camera.

Musisz to podać pozycje w którą ma być skierowana tekstura w innym wypadku jeżeli nie jest to określone, tekstura będzie ustawiałą się zawsze do kamery postaci.

Postaw piwo autorowi tego posta
 

 
Tagi: tekstura :: zmienia :: kąt :: raz :: zmianą :: położenia :: postaci.
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Tekstura zmienia kąt w raz ze zmianą położenia postaci. Odpowiedz do tematu

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