Greenie0101 Posted December 11, 2012 Posted December 11, 2012 something that ive always wondered and im sure is posible and very easy but i cant work out, is how to define values in a timer for example i can do this x,y,z = getElementPosition(source) but i cant do this setTimer(x,y,z = getElementPosition,100,0) how can i do something like this so i can use x,y,z later? New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
manve1 Posted December 11, 2012 Posted December 11, 2012 setTimer( function( ) local x, y, z = getElementPosition(source) end, 100, 0 ) Looking for tutorials or information? check out: www.simpleask.co.uk
TAPL Posted December 11, 2012 Posted December 11, 2012 You will need to pass an argument because "source" is not defined here.
TwiX! Posted December 11, 2012 Posted December 11, 2012 setTimer ( example, 100, 1, source ); function example ( player ) x, y, z = getElementPosition ( player ); end But if you not have source: You will need to pass an argument because "source" is not defined here. - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
HunT Posted December 11, 2012 Posted December 11, 2012 Or : https://wiki.multitheftauto.com/wiki/OnClientRender @Huntone_
Greenie0101 Posted December 11, 2012 Author Posted December 11, 2012 You will need to pass an argument because "source" is not defined here. this was just an example, ive got a script which uses an event making the player the source Or : https://wiki.multitheftauto.com/wiki/OnClientRender its server sided oh and this script is using getElementVelocity and not getElementPosition and all im getting is 0 as my return what if i went setTimer(outputChatBox,100,0,getElementVelocity(object),source) is there a way to make that output the velocity in all 3 of its returns? New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
TAPL Posted December 11, 2012 Posted December 11, 2012 You will need to pass an argument because "source" is not defined here. this was just an example, ive got a script which uses an event making the player the source Anything come from outside the function that are inside the timer, and not global (local) or source from an event, you will need to pass it. -- you sholud have event here setTimer(function(source) local x, y, z = getElementVelocity(object) -- object is global? if not you need to pass it too. outputChatBox(x..", "..y..", "..z, source) end,100,0,source)
Greenie0101 Posted December 11, 2012 Author Posted December 11, 2012 still getting 0 for everything even when the object i falling quite fast New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
Jaysds1 Posted December 11, 2012 Posted December 11, 2012 try this: local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 ) --creates an object setElementVelocity(object,1000,0,0) --sets the speed of the object 1000 going north --For onClientRender addEventHandler("onClientRender",root,function() local x,y,z = getElementVelocity(object) --if the object isn't moving then the x,y,z would be zero outputChatBox(x.. "," ..y..","..z) --Outputs the x,y,z speed of the object end) --timer setTimer(function() local x,y,z = getElementVelocity(object) --if the object isn't moving then the x,y,z would be zero outputChatBox(x.. "," ..y..","..z) --Outputs the x,y,z speed of the object end,1000,7) BTW, the setElementVelocity is only client-side only. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Greenie0101 Posted December 12, 2012 Author Posted December 12, 2012 try this: local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 ) --creates an object setElementVelocity(object,1000,0,0) --sets the speed of the object 1000 going north --For onClientRender addEventHandler("onClientRender",root,function() local x,y,z = getElementVelocity(object) --if the object isn't moving then the x,y,z would be zero outputChatBox(x.. "," ..y..","..z) --Outputs the x,y,z speed of the object end) --timer setTimer(function() local x,y,z = getElementVelocity(object) --if the object isn't moving then the x,y,z would be zero outputChatBox(x.. "," ..y..","..z) --Outputs the x,y,z speed of the object end,1000,7) BTW, the setElementVelocity is only client-side only. what ive done is made 2 objects, one is a ped the other is an object. i have attached them so that as the ped falls with graity the object falls too. then i want to get the velocity of the ped every 100ms. i know how to do all this and it should be easy. however even when the ped is clearly falling very fast, with the object attached, im getting 0,0,0 as my velocity New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
Tete omar Posted December 12, 2012 Posted December 12, 2012 As i understood from what you said you want to attach the object to the player that when the player falls or move anywhere the object moves with him too , so you supposed to use: attachElements already
Greenie0101 Posted December 12, 2012 Author Posted December 12, 2012 ok im being misunderstood. I have a script which makes a ped (not the player) and an object and attaches them. i dont need to be told how to do all that. i have the ped and object created, attached and falling, thats not what i needed help to do. now i need to use setTimer so i get the velocity of the ped as it falls every 100ms. when i do this in a different function, all i get is 0,0,0 on my outputChatBox. but i cant find a way of doing it in the same function. im bad at explaining so sorry if this make no sence New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
Tete omar Posted December 12, 2012 Posted December 12, 2012 Oh you meant the object following the ped , but lately?
Greenie0101 Posted December 12, 2012 Author Posted December 12, 2012 dont worry ill find a way around it. thanks for trying to help though New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
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