glowdemon1 Posted September 1, 2013 Share Posted September 1, 2013 Hi, I haven't noticed a command that allows you to pause your script for a second, I'm basicly creating a vehicle, but then I NEED to implement something that it waits 1 second after that, after that one second it does setElementFrozen. function bikeShop() lowriderBike = createVehicle(509, 698.6, -521.20, 16,0,0,90) os.sleep(1) -- ??? setElementFrozen(lowriderBike, true) end Link to comment
glowdemon1 Posted September 1, 2013 Author Share Posted September 1, 2013 setTimer Yeah, I was thinking of something easier, more compact that only requires one line, like wait() or sleep(). Well anyhow I dedicated a new function to this timer and it works now,but I was hoping there would be a more compact thing. Link to comment
50p Posted September 1, 2013 Share Posted September 1, 2013 There are coroutines but they are more complex than timers. Link to comment
glowdemon1 Posted September 1, 2013 Author Share Posted September 1, 2013 Mh, well I've struck on yet another problem, whenever I try to lock certain vehicles upon spawning, it just doesn't lock them, here's teh code : function freezeElements() setElementFrozen(lowriderBike,true) setElementFrozen(bmxBike, true) setElementFrozen(mountainbikeBike,true) end function bikeShop() lowriderBike = createVehicle(509, 698.6, -521.20, 16,0,0,225) setVehicleLocked(lowriderBike, true) bmxBike = createVehicle(481, 695.6, -521.20, 16,0,0,225) setVehicleLocked(bmxBike,true) mountainbikeBike = createVehicle(510, 692.6, -521.20, 16,0,0,225) setVehicleLocked(mountainbikeBike,true) end setTimer(freezeElements,90,1) addEventHandler("onResourceStart", getRootElement(), bikeShop) Its kind of messy indeed, but I'm not the best coder, heh. Link to comment
glowdemon1 Posted September 1, 2013 Author Share Posted September 1, 2013 Alright so, aparently : notLockableVehicles = {594, 606, 607, 611, 584, 608, 435, 450, 591, 539, 441, 464, 501, 465, 564, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 581, 509, 481, 462, 521, 463, 510, 522, 461, 448, 468, 586, 425, 520} I guess I'll have to make it so that the script restarts each couple of minutes, would while true do setTimer(bikeShop,900000,1)-- executes bikeShop once each fifteen minutes end work ? Link to comment
BieHDC Posted September 1, 2013 Share Posted September 1, 2013 Try this: edit: is this serverside? if its serverside you can prevent entering the vehicle with OnVehicleStartEnter and CancelEvent "https://wiki.multitheftauto.com/wiki/OnVehicleStartEnter" function bikeShop() lowriderBike = createVehicle(509, 698.6, -521.20, 16,0,0,225) setElementFrozen(lowriderBike,true) bmxBike = createVehicle(481, 695.6, -521.20, 16,0,0,225) setElementFrozen(bmxBike, true) mountainbikeBike = createVehicle(510, 692.6, -521.20, 16,0,0,225) setElementFrozen(mountainbikeBike,true) end addEventHandler("onResourceStart", getRootElement(), bikeShop) Link to comment
glowdemon1 Posted September 1, 2013 Author Share Posted September 1, 2013 Alright, I'll try that. But would the scrip I said work ? I need reload the bikeshop every 15 minutes Link to comment
BieHDC Posted September 1, 2013 Share Posted September 1, 2013 why the bikeshop schould reload every 15 min? Link to comment
glowdemon1 Posted September 1, 2013 Author Share Posted September 1, 2013 Incase anything gets bugged, rather take some precauting stuff. Link to comment
csiguusz Posted September 1, 2013 Share Posted September 1, 2013 while true do setTimer(bikeShop,900000,1)-- executes bikeShop once each fifteen minutes end work ? No, it won't work, it doesn't mean what you tought it means. For infinite repetitions use 0 as the last argument. Link to comment
Moderators IIYAMA Posted September 1, 2013 Moderators Share Posted September 1, 2013 I guess I'll have to make it so that the script restarts each couple of minutes, would while true do setTimer(bikeShop,900000,1)-- executes bikeShop once each fifteen minutes end work ? Lol lol lol, how many timers are you willing to make? local vehicleShopTable = {} local shopResetTimer -- functions -- local shopResetFunction --------------- addEventHandler("onResourceStart",resourceRoot, function () vehicleShopTable[#vehicleShopTable+1] = createVehicle(509, 698.6, -521.20, 16,0,0,225) vehicleShopTable[#vehicleShopTable+1] = createVehicle(481, 695.6, -521.20, 16,0,0,225) vehicleShopTable[#vehicleShopTable+1] = createVehicle(510, 692.6, -521.20, 16,0,0,225) shopResetTimer = setTimer (shopResetFunction ,900000,0) end) shopResetFunction = function () for i=1, #vehicleShopTable do respawnVehicle ( vehicleShopTable[i] ) end end 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