Greenie0101 Posted June 13, 2012 Share Posted June 13, 2012 I made this script from scratch and it works fine for 10 or so seconds then starts to lag and crash the server. function traingo() setTrainSpeed(myTrain, -0.5) -- Speed up setTrainSpeed(car1, -0.5) -- Speed up setTrainSpeed(car2, -0.5) -- Speed up setTrainSpeed(car3, -0.5) -- Speed up setTrainSpeed(car4, -0.5) -- Speed up local timer = setTimer (traingo, 1000, 0) end addCommandHandler("go",traingo) Whats wrong? (there is more to it but that part works fine) I type /go and the train goes fine I stand on the back and it works fine 10 secs later it lags heaps and i have to restart the server Link to comment
Kenix Posted June 13, 2012 Share Posted June 13, 2012 It's seems like recursion. When you type cmd it's make 1 infinite timer. When this timer reached ( 1 sec ) this make next infinite timer and etc. In your case you use not infinite timer. ( just 1 sec ). pTimer = setTimer ( traingo, 1000, 1 ) Also i think you not needed use timer local because you need destroy. Link to comment
Greenie0101 Posted June 13, 2012 Author Share Posted June 13, 2012 thanks mate that worked. Whats different between timer and ptimer? Link to comment
myonlake Posted June 13, 2012 Share Posted June 13, 2012 thanks mate that worked. Whats different between timer and ptimer? No difference. He only just removed the 'local' there. Link to comment
Greenie0101 Posted June 13, 2012 Author Share Posted June 13, 2012 That's odd cos I had it without a local before and I didn't work so I tried adding a local to fix it.o well I hav another problem with it now. When I get other people on it the individual carriages begin to break up. Gaps form in the train and some carriges disappear or lose their physical part so you fall throug the floor of them. Link to comment
myonlake Posted June 13, 2012 Share Posted June 13, 2012 Blame Multi Theft Auto for that. You could use attachElements -function. attachElements Link to comment
Greenie0101 Posted June 14, 2012 Author Share Posted June 14, 2012 but then the whole train would be straight all the time, I'm using attach elements to attach boxes and stuff to the train Link to comment
Moderators IIYAMA Posted June 14, 2012 Moderators Share Posted June 14, 2012 he may can play a little with the offset, but I think that will be laggy. 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