Zcraks Posted June 26, 2019 Share Posted June 26, 2019 Hi. How to make a limit on jobs? If 10 places and 10 players work, then you will be told that "There are no places". Link to comment
Moderators IIYAMA Posted June 26, 2019 Moderators Share Posted June 26, 2019 local playersInJobs = { ["job-name"] = {} } table.insert(playersInJobs["job-name"], player) if #playersInJobs["job-name"] == 10 then end 1 Link to comment
Zcraks Posted June 28, 2019 Author Share Posted June 28, 2019 On 26/06/2019 at 10:01, IIYAMA said: local playersInJobs = { ["job-name"] = {} } table.insert(playersInJobs["job-name"], player) if #playersInJobs["job-name"] == 10 then end for k, i in ipairs(playersInJobs["job-name"]) do while playersInJobs["job-name"][i] do if i == element then table.remove(playersInJobs["job-name"], i) end end end Why not removed from the table? Link to comment
Rockyz Posted June 28, 2019 Share Posted June 28, 2019 for index = 1, #playersInJobs["job-name"] do if playersInJobs["job-name"][index] == element then table.remove(playersInJobs["job-name"], index) break end end 1 Link to comment
Zcraks Posted June 28, 2019 Author Share Posted June 28, 2019 7 hours ago, #,xiRocKyz said: for index = 1, #playersInJobs["job-name"] do if playersInJobs["job-name"][index] == element then table.remove(playersInJobs["job-name"], index) break end end if #playersInJobs["job-name"] <= 9 and #playersInTurn["job-name"] ~= nil then for k,i in ipairs(playersInTurn["job-name"]) do player = getPlayerFromNick (playersInTurn["job-name"][i]) if player ~= false then outputChatBox ("Go to job !", player) end end end How to make sure that when a place becomes available, it notifies the first player in the queue ? Link to comment
SycroX Posted June 28, 2019 Share Posted June 28, 2019 1 hour ago, Zcraks said: if #playersInJobs["job-name"] <= 9 and #playersInTurn["job-name"] ~= nil then for k,i in ipairs(playersInTurn["job-name"]) do player = getPlayerFromNick (playersInTurn["job-name"][i]) if player ~= false then outputChatBox ("Go to job !", player) end end end How to make sure that when a place becomes available, it notifies the first player in the queue ? for index = 1, #playersInJobs["job-name"] do if playersInJobs["job-name"][index] == element then table.remove(playersInJobs["job-name"], index) if playersInJobs["job-name"][1] and isElement ( playersInJobs["job-name"][1] ) then outputChatBox ( "NOTIFICATION : Go to the job" , playersInJobs["job-name"][1] ) end break end end 1 Link to comment
Zcraks Posted June 29, 2019 Author Share Posted June 29, 2019 On 28/06/2019 at 15:56, #x1AhMeD-09 said: for index = 1, #playersInJobs["job-name"] do if playersInJobs["job-name"][index] == element then table.remove(playersInJobs["job-name"], index) if playersInJobs["job-name"][1] and isElement ( playersInJobs["job-name"][1] ) then outputChatBox ( "NOTIFICATION : Go to the job" , playersInJobs["job-name"][1] ) end break end end while playersInJobs["Job"] == 10 do while playersInTurn["Job"] == 0 do if playersInTurn["Job"][1] and isElement ( playersInTurn["Job"][1] ) then outputChatBox ( "Go to the job" , playersInTurn["Job"][1] ) one = (playersInTurn["lawn"][1]) timer = setTimer(function (one) table.remove(playersInTurn["lawn"], one) outputChatBox("Time is out", one) end, 20000, 1) break end end end How to make it work? Link to comment
SycroX Posted June 29, 2019 Share Posted June 29, 2019 (edited) local Timers = {} while playersInJobs["Job"] == 10 do while playersInTurn["Job"] == 0 do if playersInTurn["Job"][1] and isElement ( playersInTurn["Job"][1] ) then outputChatBox ( "Go to the job" , playersInTurn["Job"][1] ) local newIndex = #Timers+1 Timers[newIndex] = setTimer ( function ( newIndex ) table.remove(playersInTurn["lawn"], 1) outputChatBox("Time is out", playersInTurn["lawn"][1]) Timers[newIndex] = false end , 20000, 1, newIndex) break end end end Edited June 29, 2019 by #x1AhMeD-09 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