LabiVila Posted September 15, 2015 Share Posted September 15, 2015 local players = {} function onjoin () table.insert (players, source) setTimer ( function () for k,v in ipairs (players) do if (v == source) then table.remove (players, k) end end triggerClientEvent ("handler", getRootElement(), players) end, 5000, 1 ) triggerClientEvent ("handler", getRootElement(), players) end addEventHandler ("onPlayerJoin", getRootElement(), onjoin) function handler (players) addEventHandler ("onClientRender", getRootElement(), function () for i,v in ipairs (players) do dxDrawText (i.." "..getPlayerName (v), 200, 200 + (i * 21)) end end ) end addEvent ("handler", true) addEventHandler ("handler", getRootElement(), handler) so, 5 seconds after joining, the text should dissapear, but it is not dissapearing, it is most likely table.remove that isn't working, can I have some help? Link to comment
LabiVila Posted September 15, 2015 Author Share Posted September 15, 2015 Yes, if I keep 'debugging it', at 'if (v == source)' gives an error Link to comment
KariiiM Posted September 15, 2015 Share Posted September 15, 2015 (edited) Yes, if I keep 'debugging it', at 'if (v == source)' gives an error What the error say? Edited September 15, 2015 by Guest Link to comment
LabiVila Posted September 15, 2015 Author Share Posted September 15, 2015 Nevermind, got it done, thank you anyway Link to comment
Tomas Posted September 15, 2015 Share Posted September 15, 2015 setTimer has its own 'source' predefined variable, you must pass it as an argument, setTimer ( function (player) for k,v in ipairs (players) do if (v == player) then table.remove (players, k) end end triggerClientEvent ("handler", getRootElement(), players) end, 5000, 1, source ) Link to comment
JR10 Posted September 16, 2015 Share Posted September 16, 2015 You should break after removing the player, so it doesn't uselessly loop through the rest of the table. setTimer ( function (player) for k,v in ipairs (players) do if (v == player) then table.remove (players, k) break end end triggerClientEvent ("handler", resourceRoot, players) end, 5000, 1, source ) 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