Jump to content

Freeze after countdown


h4x7o0r

Recommended Posts

Hey there , i need your help guys.

Considering there are two team and a global rule : no more than 2 players alive.

how can i set all players from vehicles frozen after countdown ends, (if there are more than 2 players alive for e.g) until some of alive players will press a key so after round starts they will be killed. I'll give u an example so i will make things clearer.

Example:

Rule: no more than 2 players alive.

Team1 has 3 players

Team2 has 4 players

Round starts: All players are frozen until 1 player from team1 and 2 players from team2 will press a key. After that, players that pressed "the key" will be killed and round will continue with equal number of alive players from each team.

Thanks a lot for your time reading this

and waiting for your help.

Link to comment

Thanks for your reply. Actually i tried to make something, tried so many changes but without any luck

Here's what i've tried already :

  
-- client-side 
   function onClientRaceStateChanging ( newStateName, oldStateName) 
        if newStateName == "GridCountdown" then 
           triggerServerEvent ( "test", getRootElement(), thePlayer) 
        end 
    end 
    addEvent( "onPlayersReady", true ) 
    addEventHandler( "onPlayersReady", getRootElement(), onClientRaceStateChanging ) 
  

  
-- serverside 
  
    addEvent ("test", true) 
    addEventHandler("onPlayerReady", getRootElement(), 
    function test ( thePlayer)  
    local connectedPlayers = getElementsByType ( "player" ) 
    for i, aPlayer in ipairs(connectedPlayers) do 
    bindKey ( aPlayer, "r", "down", "Toggle freeze status", toggleFreezeStatus ) 
    end 
    end ) 
     
function toggleFreezeStatus ( thePlayer ) 
    if getPedOccupiedVehicle ( thePlayer ) then 
        local playerVehicle = getPedOccupiedVehicle ( thePlayer ) 
        local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
        local newFreezeStatus = not currentFreezeStatus 
        setElementFrozen ( playerVehicle, newFreezeStatus ) 
    end 
end 
  

Tried using a toggle for the moment (e.g from wiki) so i can see if things are triggered but no luck.

Link to comment

I once made an AFK Detector.

This is the important part:

afkTimer = setTimer(checkafk, 1000, 0) 
  
function checkafk() 
  
if exports.race:getTimePassed() > (30000) then  -- >0 is what you need I guess 
  --do something 
end 
  
end 

You could make that timer checking every 100 ms or something how much time has passed.

I'm not sure what that functions returns when round didn't start, I guess just 0.

So the worst case is map was running for 100 ms (depending on your Timer) before your players are frozen again.

Link to comment

Thanks for your reply Bons.

Tried clientside this way :

  
        addEventHandler ("onClientMapStarting", root,  
    function() 
if exports.race:getTimePassed() > tonumber(0) then     
   -- ERROR: call : failed to call race:getTimePassed() [string '?'] 
   -- ERROR: attempt to compare a number with a boolean 
  outputChatBox ("Test") 
end 
end  
)  

but anyways, the important part is how can i set all players frozen until some of the team players will press a key?

Thanks in advance.

Link to comment

I guess that function is only available server side.

About this other thing, you could check the alive players in the teams. Some function where u set the max alive players, then it checks onPlayerWasted how many people are still alive in each team.

If its good they get unfrozen.

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...