Jump to content

setTime for everybody


Recommended Posts

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
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 by #_iMr.[E]coo
Link to comment

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 by Avagard
Link to comment

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 by pa3ck
Link to comment

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 by Avagard
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...