syrasia Posted March 30, 2015 Posted March 30, 2015 Hi there, I am trying to use OOP where ever i can to learn it. More or less. Nothing special: function f4_get_pos( button, press ) if button == "F4" and (press) then --local x, y, z = getElementPosition(localPlayer) <--This way it works, but no oop local x, y, z = localPlayer:getPosition() <-- throws the error outputChatBox(x) outputChatBox(y) outputChatBox(z) end end addEventHandler("onClientKey", getRootElement(), f4_get_pos) And this is the /debugscript 3 message: attempt to index golbal 'localPlayer' (a userdata value) How do i use oop right in this case? Do i miss somthing? Have a N.I.C.E. day ^^
xeon17 Posted March 30, 2015 Posted March 30, 2015 I had the same problem before a few days, try this: function f4_get_pos( button, press ) if button == "F4" and (press) then --local x, y, z = getElementPosition(localPlayer) <--This way it works, but no oop local x, y, z = localPlayer.position <-- throws the error outputChatBox(x) outputChatBox(y) outputChatBox(z) end end addEventHandler("onClientKey", getRootElement(), f4_get_pos)
#RooTs Posted March 30, 2015 Posted March 30, 2015 @Xeon, why not use? local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) I did not understand, the which is oop?
xeon17 Posted March 30, 2015 Posted March 30, 2015 @Xeon, why not use? local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) I guess you didn't read what he wrote, his problem is that he want to do it in OOP but it doesn't work.
#RooTs Posted March 30, 2015 Posted March 30, 2015 I did not understand, the which is oop? I know more what is OOP
xeon17 Posted March 30, 2015 Posted March 30, 2015 I did not understand, the which is oop? I know more what is OOP Sorry but i really don't understand your english, if you want to learn something about OOP then check the links bellow. https://wiki.multitheftauto.com/wiki/OOP https://wiki.multitheftauto.com/wiki/OOP_Introduction https://wiki.multitheftauto.com/wiki/OOP_client https://wiki.multitheftauto.com/wiki/OOP_server
RenanPG Posted March 30, 2015 Posted March 30, 2015 I did not understand, the which is oop? I know more what is OOP http://en.wikipedia.org/wiki/Object-ori ... rogramming
JR10 Posted March 31, 2015 Posted March 31, 2015 OOP coordinates functions do not return 3 values, it returns a Vector3 object that contains the coords: function f4_get_pos( button, press ) if button == "F4" and (press) then --local x, y, z = getElementPosition(localPlayer) <--This way it works, but no oop local pos = localPlayer.position <-- throws the error outputChatBox(pos.x) outputChatBox(pos.y) outputChatBox(pos.z) end end addEventHandler("onClientKey", getRootElement(), f4_get_pos) Make sure OOP is enabled in meta.xml.
Mr.unpredictable. Posted March 31, 2015 Posted March 31, 2015 I did not understand, the which is oop? I know more what is OOP joke?
syrasia Posted March 31, 2015 Author Posted March 31, 2015 Okay, thanks for the info/tipp xeon, I looked in the oope_client wiki and found out, that the getPostion() seems to be not aviable for cliend side. The link is realy healpfull. BTW: oop is enabled with true in meta.xml So this is solved, ty
#RooTs Posted March 31, 2015 Posted March 31, 2015 Okay,thanks for the info/tipp xeon, I looked in the oope_client wiki and found out, that the getPostion() seems to be not aviable for cliend side. The link is realy healpfull. BTW: oop is enabled with true in meta.xml So this is solved, ty 2 people helped, I and you
xeon17 Posted March 31, 2015 Posted March 31, 2015 Okay,thanks for the info/tipp xeon, I looked in the oope_client wiki and found out, that the getPostion() seems to be not aviable for cliend side. The link is realy healpfull. BTW: oop is enabled with true in meta.xml So this is solved, ty Anytime
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