h4x7o0r Posted February 6, 2014 Share Posted February 6, 2014 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
tosfera Posted February 7, 2014 Share Posted February 7, 2014 Loop trough the elements with the type 'vehicle' with getElementsByType, after that use setElementFrozen. Link to comment
h4x7o0r Posted February 7, 2014 Author Share Posted February 7, 2014 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
Gallardo9944 Posted February 7, 2014 Share Posted February 7, 2014 GridCountdown state is triggered when everyone is ready, so everyone is already frozen. Then, as soon as the round starts, everyone is unfrozen. You need to trigger freezing when the round starts, not when it prepares. Link to comment
h4x7o0r Posted February 7, 2014 Author Share Posted February 7, 2014 I think (there's no event for round starting) so maybe i can use a timer so after 6 secs since countdown started to trigger the server side. The big problem is what happens after that. Link to comment
Bonsai Posted February 8, 2014 Share Posted February 8, 2014 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
h4x7o0r Posted February 8, 2014 Author Share Posted February 8, 2014 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
Bonsai Posted February 8, 2014 Share Posted February 8, 2014 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
h4x7o0r Posted February 13, 2014 Author Share Posted February 13, 2014 onPlayerWasted it's useless because i wanna check balanced teams before round starts. Any other opinions ? 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