Jump to content

[HELP]get player position


Recommended Posts

Posted

what's the problem in this codes:

local x, y, z = getElementPosition(localPlayer);
if (x == 1554.2001953125) then
	if (y == -1675.599609375) then
		if (z == 15.199999809265) then
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
		end
	end
end

???????????????????????????????????????????????????

Posted

1 localPlayer is for the client side

2 It't almost impossible to check a position like that, you may try getDistanceBetweenPoints3D

Posted

AllRight!So What's The Problem Now?

function EnterToPD ()
	local x, y, z = getElementPosition ( thePlayer )
	if (x == 1554.2001953125) then
		if (y == 1554.2001953125) then
			if (z == 15.199999809265) then
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
			end
		end
	end
end
addCommandHandler("in", EnterToPD)

Please Help Me!!!!!!!!!!!!!And If My Code's Wrong So Tell Me What can I Do? In fact, Just Send Me The Code :)

Thank's ❤️❤️❤️❤️❤️❤️❤️

Posted (edited)
function EnterToPD (source)
	local x, y, z = getElementPosition ( source )
	if (x == 1554.2001953125 and y == 1554.2001953125 and z == 15.199999809265 ) then
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
			end
		end
addCommandHandler("in", EnterToPD)

 

Edited by -Ilker.
Posted
19 minutes ago, -Ilker. said:

function EnterToPD (source)
	local x, y, z = getElementPosition ( source )
	if (x == 1554.2001953125 and y == 1554.2001953125 and z == 15.199999809265 ) then
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
			end
		end
addCommandHandler("in", EnterToPD)

 

It didn't work either. My goal is to get into the PDHQ when the player is in the marker.Can you give me the necessary codes?

Posted
yourmarker = createMarker(....)
function EnterToPD (source)
	local x, y, z = getElementPosition ( source )
	if ( isElementWithinMarker ( source , yourmarker ) ) then 
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
			end
		end
addCommandHandler("in", EnterToPD)

Do you mean like this?

Posted

i got error in console :

Line 4 : Bad Argument @ 'isElementWithInMarker' [Expected marker at argument 2, got boolean

I mean, when the player is in the back of the police station, it will show up inside. That's it! Like a normal "door" system on MTA!

32 minutes ago, -Ilker. said:

yourmarker = createMarker(....)
function EnterToPD (source)
	local x, y, z = getElementPosition ( source )
	if ( isElementWithinMarker ( source , yourmarker ) ) then 
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
			end
		end
addCommandHandler("in", EnterToPD)

Do you mean like this?

i got error in console :

Line 4 : Bad Argument @ 'isElementWithInMarker' [Expected marker at argument 2, got boolean

I mean, when the player is in the back of the police station, it will show up inside. That's it! Like a normal "door" system on MTA!

32 minutes ago, -Ilker. said:

yourmarker = createMarker(....)
function EnterToPD (source)
	local x, y, z = getElementPosition ( source )
	if ( isElementWithinMarker ( source , yourmarker ) ) then 
			outputChatBox ("Entered", source, 0, 255, 0, false)
			spawnPlayer (source, 923.5, -1143.5, 392.79998779297, 180, math.random (0,288), 0, 0, spawnTeam)
			fadeCamera (source, true)
			setCameraTarget (source, source)
			end
		end
addCommandHandler("in", EnterToPD)

Do you mean like this?

i got error in console :

Line 4 : Bad Argument @ 'isElementWithInMarker' [Expected marker at argument 2, got boolean

I mean, when the player is in the back of the police station, it will show up inside. That's it! Like a normal "door" system on MTA!

Posted (edited)

Also I have already told you, you can't check a player position like that, try using getDistanceBetweenPoints3D

local x,y,z = getElementPosition(player);

local tx,ty,tz = 1554.2001953125, -1675.599609375, 15.199999809265;

if getDistanceBetweenPoints3D(x,y,z,tx,ty,tz) <= 1 then

-- do something

end

 

Edited by Tekken

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...