Search the Community
Showing results for tags 'timer'.
-
Timer not canceled after player dies. The player dies but does not appear to have left the area. That's why the rockets keep firing. sorry my english bad server g_base_col = createColCuboid(-381.27297973633, 1517.2098388672, -5.718826293945, 1600, 1600, 200.25) g_root = getRootElement () function hit ( pla, dim, hitElement ) if getElementType ( pla ) == "player" then local vehicle = getPedOccupiedVehicle ( pla ) if vehicle or vehicle then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(pla)), aclGetGroup("roket")) then outputChatBox ( "Hoş Geldin Asker!, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) else setElementData ( pla, "inRestrictedArea", "true" ) triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) outputChatBox ( "Askeri Bölge Derhal Uzaklaş!", pla, 255, 0, 0 ) outputChatBox ( "[Uyarı] Roket Saldırısı!", g_root, 255, 0, 0 ) end end end end addEventHandler ( "onColShapeHit", g_base_col, hit ) function leave ( pla, dim ) if getElementType ( pla ) == "player" then local vehicle = getPedOccupiedVehicle ( pla ) if vehicle or vehicle then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(pla)), aclGetGroup("roket")) then outputChatBox ( "İyi Devriyeler Asker!", pla, 0, 100, 0 ) else setElementData ( pla, "inRestrictedArea", "false" ) triggerClientEvent ( pla, "destroyTimers", g_root, pla ) outputChatBox ( "[Uyarı] Roket Saldırısı Durdu!", g_root, 255, 0, 0 ) outputDebugString ( "*"..getPlayerName(pla).." has left col shape" ) end end end end addEventHandler ( "onColShapeLeave", g_base_col, leave ) client g_loc_pla = getLocalPlayer () g_loc_root = getRootElement () addEvent ( "destroyTrepassor", true ) addEventHandler ( "destroyTrepassor", g_loc_root, function () posX = -147.10989379883 posY = 2001.6342773438 posZ = 97.30118560791 posX2 = -135.48461914062 posY2 = 1652.8358154297 posZ2 = 97.30118560791 posX3 = 99.344902038574 posY3 = 2233.484375 posZ3 = 130.27871704102 posX4 = 478.35934448242 posY4 = 2160.7651367188 posZ4 = 97.30118560791 posX5 = 523.74835205078 posY5 = 1976.8087158203 posZ5 = 97.30118560791 posX6 = 448.73950195312 posY6 = 1715.9664306641 posZ6 = 97.30118560791 posX7 = 219.20726013184 posY7 = 1836.5458984375 posZ7 = 97.30118560791 posX8 = 188.45198059082 posY8 = 2081.4970703125 posZ8 = 97.30118560791 local isInResArea = getElementData ( g_loc_pla, "inRestrictedArea" ) rotZ = getPedRotation ( g_loc_pla ) if isInResArea == "true" then timer1 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX, posY, posZ, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer2 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX2, posY2, posZ2, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer3 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX3, posY3, posZ3, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer4 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX4, posY4, posZ4, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer5 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX5, posY5, posZ5, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer6 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX6, posY6, posZ6, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer7 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX7, posY7, posZ7, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) timer8 = setTimer ( createProjectile, 3000, 0, g_loc_pla, 20, posX8, posY8, posZ8, 1.0, g_loc_pla, 0, 0, rotZ, 0.1, 0.1, 0.1 ) end end ) addEvent ( "destroyTimers", true ) addEventHandler ( "destroyTimers", g_loc_root, function () local isInResArea = getElementData ( g_loc_pla, "inRestrictedArea" ) if isInResArea == "false" then killTimer ( timer1 ) killTimer ( timer2 ) killTimer ( timer3 ) killTimer ( timer4 ) killTimer ( timer5 ) killTimer ( timer6 ) killTimer ( timer7 ) killTimer ( timer8 ) end end )
-
Hello, i am trying to make a simple rally stage mod where you create 2 markers, one for start and one for finish, that part is good, but i am trying to make a timer start when you pass the start marker and stop counting when you pass the finish marker, then it should print the time in chat. I started lua scripting today and used a bit of GPT just because all i knew was Java, so basically when i pass the start marker the Stage Started message doesn't show up, so i guess i am not getting the player position correctly maybe? not sure. The only code not inserted here are 3 functions to create the start, the finish and to clear all markers, so i guess is not needed. function checkStageProgress(player) if not startMarker or not finishMarker then return end local startX, startY, startZ = getElementPosition(startMarker) local finishX, finishY, finishZ = getElementPosition(finishMarker) local playerX, playerY, playerZ = getElementPosition(player) local distanceToStart = getDistanceBetweenPoints2D(startX, startY, playerX, playerY) if not raceInProgress and distanceToStart <= 3 then raceInProgress = true startTime = getTickCount() -- Start counting time outputChatBox("Stage started!", player) end if raceInProgress then local elapsedTime = (getTickCount() - startTime) / 1000 outputChatBox("Stage time: " .. elapsedTime .. " seconds.", player) end if raceInProgress and isElementWithinMarker(player, finishMarker) then local elapsedTime = (getTickCount() - startTime) / 1000 outputChatBox("Stage finished! Time: " .. elapsedTime .. " seconds.", player) raceInProgress = false end end
-
------- HK 417 ------- mermi = 500 id = 31 addEvent("m4al",true) addEventHandler("m4al",root,function() if getTickCount() - (tick[source] or 0) >= SECONDS * 864000 then giveWeapon(source,id,mermi) tick[source] = getTickCount() outputChatBox("[!]#ff3300 HK 417 Markalı Silahını Kuşandın.",source,0,255,0,true) else outputChatBox("[!]#ff3300 [1 Haftalık Stok] 4 Saat Sonra Tekrar Alabilirsin.",source,0,255,0,true) end end ) ------- SNIPER ------- mermi3 = 15 id3 = 34 addEvent("sniperal",true) addEventHandler("sniperal",root,function() if getTickCount() - (tick[source] or 0) >= SECONDS * 864000 then giveWeapon(source,id3,mermi3) tick[source] = getTickCount() outputChatBox("[!]#ff3300 Bora 12 Markalı Uzun Namlu'lu Silahını Kuşandın.",source,0,255,0,true) else outputChatBox("[!]#ff3300 [1 Haftalık Stok] 4 Saat Sonra Tekrar Alabilirsin.",source,0,255,0,true) end end ) Hi, I can only use one. When I try to use the other, the timer activates and prevents me from picking up the other weapon. I will be glad if you help
-
السلام عليكم ورحمة الله بركاتة كيف حال الشباب ان شاء اللـه تكونو في أتم الصحة والعافيه استفساري القوي (بنسبة لي ههه) هو كيف اسوي دالة مثل setTimer C++ بال او اذا كان في من الاساس ايش هي
-
Gostaria de adicionar uma contagem no código que estou mexendo da seguinte maneira , quando o jogador da acl POLICIA desse o comando /armas ele receberia armas , mas se ele desse o comando novamente ele so poderia pegar depois de 30 minutos . Consegui fazer isso , mas quando o jogador sai do servidor e ao entrar novamente e realizar o mesmo comando , ele consegue pegar as armas sem ter passado os 30 minutos.
-
Hi guys! Im kindda new at scripting, I ask your help! I want to set a timer what counts somewhere on the screen and when its up then I'll be killed. I also want it to be restarted after respawning. Thank you for your help in advance! :(
-
Hello, I need a marker timer script which starts a timer on screen for that player who hit marker X and stopped when that player hit marker Y. And when that player hits marker X again without hitting marker Y, it restarts/reset timer again. Help me pls.
-
Olá estou tentando fazer para quando o jogador encostar do marker vai desabilita todos os acesso para ele não conseguir se movimenta ai tudo bem, so que depois de colocou um setTimer para que pode voltar os controle do jogador mas está dando esse erro http://prntscr.com/lx94uf e não tenho a menor ideia de como arruma-lo server-side function Start_Bus(marker, md) if isPedInVehicle( source ) then if md then if marker == Rota1_Vermelha then setElementVisibleTo( Rota1_Vermelha, source, false ) setElementVisibleTo( Rota1_Blip, source, false ) setElementVisibleTo( Rota2_Vermelha, source, true ) setElementVisibleTo( Rota2_Blip, source, true ) toggleAllControls ( source, false ) setControlState ( source, "handbrake", true ) setTimer(function() toggleAllControls ( source, true ) setControlState ( source, "handbrake", false ) end, 5000, 1) end end end end addEventHandler("onPlayerMarkerHit", root, Start_Bus)
-
I have this: function Salir() if isElement(tableVehicles[source]) then destroyElement(tableVehicles[source]) end end addEventHandler("onPlayerVehicleExit",getRootElement(),Salir) This function destroys the vehicle when the player leaves, I want this to happen after a second and not immediately, i need to use "Set timer", but I do not know how to use it, I tried different ways but none of them
-
Hi there! I've been trying to make a script for vehicle engine starter. My idea is, that player would have to hold down a key for 2 seconds and then the engine would start. Is there anybody that can help me with this please?
-
Buenas, les quería comentar que recientemente he intentado poner un timer sin exito para el drop, lo que yo quiero es que al poner el comando /drop en say, automáticamente se active un timer para que por si el jugador vuelve a tipear el comando deba esperar 5 segundos para volver a hacerlo, de esa manera no me harían un masivo floodeo con el comando, y ademas de eso el comando /drop queda bindeado con la tecla de "backspace" he buscado si en el archivo del teleport estaba la linea del bind pero no la encontré y a la hora de escribir o hacer ciertas cosas con otros resources se vuelve molesto apretar la tecla y que te mande a drop, sin mas que decir dejo la linea del teleport grcias! Aqui la linea del teleport : local posicoes = { { 1497.5999755859, -1853.0999755859, 2516 }, { 1493.3000488281, -1829.8000488281, 2516 }, { 1509.1999511719, -1827.3000488281, 2516 }, } function PosicaoPlayer ( thePlayer, command ) local azar = math.random ( #posicoes ) local veh = getPedOccupiedVehicle(thePlayer) if (veh) then setElementPosition(veh, unpack ( posicoes [ azar ] ) ) else setElementPosition(thePlayer, unpack ( posicoes [ azar ] ) ) end outputChatBox ( "#FFFFFF[#00FF00Tele#FFFFFF] ".. getPlayerName(thePlayer) .." #FFFFFFFue para drop! (#00FF00/drop#FFFFFF)", root, 0, 255, 0, true ) end addCommandHandler ( "drop", PosicaoPlayer )
-
Hey guys. I tried to killTimer after a player gets back to his jobcar. But it doesn't work for me. there isn't even a outputChatBox (I tried it out but deleted it for this showing) local Timer= setTimer( function () JobIcon=createBlip(1611.9,-1891.8,13.60,40, 1, 0, 0, 0, 255, 0, 99999.0) outputChatBox("Der Job wurde beendet!",myPlayer,255,0,0) destroyElement(jobcar) destroyElement(markers1) end,5000,0) end addEventHandler("onPlayerVehicleEnter",getRootElement(), function(vehicleID,leftSeat,jackerPlayer) local vehicleJ=getPedOccupiedVehicle(thePlayer) --jobcar is defined at the top of my script as 'createVehicle(512,....)-- if vehicleJ == jobcar and isTimer(Timer) then killTimer(Timer) end outputChatBox("Du bist rechtzeitig zurückgekehrt!",myPlayer,0,255,0,true) outputChatBox("Drücke 'B' um die Warnleuchte einzuschalten!",myPlayer,255,135,10,true) end) local Timer= setTimer( function () JobIcon=createBlip(1611.9,-1891.8,13.60,40, 1, 0, 0, 0, 255, 0, 99999.0) outputChatBox("Der Job wurde beendet!",myPlayer,255,0,0) destroyElement(jobcar) destroyElement(markers1) end,5000,0) end addEventHandler("onPlayerVehicleEnter",getRootElement(), function(vehicleID,leftSeat,jackerPlayer) local vehicleJ=getPedOccupiedVehicle(player) --jobcar is defined at the top of my script as 'createVehicle(512,....)-- if vehicleJ == jobcar and isTimer(Timer) then killTimer(Timer) end outputChatBox("Du bist rechtzeitig zurückgekehrt!",myPlayer,0,255,0,true) --translation: You came back in time! -- outputChatBox("Drücke 'B' um die Warnleuchte einzuschalten!",myPlayer,255,135,10,true) end)
-
function refre:~emLoots () for i, loots in ipairs(getElementsByType("colshape")) do local itemloot = getElementData(loots,"itemloot") if itemloot then local objects = getElementData(loots,"objectsINloot") if objects then if objects[1] ~= nil then destroyElement(objects[1]) end if objects[2] ~= nil then destroyElement(objects[2]) end if objects[3] ~= nil then destroyElement(objects[3]) end end destroyElement(loots) end end triggerEvent("onServerRespawnTrees",root) insertIntoTableResidential() createPickupsOnServerStart() setTimer(refre:~emLootPoints,gameplayVariables["itemrespawntimer"],1) local theTime = getRealTime() local hour = theTime.hour local minute = theTime.minute local seconds = theTime.second if hour < 10 then hour = "0"..hour else hour = theTime.hour end if minute < 10 then minute = "0"..minute else minute = theTime.minute end if seconds < 10 then minute = "0"..seconds else seconds = theTime.second end exports.DayZ:saveLog("[DayZ] ["..hour..":"..minute..":"..seconds.."] Items have been respawned.\r\n","game") outputDebugString("[DayZ] ["..hour..":"..minute..":"..seconds.."] Items have been respawned.",0,0,255,0) end function refre:~emLootPoints () local time = getRealTime() local hour = time.hour setTimer(refre:~emLoots,60000,1) end setTimer(refre:~emLootPoints,gameplayVariables["itemrespawntimer"],1) Help me create reloot time hud and chat
-
This is the code: function stimers(thePlayer) if getElementData(thePlayer,"asdasd") == true then local lejartimer1 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","10 mins!") local lejartimer2 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","9 mins!") end,60000, 1) local lejartimer3 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","8 mins!") end,120000, 1) local lejartimer4 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","7 mins!") end,180000, 1) local lejartimer5 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","6 mins!") end,240000, 1) local lejartimer6 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","5 mins!") end,300000, 1) local lejartimer7 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","4 mins!") end,360000, 1) local lejartimer8 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","3 mins") end,420000, 1) local lejartimer9 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","2 mins") end,480000, 1) local lejartimer10 = setTimer(function() exports.fly_box:showBox (thePlayer,"info","1 mins") end,540000, 1) local lejartimer11 = setTimer(function() setElementVisibleTo(mark, thePlayer, false) setElementData(thePlayer, "asdasd", false) local pos = positions[math.random(1,#positions)] setElementPosition ( mark, pos.x,pos.y,pos.z ) end,600000, 1) end,100,1) --- elseif getElementData(thePlayer,"asdasd") == false then if isTimer ( lejartimer1 ) then killTimer ( lejartimer1 ) end if isTimer ( lejartimer2 ) then killTimer ( lejartimer2 ) end if isTimer ( lejartimer3 ) then killTimer ( lejartimer3 ) end if isTimer ( lejartimer4 ) then killTimer ( lejartimer4 ) end if isTimer ( lejartimer5 ) then killTimer ( lejartimer5 ) end if isTimer ( lejartimer6 ) then killTimer ( lejartimer6 ) end if isTimer ( lejartimer7 ) then killTimer ( lejartimer7 ) end if isTimer ( lejartimer8 ) then killTimer ( lejartimer8 ) end if isTimer ( lejartimer9 ) then killTimer ( lejartimer9 ) end if isTimer ( lejartimer10 ) then killTimer ( lejartimer10 ) end end end addEvent("ctimers",true) addEventHandler("ctimers", root,stimers) Why not working the killTimers? How to fix this?
-
Hello. I want create a dx timer which when the player disconnect, and connect again to the server then not reset the timer. Sorry for my bad english :c
-
Hello, i'm working on a VIP Script, its important in RPG Servers Well i made the full script, i can give anyone vip and remove it but still one thing, its the timer, peoples call it vip hours! I want to make an expired date or something like that, i mean i will give someone 100 hours of vip, and after 100 hours the vip will be removed from him, i think you understand what i mean
-
i have this code: setTimer(function() local arfolyam = math.random(200,5130) outputChatBox("Jelenlegi árfolyam: "..arfolyam) end, 500, 0) GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1]) but i get this error in debugscript 3: attempt to concatenate global 'arfolyam' ( a nil value) what wrong? how to fix this?
-
So, i have a problem, im making a script for replacing sounds of cars, the first car i enter works nice, when i change engine state the sound goes off and on but when left a car on with the replaced sound and try to enter to another car and start the engine, it plays the sound on the last car, so if you do this with more cars, the first car plays a lot of sounds. Sorry my english is a bit :~ty cause im spanish. Heres some lua code, server side local wayfarerenginestate = 0 local timerwayfarersound = {} function OnEnterVehicle ( thePlayer, seat, jacked ) if getElementModel( source ) == 586 then local texture2 local sourcetxt = tostring(source) if string.match(sourcetxt, " ") then local extracted = sourcetxt:match("% .+") texture2 = extracted:gsub("% ","") end outputChatBox( texture2 ) if getElementData( source, "timer") == false then outputChatBox ( "Timer started", thePlayer ) timerwayfarersound[texture2] = setTimer( checkwayfarerenginestate, 500, 0, source, texture2 ) setElementData( source, "timer", true) end end end addEventHandler ( "onVehicleEnter", getRootElement(), OnEnterVehicle ) function checkwayfarerenginestate (source, texture2) if getVehicleEngineState( source ) == true and wayfarerenginestate == 0 then triggerClientEvent( "wayfarersoundcevent", resourceRoot, source, texture2) wayfarerenginestate = 1 elseif getVehicleEngineState( source ) == false and wayfarerenginestate == 1 then triggerClientEvent( "wayfarersounddcevent", resourceRoot, texture2) wayfarerenginestate = 0 end end Client side: local wayfarerenginestate = 0 local wayfarersound = {} function wayfarersoundf ( veh, texture2 ) local x, y, z = getElementPosition( veh ) wayfarersound[texture2] = playSound3D( "sounds/wayfarersound.mp3", x, y, z, true ) setSoundVolume( wayfarersound[texture2], 0.45 ) setSoundMaxDistance( wayfarersound[texture2], 100 ) attachElements( wayfarersound[texture2], veh) end addEvent( "wayfarersoundcevent", true ) addEventHandler( "wayfarersoundcevent", resourceRoot, wayfarersoundf ) function wayfarersounddf (texture2) destroyElement( wayfarersound[texture2] ) end addEvent( "wayfarersounddcevent", true ) addEventHandler( "wayfarersounddcevent", resourceRoot, wayfarersounddf ) What is the problem? Which 1 vehicle it works nice but, which more than 1 it bugs
-
Hi, can you help me? I want this animation to start and stop at 5 seconds and at 10 seconds to return the animation function animacion(source) setPedAnimation( source, "ped", "gas_cwr") setTimer(pararanim,5000,1) end addCommandHandler ("toxic", animacion) function pararanim(tp) setPedAnimation(tp,false) setTimer(animacion,3000,1) end addCommandHandler ("parar", pararanim) setPedAnimation( source, "GANGS", "prtial_gngtlkB", 1, false, true, true, true, false ) setTimer(function() setPedAnimation(source, false) end, 1000, 1) Try doing it with timers but not for animation
-
Hi, I'm creating a SQL-based currency system script, I put a setTime to generate coins at a certain time for certain players, however, I need to destroy this setTime when the player clears, I already did something to do that, However, when the player clears and setTime is destroyed, everyone's time is destroyed, not just the user who logged out. I need that when certain user is logged off, only his setTime is canceled ... does anyone have any idea what I can do? Starting time: function startFunction(_,thePlayer) tempo = setTimer ( function() ...code... end, 2000, 0 ) end Destroy time: function playerOff(thePlayer) ...code... if isTimer ( tempo ) then killTimer ( tempo ) end end addEventHandler("onPlayerQuit", getRootElement(), playerOff) addEventHandler("onPlayerLogout", getRootElement(), playerOff)
-
So hello, I maked a script, when i teleport with my command "sf" or "lv" or even "ls" when I'm in a car, I never teleport, but when I'm standing I doo teleport, soo how to do a teleportation with a car that worked when im in car and when im on foot, and i want to add a timer when i say "ls" and on the screen shows "3 seconds until a teleportation", and when hit by a player or a car, stop it by 1 sec and continue it. commando = { } laikas = 5000 function Tele( playerSource ) if (commando[playerSource]) then end setElementPosition(playerSource, 1518.88757, -1668.16504, 13.54688) commando[playerSource] = true setTimer( function() commando[playerSource] = false end, laikas, 1) end addCommandHandler( "ls",Tele) ------------------------------------------------------------------------------------------------------------------------- function Tele( playerSource ) if (commando[playerSource]) then end setElementPosition(playerSource, 2032.60022, 1343.41199, 10.82031) commando[playerSource] = true setTimer( function() commando[playerSource] = false end, laikas, 1) end addCommandHandler( "lv",Tele) ------------------------------------------------------------------------------------------------------------------------- function Tele( playerSource ) if (commando[playerSource]) then end setElementPosition(playerSource, -2028.97644, 148.12634, 28.83594) commando[playerSource] = true setTimer( function() commando[playerSource] = false end, laikas, 1) end addCommandHandler( "sf",Tele) -------------------------------------------------------------------------------------------------------------------------
-
local countdown = 120 G3 = guiCreateLabel(0.49, 0.67, 0.03, 0.02, tostring(countdown).." mp", true) guiSetFont(G3, "default-bold-small") guiSetVisible(G3,false) addEventHandler("onClientGUIClick",root, function () if source == buttonGuest then removeEventHandler("onClientRender",root,a123) addEventHandler("onClientRender", root, dxhavendeg) guiSetVisible(buttonLogin,false) guiSetVisible(buttonRegister,false) guiSetVisible(buttonGuest,false) guiSetVisible(editPassword,false) guiSetVisible(editUsername,false) setTimer(function () countdown = countdown - 1 if countdown >= 0 then guiSetText(G3, tostring(countdown)) else outputChatBox("asd") end end, 120000, 1000) end end ) what wrong?
-
function countdownFin() removeEventHandler("onClientRender", root, eventszamlalas) end local countdown = setTimer(countdownFin, 5000, 1) local screenW, screenH = guiGetScreenSize() function eventszamlalas() local x = getTimerDetails(countdown) local timeLeft = math.ceil(x/1000) dxDrawLine((screenW * 0.4111) - 1, (screenH * 0.1244) - 1, (screenW * 0.4111) - 1, screenH * 0.1589, tocolor(254, 254, 254, 255), 1, false) dxDrawLine(screenW * 0.6118, (screenH * 0.1244) - 1, (screenW * 0.4111) - 1, (screenH * 0.1244) - 1, tocolor(254, 254, 254, 255), 1, false) dxDrawLine((screenW * 0.4111) - 1, screenH * 0.1589, screenW * 0.6118, screenH * 0.1589, tocolor(254, 254, 254, 255), 1, false) dxDrawLine(screenW * 0.6118, screenH * 0.1589, screenW * 0.6118, (screenH * 0.1244) - 1, tocolor(254, 254, 254, 255), 1, false) dxDrawRectangle(screenW * 0.4111, screenH * 0.1244, screenW * 0.2007, screenH * 0.0344, tocolor(0, 0, 0, 161), false) dxDrawText("Az event elkezdődött! Vége: "..convertSecondsToMinutes(timeLeft), screenW * 0.4118, screenH * 0.1244, screenW * 0.6118, screenH * 0.1589, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end function eventstart() addEventHandler("onClientRender", root, eventszamlalas) end addCommandHandler("asd", eventstart) function convertSecondsToMinutes(sec) local temp = sec/60 local temp2 = (math.floor(temp)) local temp3 = sec-(temp2*60) if string.len(temp3) < 2 then temp3 = "0"..tostring(temp3) end return tostring(temp2)..":"..tostring(temp3) end i created a command, which displays the dx elements, and the timer, but the timer starts with the script, and when it expires, the command doesn't working.. i want, when i type command, show dx elements to everyone, and start timer, how to fix this ? sorry for my very bad English..:|
-
Good day! This is my code where the objective is to set the player wanted level. After increasing the wanted level, I want to create a timer in order to start decreasing it. The problem is that in my code, at each wanted level increase, it creates a timer, which is pretty annoying. The thing is, how can I check if there is a timer and destroy it, before starting the new one? I thought I did that, but the code is not working! function setWantedLevel(player) local wantedLevel = getElementData(player,"wantedLevel") if wantedLevel == 10 then setElementData(player,"wantedLevel",10,true) exports.SASCnotifications:drawNotification("#FF0000[Wanted Level System]#FFFFFF Wanted level is "..wantedLevel..".",localPlayer) else setElementData(player,"wantedLevel",wantedLevel+1,true) exports.SASCnotifications:drawNotification("#FF0000[Wanted Level System]#FFFFFF Wanted level increased to "..(wantedLevel+1)..".",localPlayer) if getElementData(player,"wantedLevel") == 3 then triggerServerEvent("setCriminalJob",player,player) end end timer = nil timer = setTimer(function(myTimer) if isTimer(myTimer) then killTimer(myTimer) timer=nil end local wantedLevel = getElementData(player,"wantedLevel") if wantedLevel == 0 then killTimer(myTimer) elseif wantedLevel ~= 0 then setElementData(player,"wantedLevel",wantedLevel-1,true) exports.SASCnotifications:drawNotification("#FF0000[Wanted Level System]#FFFFFF Wanted level decreased to "..(wantedLevel-1)..".",player) end end,5000,0,timer) end
-
Hey i make this script when you have low fuel to start a sound alarm but i don't know how to make to check this when you are in helicopter : function helicopter () if ( isPedInVehicle ( localPlayer ) == false ) then return false end ---------------------------Parts----------------------- local veh = getPedOccupiedVehicle(getLocalPlayer()); local maxfuel = ---myStuff--; local fuel = ---myStuff----------; if (isElement(veh) and getElementModel(veh) == 487 or 497 or 417 or 563 ) then if fuel <= 5 then sound = playSound("sound/beep.mp3" , true) setSoundVolume(sound, 0.2) outputChatBox ( "#FF0000Alarm ! #FFFFFFLow fuel ! Press ' Z ' to stop the alarm.", 255, 255, 255, true ) bindKey ( "Z", "down", stopMySoundV ) addEventHandler ( "onClientVehicleExit", root, stopMySound ) killTimer(tm) end end end tm = setTimer (helicopter , 5000 , 0) addEventHandler ( "onClientResourceStart", root, helicopter ) function stopMySound() stopSound ( sound ) unbindKey ( "Z", "down", stopMySoundV ) end function stopMySoundV() stopSound ( sound ) removeEventHandler( "onClientVehicleExit", root, stopMySound ) end This all work , but when he kill the timer i can't use ' resetTimer ' because he killed it , so how to make to reset that timer when he leave the vehicle ? this work first time , but when i enter again in vehicle he wont verify again.
- 13 replies
-
- timer
- addeventhandler
-
(and 1 more)
Tagged with: