pa3ck Posted May 5, 2017 Share Posted May 5, 2017 22 minutes ago, DNL291 said: Will not that method in pratice trigger for each player? Since client unlike server side executes for a specific player. If using a table of player elements it works, can you explain me how the MTA internally will execute this function using a table on 'sendTo' argument? Of course MTA has to do some sort of looping, but I'm pretty sure he wasn't asking about that, he was asking about the LUA part, where no loop is needed. Link to comment
DNL291 Posted May 5, 2017 Share Posted May 5, 2017 Sometimes people asking for help with scripts don't have much knowledge about Lua, so it's natural for them to use wrong methods. If you're helping them, and you know the right way to do, then why are you going to do what they want? That will make it harder for yourself to help people. Ontopic: Why he will want it without loop if it will be the same thing as with loop - will only change in code, but will do the same thing when Lua executes it. So obviously the question is about performance as well. Link to comment
pa3ck Posted May 5, 2017 Share Posted May 5, 2017 He came here asking if he can trigger to multiple players without loop, you said no, I said yes, he can. That's my perspective, but you're right, it's just a performance question, if looping through a table of players and triggering in LUA is the same as looping through the table in MTA's environment would be the same, they wouldn't have implemented the option to trigger with a table in the first place, in my honest opinion, but anyway, I think his problem has been solved. 1 Link to comment
Avagard Posted May 6, 2017 Author Share Posted May 6, 2017 (edited) just a question pa3ck doesn't this code do as your code? if not what is the problem? cttime1 = setTimer( function() local players = getPlayersInTeam ( CT ) for playerKey, playerValue in ipairs ( players ) do if getElementDimension ( playerValue ) == 0 then if getElementData ( playerValue , "alive" ) == true then triggerClientEvent ("TimeEndRestartCT1",playerValue) end end end end, 129000, 0) its not that your code is not working... it works perfectly, but i want to know what is wrong with this one Edited May 6, 2017 by Avagard Link to comment
pa3ck Posted May 6, 2017 Share Posted May 6, 2017 Nothing, there's nothing wrong with that one, I just think it's better to let MTA's code do the looping with the table being passed to the function rather than the LUA loop. 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