Avagard Posted May 2, 2017 Share Posted May 2, 2017 hello.. i want the time to be the same for every body will this work? (i haven't tested because no players ) it is client btw i putted it client because the function (ifalldeadtime1) only works on client function setTimerForALL() local players = getElementsByType ( "player" ) for theKey,thePlayers in ipairs ( players ) do cttime1 = setTimer (ifalldeadTime1,12900,0) end end Link to comment
LoveFist Posted May 3, 2017 Share Posted May 3, 2017 setTime is a shared function. If you call it serverside it will change time for all players. More info at wiki - https://wiki.multitheftauto.com/wiki/SetTime Link to comment
NeXuS™ Posted May 3, 2017 Share Posted May 3, 2017 (edited) @LoveFist, he just did a typo, it's the setTimer function, and he'll need it on client side For the answer @Avagard. You can use addEvent, addEventhandler and the do triggerClientEvent. If you do this way, you can use setTimer on serverside. Edited May 3, 2017 by NeXuS™ Link to comment
^iiEcoo'x_) Posted May 3, 2017 Share Posted May 3, 2017 (edited) function setTimerAll_ ( ) triggerServerEvent ( 'aTimer_' , localPlayer ) end addEvent ( 'Accepted_' , true ) addEventHandler ( 'Accepted_' , root , function ( ) ifalldeadtime1 ( ) end ) addEvent ( 'aTimer_' , true ) addEventHandler ( 'aTimer_' , root , function ( ) aTimer_ = setTimer ( function ( ) triggerClientEvent ( root , 'Accepted_' , root ) end , 12900 , 0 ) end ) Edited May 3, 2017 by #_iMr.[E]coo Link to comment
Avagard Posted May 3, 2017 Author Share Posted May 3, 2017 (edited) thank you ecoo but i have a question. for example if i have 30 players in my server will in this code it will set "roundswonbyct1" 30 times and will it trigger 30 times???? here is the code(serverSide): cttime1 = setTimer( function() local getCTscore1 = getElementData(scoreCT1,"roundswonbyct1") local getTscore1 = getElementData(scoreT1,"roundswonbyt1") local players = getElementsByType ( "player" ) for theKey,thePlayers in ipairs ( players ) do local playerTeamCT1 = getTeamName(getPlayerTeam(thePlayers)) if getElementDimension ( thePlayers ) == 0 then if ( playerTeamCT1 ) == "Counter Terrorist" then if getElementData ( thePlayers , "alive" ) == true then setElementData(scoreCT1,"roundswonbyct1",getElementData(scoreCT1,"roundswonbyct1")+1) triggerClientEvent ( thePlayers, "getitServer1",thePlayers, getCTscore1,getTscore1) triggerClientEvent (thePlayers, "TimeEndRestartCT1",thePlayers) end end end end end, 129000, 0) if yes.. then i don`t want that i just want to check if players in terrorist team are alive!!! please tell me how to fix that IF YES and also please explain if not, then tell me its okay ty Edited May 3, 2017 by Avagard Link to comment
pa3ck Posted May 5, 2017 Share Posted May 5, 2017 (edited) You don't need a timer for every player to check if they're alive. What I would do is create a table server side and have an "onPlayerWasted" (not sure about the correct event name now) and put the players in the "deadPlayers = {}" table and remove them at the "onPlayerSpawn" event. If you need it client-side as well, using element data would be better. Edited May 5, 2017 by pa3ck Link to comment
Avagard Posted May 5, 2017 Author Share Posted May 5, 2017 (edited) thanks for the answer but, that is not what i wanted to do... i want to trigger it if for example, CT player is alive and T play is alive when time ends it triggers for them Edited May 5, 2017 by Avagard 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