Bean666 Posted April 26, 2016 Share Posted April 26, 2016 (edited) a player goes into the marker first and completes the mission first, he gets the money, marker disappears. players that were late in the marker didnt get the money when the marker disappears. i want a timer that if the first player goes in, it will be in progress. and even other players are late, if the timer times up, marker disappears. they all get the reward. i want all players that were within the marker will get the reward at the same time. help me please. local timeTable = {}; local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 70); local isMarerHidden = false; addEventHandler("onMarkerHit", marker, function(player) if isPedInVehicle(player) then return; end if (isMarerHidden == true) then return; end if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Stay in the marker! do not leave it or you will not get the money", player, 255, 0, 0); timeTable[player] = setTimer(function() outputChatBox("Robbery Success! Robbery will be available again in 5 minutes", player, 0, 255, 0); givePlayerMoney(player, 30000); setElementAlpha(marker, 0); isMarerHidden = true; for _,v in ipairs(getElementsByType("player")) do if isTimer(timeTable[v]) then killTimer(timeTable[v]); end end setTimer(function() setElementAlpha(marker, 70); isMarerHidden = false; end, 300000, 1); end, 180000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Edited April 27, 2016 by Guest Link to comment
KariiiM Posted April 26, 2016 Share Posted April 26, 2016 local timeTable = {}; local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); local isMarerHidden = false; addEventHandler("onMarkerHit", marker, function(player) if (not isElement(player) or getElementType(player) ~= "player") then return end if isPedInVehicle(player) then return; end if (isMarerHidden == true) then return; end if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(function() givePlayerMoney(player, 5000); setElementAlpha(marker, 0); isMarerHidden = true; setTimer(function() setElementAlpha(marker, 100); isMarerHidden = false; end, 60000, 1); end, 5000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 Btw nvm that i have a new one: a player goes into the marker first and completes the mission first, he gets the money, marker disappears. players that were late in the marker didnt get the money when the marker disappears. i want a timer that if the first player goes in, it will be in progress. and even other players are late, if the timer times up, marker disappears. they all get the reward. i want all players that were within the marker will get the reward at the same time. help me please. local timeTable = {}; local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 70); local isMarerHidden = false; addEventHandler("onMarkerHit", marker, function(player) if isPedInVehicle(player) then return; end if (isMarerHidden == true) then return; end if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Stay in the marker! do not leave it or you will not get the money", player, 255, 0, 0); timeTable[player] = setTimer(function() outputChatBox("Robbery Success! Robbery will be available again in 5 minutes", player, 0, 255, 0); givePlayerMoney(player, 30000); setElementAlpha(marker, 0); isMarerHidden = true; for _,v in ipairs(getElementsByType("player")) do if isTimer(timeTable[v]) then killTimer(timeTable[v]); end end setTimer(function() setElementAlpha(marker, 70); isMarerHidden = false; end, 300000, 1); end, 180000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Link to comment
Bean666 Posted April 27, 2016 Author Share Posted April 27, 2016 will this work? local timeTable = {}; local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); local isMarerHidden = false; addEventHandler("onMarkerHit", marker, function(player) if isPedInVehicle(player) then return; end if (isMarerHidden == true) then return; end if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(function() isElementWithinMarker(player, marker) givePlayerMoney(player, 5000); setElementAlpha(marker, 0); isMarerHidden = true; setTimer(function() setElementAlpha(marker, 100); isMarerHidden = false; end, 60000, 1); end, 5000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; isElementWithinMarker(player, marker) end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Link to comment
Tekken Posted April 27, 2016 Share Posted April 27, 2016 I said I will not do it, but there you go: local timeTable = {}; local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); local isMarerHidden = false; addEventHandler("onMarkerHit", marker, function(player) if isPedInVehicle(player) then return; end if (isMarerHidden == true) then return; end if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(function() for _,v in ipairs(getElementsByType("player")) do if isElementWithinMarker(v, marker) then givePlayerMoney(v, 5000); end destroyTimer(v); end setElementAlpha(marker, 0); isMarerHidden = true; setTimer(function() setElementAlpha(marker, 100); isMarerHidden = false; end, 60000, 1); end, 5000, 1); end end); function destroyTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() destroyTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() destroyTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) destroyTimer(player); end); Link to comment
Bean666 Posted April 27, 2016 Author Share Posted April 27, 2016 sorry for being a bother to you. and btw .... thanks... Link to comment
Tekken Posted April 27, 2016 Share Posted April 27, 2016 sorry for being a bother to you. and btw .... thanks... You do not bother me I just want you to learn, try harder by yourself, I actually like to make those scripts for you. 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