Jump to content

Set timer


Crow

Recommended Posts

Hi guys i need put set timer for automatic restar resource. But i dont know how

this is the script that i need put auto-reset
 

Spoiler

 

local MainT = {} -- main table for important elements
local m1 = createMarker(2495.6821289063,-1686.439453125,12.515347480774,"cylinder",2,0,150,20,200)
local MissionTeam = createTeam("MissionTeam",0,200,20)
local ZombieTeam = createTeam("ZombieMission",200,0,20)
local ZomniesTable = {172,173,174,175,176}
MainT.ZombieKill = 0


function MissonHit1Marker(E)
if (E) and getElementType(E) == "player" then
 triggerClientEvent(E,"seeGuiMisson",E)
end
end
addEventHandler("onMarkerHit",m1,MissonHit1Marker)
 
addEvent("ClickButtonsServer",true)
addEventHandler("ClickButtonsServer",root,
function(text)
if (text == "Start") then
triggerClientEvent(source,"seeGuiMisson",source)
destroyElement(m1)
MainT.Player = source
MissionPart1()
setPlayerTeam(MainT.Player,MissionTeam)
addEventHandler("onPlayerWasted",MainT.Player,PlayerWasted)
elseif(text == "Closed") then
triggerClientEvent(source,"seeGuiMisson",source)
end
end)
 
function MissionPart1()
MainT.Suvivor = exports [ "slothBot" ]:spawnBot(2201.696, -1172.902, 1029.797,90,1,15,0,MissionTeam,24,"hunting")
blipPP = createBlipAttachedTo(MainT.Suvivor,52,2)
outputChatBox("Go to the MOTEL and Save Maria",MainT.Player)
setTimer(function()for i=1,12 do
i = exports [ "slothBot" ]:spawnBot( 2217.0888671875+math.random(-2,2),-1188.4528808594+math.random(-2,2),1029.796875,90,ZomniesTable[math.random(1,#ZomniesTable)],15,0,ZombieTeam,0,"chasing",MainT.Suvivor)
setElementData(i,"ZombieMission",true)end end,1200,1)
end

 
addEventHandler("onPedWasted",root,
 function()
if getElementData(source,"ZombieMission") then
MainT.ZombieKill = MainT.ZombieKill+1
end
if (MainT.ZombieKill == 12) then
 MissionPart2()
 MainT.ZombieKill = nil
end
if (source == MainT.Suvivor) then
outputChatBox("Survivor killed, Mission Failed",MainT.Player)
local Res = getResourceFromName("MissionSurvivor")
destroyElement(blipPP)
stopResource(Res)
for k,v in ipairs(getElementsByType("ped"))
do
if getElementData(v,"ZombieMission") then
destroyElement(v)
end
end
end
end
)
 
function MissionPart2()
exports [ "slothBot" ]:setBotFollow(MainT.Suvivor,MainT.Player)
MainT.Heli = createVehicle(521,2223.9177246094,-1159.9803466797,25.740327835083)
outputChatBox("Go to FCR-900",MainT.Player)
addEventHandler("onVehicleEnter",MainT.Heli,MissionPart3)
end
 
function MissionPart3(p,seat)
if (p == MainT.Player) then
if(seat == 0) then
MainT.Blip2=createBlip(-2464.6298828125,2251.3701171875,4.787636756897)
MainT.Marker2=createMarker(-2464.6298828125,2251.3701171875,4.787636756897,"cylinder",2,0,150,20,200)
warpPedIntoVehicle(MainT.Suvivor,source,1)
addEventHandler("onMarkerHit",MainT.Marker2,MissionPart4)
end
end
end
 
function MissionPart4(E)
if (E == MainT.Player) or (E == MainT.Heli) then
local p = getVehicleController(MainT.Heli) or MainT.Player
givePlayerMoney(p,30000)
outputChatBox("Mission 1 Complete go for Mission 2 ",p)
destroyElement(MainT.Heli)
destroyElement(blipPP)
MainT.Heli = nil
destroyElement(MainT.Suvivor)
MainT.Suvivor = nil
destroyElement(MainT.Blip2)
MainT.Blip2 = nil
destroyElement(MainT.Marker2)
MainT.Marker2 = nil
end
end
 
function PlayerWasted()
if (source == MainT.Player) then
outputChatBox("You die, Mission Failed",MainT.Player)
local Res = getResourceFromName("MissionSurvivor")
stopResource(Res)
destroyElement(blipPP)
for k,v in ipairs(getElementsByType("ped"))
do
if getElementData(v,"ZombieMission") then
destroyElement(v)

end
end
end
end

 

how i can put set timer for the script auto reset. A guy tell me i need put a " set timer "

Link to comment
local MainT = {} -- main table for important elements
local m1 = createMarker(2495.6821289063,-1686.439453125,12.515347480774,"cylinder",2,0,150,20,200)
local MissionTeam = createTeam("MissionTeam",0,200,20)
local ZombieTeam = createTeam("ZombieMission",200,0,20)
local ZomniesTable = {172,173,174,175,176}
MainT.ZombieKill = 0

local aMissionJoin_ = false

function aOpenMission_ ( )
  setTimer ( function ( )
      outputChatBox ( ' Mission Open ' , root )
      aMissionJoin_ = true
    end , 1000 * 60 * 2^2 , 1 )
end 

aOpenMission_ ( )

function MissonHit1Marker(E)
if (E) and getElementType(E) == "player" then
          if aMissionJoin_ == false then return outputChatBox ( ' Mission Closed ' , E ) end
 triggerClientEvent(E,"seeGuiMisson",E)
end
end
addEventHandler("onMarkerHit",m1,MissonHit1Marker)
 
addEvent("ClickButtonsServer",true)
addEventHandler("ClickButtonsServer",root,
function(text)
if (text == "Start") then
triggerClientEvent(source,"seeGuiMisson",source)
destroyElement(m1)
MainT.Player = source
MissionPart1()
setPlayerTeam(MainT.Player,MissionTeam)
addEventHandler("onPlayerWasted",MainT.Player,PlayerWasted)
elseif(text == "Closed") then
triggerClientEvent(source,"seeGuiMisson",source)
end
end)
 
function MissionPart1()
MainT.Suvivor = exports [ "slothBot" ]:spawnBot(2201.696, -1172.902, 1029.797,90,1,15,0,MissionTeam,24,"hunting")
blipPP = createBlipAttachedTo(MainT.Suvivor,52,2)
outputChatBox("Go to the MOTEL and Save Maria",MainT.Player)
setTimer(function()for i=1,12 do
i = exports [ "slothBot" ]:spawnBot( 2217.0888671875+math.random(-2,2),-1188.4528808594+math.random(-2,2),1029.796875,90,ZomniesTable[math.random(1,#ZomniesTable)],15,0,ZombieTeam,0,"chasing",MainT.Suvivor)
setElementData(i,"ZombieMission",true)end end,1200,1)
end

 
addEventHandler("onPedWasted",root,
 function()
if getElementData(source,"ZombieMission") then
MainT.ZombieKill = MainT.ZombieKill+1
end
if (MainT.ZombieKill == 12) then
 MissionPart2()
 MainT.ZombieKill = nil
end
if (source == MainT.Suvivor) then
outputChatBox("Survivor killed, Mission Failed",MainT.Player)
local Res = getResourceFromName("MissionSurvivor")
destroyElement(blipPP)
stopResource(Res)
for k,v in ipairs(getElementsByType("ped"))
do
if getElementData(v,"ZombieMission") then
destroyElement(v)
end
end
end
end
)
 
function MissionPart2()
exports [ "slothBot" ]:setBotFollow(MainT.Suvivor,MainT.Player)
MainT.Heli = createVehicle(521,2223.9177246094,-1159.9803466797,25.740327835083)
outputChatBox("Go to FCR-900",MainT.Player)
addEventHandler("onVehicleEnter",MainT.Heli,MissionPart3)
end
 
function MissionPart3(p,seat)
if (p == MainT.Player) then
if(seat == 0) then
MainT.Blip2=createBlip(-2464.6298828125,2251.3701171875,4.787636756897)
MainT.Marker2=createMarker(-2464.6298828125,2251.3701171875,4.787636756897,"cylinder",2,0,150,20,200)
warpPedIntoVehicle(MainT.Suvivor,source,1)
addEventHandler("onMarkerHit",MainT.Marker2,MissionPart4)
end
end
end
 
function MissionPart4(E)
if (E == MainT.Player) or (E == MainT.Heli) then
local p = getVehicleController(MainT.Heli) or MainT.Player
givePlayerMoney(p,30000)
outputChatBox("Mission 1 Complete go for Mission 2 ",p)
destroyElement(MainT.Heli)
destroyElement(blipPP)
MainT.Heli = nil
destroyElement(MainT.Suvivor)
MainT.Suvivor = nil
destroyElement(MainT.Blip2)
MainT.Blip2 = nil
destroyElement(MainT.Marker2)
MainT.Marker2 = nil
end
end
 
function PlayerWasted()
if (source == MainT.Player) then
outputChatBox("You die, Mission Failed",MainT.Player)
local Res = getResourceFromName("MissionSurvivor")
stopResource(Res)
destroyElement(blipPP)
for k,v in ipairs(getElementsByType("ped"))
do
if getElementData(v,"ZombieMission") then
destroyElement(v)

end
end
end
end

 

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