Liyones Posted December 28, 2019 Share Posted December 28, 2019 Well , hello MTA comunity , can someone help me please , how i can know my xyz position because i was making script and i need to know my position xyz , can someone help me please ! thanks ! Link to comment
MTA Anti-Cheat Team Dutchman101 Posted December 28, 2019 MTA Anti-Cheat Team Share Posted December 28, 2019 I think you mean this: local x, y, z = getElementPosition(element) 3 hours ago, X.Liyones.X said: know my xyz position I think you want to replace element with thePlayer or localPlayer I guess you understand it now, but just in case: Example on how to use the position stored in the x, y, z local local x, y, z = getElementPosition(thePlayer) -- get player's location createVehicle(551, x, y, z) -- spawn a vehicle at player's location That code would do exactly the same as this: createVehicle(551, getElementPosition(thePlayer)) The reason that above code (single line) also works, is because createVehicle requires 3 float functions (x, y, z position) to spawn a vehicle, and getElementPosition returns exactly these 3 float values that it wants. Note to others reading this in the future: you can't use a local like this (a, b, c) for all functions - the reason it fits getElementPosition is because it returns 3 float values, as the wiki page for this function reads: However, you can store return values from plenty of functions in a local with the appropiate amount of values (not just local a, b, c) and the reason I am turning this reply into some kind of tutorial is because I've seen the prevalence of scripts that can be easily cleaned up by doing things like this. @X.Liyones.X 1 Link to comment
AleksCore Posted December 31, 2019 Share Posted December 31, 2019 https://community.multitheftauto.com/index.php?p=resources&s=details&id=6778 maybe this script will be useful for you 1 Link to comment
Liyones Posted December 31, 2019 Author Share Posted December 31, 2019 4 hours ago, AleksCore said: https://community.multitheftauto.com/index.php?p=resources&s=details&id=6778 maybe this script will be useful for you On 28/12/2019 at 14:28, Dutchman101 said: I think you mean this: local x, y, z = getElementPosition(element) I think you want to replace element with thePlayer or localPlayer I guess you understand it now, but just in case: Example on how to use the position stored in the x, y, z local local x, y, z = getElementPosition(thePlayer) -- get player's location createVehicle(551, x, y, z) -- spawn a vehicle at player's location That code would do exactly the same as this: createVehicle(551, getElementPosition(thePlayer)) The reason that above code (single line) also works, is because createVehicle requires 3 float functions (x, y, z position) to spawn a vehicle, and getElementPosition returns exactly these 3 float values that it wants. Note to others reading this in the future: you can't use a local like this (a, b, c) for all functions - the reason it fits getElementPosition is because it returns 3 float values, as the wiki page for this function reads: However, you can store return values from plenty of functions in a local with the appropiate amount of values (not just local a, b, c) and the reason I am turning this reply into some kind of tutorial is because I've seen the prevalence of scripts that can be easily cleaned up by doing things like this. @X.Liyones.X thanks guys 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