Jump to content

[HELP] How to know if a player passed map limit?


Cacaroto

Recommended Posts

Posted

I was trying to create a script which detect if a player has passed the map limit (in general case GTA:SA map). I tried something with getElementPosition but I think it's a bad way to develop this resource. Can somebody help me?

Posted

There's two basic solutions for this problem. You either check the position of the player, GTA map is 6000x6000 which means that it's from -3000 to 3000 on both axis.

OR

You create a map sized colShape and add an event handler to check if the player exits it. That's the worse solution in my opinion.

Posted (edited)

Okay, so would be done just checking if a player passes from -3000 or +3000 with getElementPosition?

CLIENT

function checkIfPlayerPassedLimit()
    local x, y, z = getElementPosition(getLocalPlayer())
    if x > 3000 or -3000 or y > 3000 or -3000 or z > 3000 or -3000 then
        local pName = getPlayerName(getLocalPlayer())
        triggerServerEvent ( "onLimitPass", resourceRoot, pName)
    end
end

 

SERVER

function greetingHandler (pName)
    outputChatBox( pName.." has passed map limit.", getRootElement(), 255, 255, 255, trues )
end
addEvent( "onLimitPass", true )
addEventHandler( "onLimitPass", resourceRoot, greetingHandler )

 

Edited by Cacaroto
Posted
function isPlayerInSA( p )
	local px, py = getElementPosition(p)

	return ( ( px <= 3000 and px >= -3000 ) and ( py <= 3000 and py >= -3000 ) )
end

 

  • Like 1

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