Bean666 Posted February 7, 2021 Share Posted February 7, 2021 local locations = { {-1506.498046875, 2536.84765625, 55.888042449951,-1505.80859375, 2566.9189453125, 55.8359375,-1490.5693359375, 2649.619140625, 55.8359375,-1517.75390625, 2668.05859375, 55.6875, 20000}, {-1608.9736328125, 2452.9296875, 68.308662414551,-1582.5891113281, 2494.0854492188, 69.000640869141,-1582.5891113281, 2494.0854492188, 69.000640869141,-1576.248046875, 2503.6533203125, 69.123001098633, 20000}, {-1608.9736328125, 2452.9296875, 68.308662414551,-1582.5891113281, 2494.0854492188, 69.000640869141,-1582.5891113281, 2494.0854492188, 69.000640869141,-1576.248046875, 2503.6533203125, 69.123001098633, 20000} } function startlogin() drawall() showPlayerHudComponent ( "radar", false ) loc = math.random(#locations) smoothMoveCamera( locations[loc][1], locations[loc][2], locations[loc][3], locations[loc][4], locations[loc][5], locations[loc][6], locations[loc][7], locations[loc][8], locations[loc][9], locations[loc][10], locations[loc][11], locations[loc][12], locations[loc][13]) cameratimer = setTimer(function() loc = math.random(#locations) smoothMoveCamera( locations[loc][1], locations[loc][2], locations[loc][3], locations[loc][4], locations[loc][5], locations[loc][6], locations[loc][7], locations[loc][8], locations[loc][9], locations[loc][10], locations[loc][11], locations[loc][12], locations[loc][13]) end, 21000, 0) theme = playSound("sounds/theme.mp3", true) setSoundVolume(theme, 1.0) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startlogin) so I made a table of locations for the smoothmovecamera, locations are random but sometimes it repeats, how to make it not repeat despite the locations being random? it's the hard way, the easy way is just to make the sequence in order(this seems like the easiest choice) but if possible i'd like them all random but not repeating but it seems hard. Link to comment
Moderators IIYAMA Posted February 7, 2021 Moderators Share Posted February 7, 2021 local loc_ if #locations > 1 then repeat loc_ = math.random(#locations) until loc_ ~= loc else loc_ = locations[1] end loc = loc_ To not repeat, you need to repeat . Link to comment
Bean666 Posted February 7, 2021 Author Share Posted February 7, 2021 1 hour ago, IIYAMA said: local loc_ if #locations > 1 then repeat loc_ = math.random(#locations) until loc_ ~= loc else loc_ = locations[1] end loc = loc_ To not repeat, you need to repeat . once again, thank you so much. 1 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