Cacaroto Posted August 6, 2019 Share Posted August 6, 2019 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? Link to comment
WorthlessCynomys Posted August 6, 2019 Share Posted August 6, 2019 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. Link to comment
Cacaroto Posted August 7, 2019 Author Share Posted August 7, 2019 (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 August 7, 2019 by Cacaroto Link to comment
Cacaroto Posted August 8, 2019 Author Share Posted August 8, 2019 Is that good? I need help Link to comment
DNL291 Posted August 9, 2019 Share Posted August 9, 2019 function isPlayerInSA( p ) local px, py = getElementPosition(p) return ( ( px <= 3000 and px >= -3000 ) and ( py <= 3000 and py >= -3000 ) ) end 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now