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

Wysłany: 2019-01-31, 21:02


smigi







Wiek: 23
Na forum: 3367 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50

witam pomoze mi ktos ? gdy wgrywam radar z paczki stories rpg pod pysa to mi nie dziala nie wyswietla sie tu kod


Kod:

local enableBlips = true
local renderNorthBlip = true
local alwaysRenderMap = false


local worldW, worldH = 3072, 3072 --map image dimensions - if map image changed, please edit appropriately
local blip = 12 --Blip size, pixels relative to 1366x768 resolution

------------------------------------------------------------------------------------
--Do not modify anything below unless you're absolutely sure of what you're doing.--
------------------------------------------------------------------------------------

local sx, sy = guiGetScreenSize()
local rt = dxCreateRenderTarget(290, 175)
local xFactor, yFactor = sx/1366, sy/768
local yFactor = xFactor --otherwise the radar looses it's 2:3 ratio.

local w, h=(sx/1680), (sy/1050)


-- Useful functions --
function findRotation(x1,y1,x2,y2) --Author: Doomed_Space_Marine & robhol
local t = -math.deg(math.atan2(x2-x1,y2-y1))
if t < 0 then t = t + 360 end;
return t;
end
function getPointFromDistanceRotation(x, y, dist, angle) --Author: robhol
local a = math.rad(90 - angle);
local dx = math.cos(a) * dist;
local dy = math.sin(a) * dist;
return x+dx, y+dy;
end

function drawRadar()
if not getElementData(localPlayer,"player:logged") then return end
if getElementData(localPlayer,"hud:visible") then
setPlayerHudComponentVisible("radar", false)
if (not isPlayerMapVisible()) then
local mW, mH = dxGetMaterialSize(rt)
local x, y = getElementPosition(localPlayer)
local X, Y = mW/2 -(x/(6000/worldW)), mH/2 +(y/(6000/worldH))
local camX,camY,camZ = getElementRotation(getCamera())
dxSetRenderTarget(rt, true)
if alwaysRenderMap or getElementInterior(localPlayer) == 0 then
dxDrawRectangle(0, 0, mW, mH, 0xFF7CA7D1) --render background
dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, "image/world.jpg", camZ, (x/(6000/worldW)), -(y/(6000/worldH)), tocolor(255, 255, 255, 255))
end
dxSetRenderTarget()
dxDrawImage(17*w, 1012*h, 358*w, 5*h, "image/pasek.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)

dxDrawImage((10+5)*xFactor, sy-((200+5))*yFactor, (300-10)*xFactor, (175)*yFactor, rt, 0, 0, 0, tocolor(255, 255, 255, 150))
local col = tocolor(r, g, b, 190)
local bg = tocolor(r, g, b, 100)

local rx, ry, rz = getElementRotation(localPlayer)
local lB = (15)*xFactor
local rB = (15+290)*xFactor
local tB = sy-(205)*yFactor
local bB = tB + (175)*yFactor
local cX, cY = (rB+lB)/2, (tB+bB)/2 +(35)*yFactor
local toLeft, toTop, toRight, toBottom = cX-lB, cY-tB, rB-cX, bB-cY
for k, v in ipairs(getElementsByType("blip")) do
local bx, by = getElementPosition(v)
local actualDist = getDistanceBetweenPoints2D(x, y, bx, by)
local maxDist = getBlipVisibleDistance(v)
if actualDist <= maxDist and getElementDimension(v)==getElementDimension(localPlayer) and getElementInterior(v)==getElementInterior(localPlayer) then
local dist = actualDist/(6000/((worldW+worldH)/2))
local rot = findRotation(bx, by, x, y)-camZ
local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.min(dist, math.sqrt(toTop^2 + toRight^2)), rot)
local bpx = math.max(lB, math.min(rB, bpx))
local bpy = math.max(tB, math.min(bB, bpy))
local bid = getElementData(v, "customIcon") or getBlipIcon(v)
local _, _, _, bcA = getBlipColor(v)
local bcR, bcG, bcB = 255, 255, 255
if getBlipIcon(v) == 0 then
bcR, bcG, bcB = getBlipColor(v)
end
local bS = getBlipSize(v)
dxDrawImage(bpx -(blip*bS)*xFactor/2, bpy -(blip*bS)*yFactor/2, (blip*bS)*xFactor, (blip*bS)*yFactor, "image/blip/"..bid..".png", 0, 0, 0, tocolor(bcR, bcG, bcB, bcA))
end
end
if renderNorthBlip then
local rot = -camZ+180
local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.sqrt(toTop^2 + toRight^2), rot) --get position
local bpx = math.max(lB, math.min(rB, bpx))
local bpy = math.max(tB, math.min(bB, bpy)) --cap position to screen
local dist = getDistanceBetweenPoints2D(cX, cY, bpx, bpy) --get distance to the capped position
local bpx, bpy = getPointFromDistanceRotation(cX, cY, dist, rot) --re-calculate position based on new distance
if bpx and bpy then --if position was obtained successfully
local bpx = math.max(lB, math.min(rB, bpx))
local bpy = math.max(tB, math.min(bB, bpy)) --cap position just in case
dxDrawImage(bpx -(blip*2)/2, bpy -(blip*2)/2, blip*2, blip*2, "image/blip/4.png", 0, 0, 0) --draw north (4) blip
end
end
dxDrawImage(cX -(blip*2)*xFactor/2, cY -(blip*2)*yFactor/2, (blip*2)*xFactor, (blip*2)*yFactor, "image/player.png", camZ-rz, 0, 0)
end
end
end
addEventHandler("onClientRender", root, drawRadar)

addEventHandler("onClientResourceStop", resourceRoot, function()
setPlayerHudComponentVisible("radar", true)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-31, 21:18


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Posiadasz elementDaty: "hud:visible" oraz "player:logged"?
Jakie? b??dy "/debugscript 3"?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-31, 22:10


smigi







Wiek: 23
Na forum: 3367 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50

tak posiadam
zadnych bledow

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-03, 10:53


Mezo.

Mod-Team






Wiek: 24
Na forum: 3211 dni
Posty: 548
Nick w MP: Mezo

Piwa: 6070

Respekt: 517
Respekt: 517




local enableBlips true 
local renderNorthBlip true 
local alwaysRenderMap false 


local worldWworldH 30723072 --map image dimensions - if map image changedplease edit appropriately 
local blip 12 --Blip sizepixels relative to 1366x768 resolution 

------------------------------------------------------------------------------------ 
--Do not modify anything below unless you're absolutely sure of what you're doing.-- 
------------------------------------------------------------------------------------ 

local sxsy guiGetScreenSize() 
local rt dxCreateRenderTarget(290175local xFactoryFactor sx/1366sy/768 
local yFactor xFactor --otherwise the radar looses it's 2:3 ratio. 

local w, h=(sx/1680), (sy/1050) 


-- Useful functions -- 
function findRotation(x1,y1,x2,y2) --Author: Doomed_Space_Marine & robhol 
local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
if t < 0 then t = t + 360 end; 
return t; 
end 
function getPointFromDistanceRotation(x, y, dist, angle) --Author: robhol 
local a = math.rad(90 - angle); 
local dx = math.cos(a) * dist; 
local dy = math.sin(a) * dist; 
return x+dx, y+dy; 
end 

function drawRadar() 
if getElementData(localPlayer,"hud:visible") then 
setPlayerHudComponentVisible("radar", false) 
if (not isPlayerMapVisible()) then 
local mW, mH = dxGetMaterialSize(rt) 
local x, y = getElementPosition(localPlayer) 
local X, Y = mW/2 -(x/(6000/worldW)), mH/2 +(y/(6000/worldH)) 
local camX,camY,camZ = getElementRotation(getCamera()) 
dxSetRenderTarget(rt, true) 
if alwaysRenderMap or getElementInterior(localPlayer) == 0 then 
dxDrawRectangle(0, 0, mW, mH, 0xFF7CA7D1) --render background 
dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, "image/world.jpg", camZ, (x/(6000/worldW)), -(y/(6000/worldH)), tocolor(255, 255, 255, 255)) 
end 
dxSetRenderTarget() 
dxDrawImage(17*w, 1012*h, 358*w, 5*h, "image/pasek.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 

dxDrawImage((10+5)*xFactor, sy-((200+5))*yFactor, (300-10)*xFactor, (175)*yFactor, rt, 0, 0, 0, tocolor(255, 255, 255, 150)) 
local col = tocolor(r, g, b, 190) 
local bg = tocolor(r, g, b, 100) 

local rx, ry, rz = getElementRotation(localPlayer) 
local lB = (15)*xFactor 
local rB = (15+290)*xFactor 
local tB = sy-(205)*yFactor 
local bB = tB + (175)*yFactor 
local cX, cY = (rB+lB)/2, (tB+bB)/2 +(35)*yFactor 
local toLeft, toTop, toRight, toBottom = cX-lB, cY-tB, rB-cX, bB-cY 
for k, v in ipairs(getElementsByType("blip")) do 
local bx, by = getElementPosition(v) 
local actualDist = getDistanceBetweenPoints2D(x, y, bx, by) 
local maxDist = getBlipVisibleDistance(v) 
if actualDist <= maxDist and getElementDimension(v)==getElementDimension(localPlayer) and getElementInterior(v)==getElementInterior(localPlayer) then 
local dist = actualDist/(6000/((worldW+worldH)/2)) 
local rot = findRotation(bx, by, x, y)-camZ 
local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.min(dist, math.sqrt(toTop^2 + toRight^2)), rot) 
local bpx = math.max(lB, math.min(rB, bpx)) 
local bpy = math.max(tB, math.min(bB, bpy)) 
local bid = getElementData(v, "customIcon") or getBlipIcon(v) 
local _, _, _, bcA = getBlipColor(v) 
local bcR, bcG, bcB = 255, 255, 255 
if getBlipIcon(v) == 0 then 
bcR, bcG, bcB = getBlipColor(v) 
end 
local bS = getBlipSize(v) 
dxDrawImage(bpx -(blip*bS)*xFactor/2, bpy -(blip*bS)*yFactor/2, (blip*bS)*xFactor, (blip*bS)*yFactor, "image/blip/"..bid..".png", 0, 0, 0, tocolor(bcR, bcG, bcB, bcA)) 
end 
end 
if renderNorthBlip then 
local rot = -camZ+180 
local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.sqrt(toTop^2 + toRight^2), rot) --get position 
local bpx = math.max(lB, math.min(rB, bpx)) 
local bpy = math.max(tB, math.min(bB, bpy)) --cap position to screen 
local dist = getDistanceBetweenPoints2D(cX, cY, bpx, bpy) --get distance to the capped position 
local bpx, bpy = getPointFromDistanceRotation(cX, cY, dist, rot) --re-calculate position based on new distance 
if bpx and bpy then --if position was obtained successfully 
local bpx = math.max(lB, math.min(rB, bpx)) 
local bpy = math.max(tB, math.min(bB, bpy)) --cap position just in case 
dxDrawImage(bpx -(blip*2)/2, bpy -(blip*2)/2, blip*2, blip*2, "image/blip/4.png", 0, 0, 0) --draw north (4) blip 
end 
end 
dxDrawImage(cX -(blip*2)*xFactor/2, cY -(blip*2)*yFactor/2, (blip*2)*xFactor, (blip*2)*yFactor, "image/player.png", camZ-rz, 0, 0) 
end 
end 
end 
addEventHandler("onClientRender", root, drawRadar) 

addEventHandler("onClientResourceStop", resourceRoot, function() 
setPlayerHudComponentVisible("radar", true) 
end)

Spr?buj tak, je?eli nie b?dziemy dalej dzia?a?.

Podpis
- Na forum pomagam na miarę swoich możliwości, oraz bezpłatnie.
- Jeżeli potrzebujesz pomocy, pisz do mnie w prywatnej wiadomości, pomoc uzyskasz szybciej.
Współpraca - [email protected]


Użytkownik - 19.08.2017
GTAO MEMBER - 29.03.2019
Support-Team - 03.02.2019 - 07.05.2019
Moderator - 07.05.2019 - 02.08.2020
Mod-Team - 02.08.2020 - 25.03.2022

Postaw piwo autorowi tego posta
 

 
Tagi: radar :: nie :: dziala
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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