Mario222 Posted October 9, 2021 Share Posted October 9, 2021 I wanna kill a last survivor in DD or Fun maps before when is the last survivor like 2 seconds after but i don't know how to do it. Link to comment
The_GTA Posted October 9, 2021 Share Posted October 9, 2021 4 hours ago, Mario222 said: I wanna kill a last survivor in DD or Fun maps before when is the last survivor like 2 seconds after but i don't know how to do it. Maybe something like this? local is_mode_running = false; local kill_last_timer = false; addEventHandler("onGamemodeMapStart", root, function(startedMap) -- Clean up from previous runtime. if (kill_last_timer) then killTimer(kill_last_timer); kill_last_timer = false; end is_mode_running = true; outputChatBox("started mode!"); end ); local function on_mode_end() outputChatBox("end of mode!"); end local function on_last_survivor(survivor) kill_last_timer = setTimer( function() killPed( survivor ); kill_last_timer = false; end, 2000, 1 ); end addEventHandler("onPlayerWasted", root, function() local alivePlayers = getAlivePlayers(); if (is_mode_running) and (#alivePlayers <= 1) then is_mode_running = false; on_mode_end(); if (#alivePlayers == 1) then on_last_survivor(alivePlayers[1]); end end end ); 1 Link to comment
Mario222 Posted October 9, 2021 Author Share Posted October 9, 2021 5 hours ago, The_GTA said: Maybe something like this? local is_mode_running = false; local kill_last_timer = false; addEventHandler("onGamemodeMapStart", root, function(startedMap) -- Clean up from previous runtime. if (kill_last_timer) then killTimer(kill_last_timer); kill_last_timer = false; end is_mode_running = true; outputChatBox("started mode!"); end ); local function on_mode_end() outputChatBox("end of mode!"); end local function on_last_survivor(survivor) kill_last_timer = setTimer( function() killPed( survivor ); kill_last_timer = false; end, 2000, 1 ); end addEventHandler("onPlayerWasted", root, function() local alivePlayers = getAlivePlayers(); if (is_mode_running) and (#alivePlayers <= 1) then is_mode_running = false; on_mode_end(); if (#alivePlayers == 1) then on_last_survivor(alivePlayers[1]); end end end ); Oh thankyou very much! 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