sabarupl
Wiek: 43 Na forum: 4825 dni Posty: 347
Piwa : 163
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)