ProCurator Posted January 10, 2011 Share Posted January 10, 2011 I'm new in Lua, now I'm trying to make first Command, but it's don't work. The question is: why? function GetPosition ( player ) local x, y, z = GetElementPosition( player ) local rx, ry, rz = GetElementRotation( player ) outputChatBox( "Your Position: "..x..", "..y..", "..z..", Rotation: "..rx..", "..ry..", "..rz) end addCommandHandler ( "pos", GetPosition ) I was looking for a some Topic for new noobs in making commands, but i don't found nothing. PS: And sorry for my english :F Link to comment
SDK Posted January 10, 2011 Share Posted January 10, 2011 Welcome to Lua 1st, use [ lua][ /lua] tags. 2nd, Lua scripts are case sensitive, so you need to check the wiki when you're scripting with MTA functions. function GetPosition ( player ) local x, y, z = getElementPosition( player ) local rx, ry, rz = getElementRotation( player ) outputChatBox( "Your Position: "..x..", "..y..", "..z..", Rotation: "..rx..", "..ry..", "..rz) end addCommandHandler ( "pos", GetPosition ) Link to comment
ProCurator Posted January 10, 2011 Author Share Posted January 10, 2011 I know, I always checking everything in wiki, because i don't know functions... But command still don't work, can somebody make it correct? :C It's will really helpful. Link to comment
Castillo Posted January 10, 2011 Share Posted January 10, 2011 it works in server side, if you want it client side then do: function GetPosition () local x, y, z = getElementPosition( getLocalPlayer() ) local rx, ry, rz = getElementRotation( getLocalPlayer() ) outputChatBox( "Your Position: "..x..", "..y..", "..z..", Rotation: "..rx..", "..ry..", "..rz) end addCommandHandler ( "pos", GetPosition ) you can define what side will be in meta.xml. Link to comment
ProCurator Posted January 10, 2011 Author Share Posted January 10, 2011 So if your code is good, why it's still don't work?! Maybe something is wrong with meta.xml? <meta> <info author="ProCurator" version="1.0" type="script" name="Get Position"/> <script src="GetPosition.lua" /> </meta> Name of Lua: GetPosition.lua Link to comment
Castillo Posted January 10, 2011 Share Posted January 10, 2011 with this code it works: function GetPosition ( player ) local x, y, z = getElementPosition( player ) local rx, ry, rz = getElementRotation( player ) outputChatBox( "Your Position: "..x..", "..y..", "..z..", Rotation: "..rx..", "..ry..", "..rz,player) end addCommandHandler ( "pos", GetPosition ) i've tested it and has no problems. Link to comment
ProCurator Posted January 10, 2011 Author Share Posted January 10, 2011 Thanks, it's working! 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