Jump to content

Warp panel like free roam


Oussema

Recommended Posts

local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1366), (screenH/768)


addEvent("showDestination",true)
addEventHandler("showDestination",client,function()
    jobMapWin = guiCreateWindow(x*402, y*120, x*620, y*569, "SAEG Map", false)
    guiWindowSetSizable(jobMapWin, false)
    jobMapIm = guiCreateStaticImage(x*10, y*7, x*600, y*551, "images/map.png", false, jobMapWin) 	
	addEventHandler("onClientGUIDoubleClick", jobMapIm, onMapImageDoubleClick)
	showCursor(true)
end)


function onMapImageDoubleClick(button, state, absX, absY)
	if (not absX or not absY) then return end
	local mapX, mapY, mapWidth, mapHeight = x + 10, y* 7, 600, 551
	local relX, relY = (absX - mapX) / mapWidth, (absY - mapY) / mapHeight
	local x = relX*6000 - 3000
	local y = 3000 - relY*6000
	local hit, hitX, hitY, hitZ
	hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000)
	--guiSetVisible(jobMapIm, false)
	--showCursor(false)
end

what's worng ?? 0 errors guys

Link to comment
  • Moderators

 

41 minutes ago, Oussema said:

Yes , my server name SAEG:RPG And i can prove that to you if you want 

I've used the contact form on your forum asking if you were part of the group, I don't know if it works.

Anyway, processLineOfSight returns nil probably because your calculations are incorrect and you end up calling that function at a wrong x and y position.

You probably wanted to do something like this at line 17:

local mapX, mapY, mapWidth, mapHeight = x*10, y*7, x*600, y*551

If for some reason, it's still not working, try to print the x and y variables.

Link to comment
  • Moderators

Well, can you double click around the middle of the map.png and reply here with the value you get for mapX, mapY, mapWidth, mapHeight, absX, absY, relX, relY, x, y.

I was not saying they are not defined, just that their values are wrong. So yeah, maybe show fine in chatbox but are they correct is what I'm wondering.

Link to comment

This one wont work with processLineOfSight because of this:

 

Quote

The two positions must be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.

 

Did a bypass with a little trick.
Tested and worked for me.

function onMapImageDoubleClick(button, state, absX, absY)
	if (not absX or not absY) then return end
	local absX, absY = absX-x*402-x*10, absY-y*120-y*7
	local mapWidth, mapHeight = x*600, y*551
	local relX, relY = absX/mapWidth, absY/mapHeight
	local x = relX*6000 - 3000
	local y = 3000 - relY*6000
	local hit, hitX, hitY, hitZ
	setElementPosition(localPlayer, x, y, 0)
	setElementFrozen(localPlayer, true)
	setTimer(function()
		hit, hitX, hitY, hitZ = processLineOfSight(x, y, 200, x, y, -200)
		setElementPosition(localPlayer, x, y, hitZ+2)
		setElementFrozen(localPlayer, false)
		--guiSetVisible(jobMapIm, false)
		--showCursor(false)
	end, 300, 1)
end

If you need further help, feel free to ask here.

  • Like 1
Link to comment
On 14/03/2017 at 22:33, Patrik91 said:

This one wont work with processLineOfSight because of this:

 

 

Did a bypass with a little trick.
Tested and worked for me.


function onMapImageDoubleClick(button, state, absX, absY)
	if (not absX or not absY) then return end
	local absX, absY = absX-x*402-x*10, absY-y*120-y*7
	local mapWidth, mapHeight = x*600, y*551
	local relX, relY = absX/mapWidth, absY/mapHeight
	local x = relX*6000 - 3000
	local y = 3000 - relY*6000
	local hit, hitX, hitY, hitZ
	setElementPosition(localPlayer, x, y, 0)
	setElementFrozen(localPlayer, true)
	setTimer(function()
		hit, hitX, hitY, hitZ = processLineOfSight(x, y, 200, x, y, -200)
		setElementPosition(localPlayer, x, y, hitZ+2)
		setElementFrozen(localPlayer, false)
		--guiSetVisible(jobMapIm, false)
		--showCursor(false)
	end, 300, 1)
end

If you need further help, feel free to ask here.

Thx worked 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...