Jump to content

Search the Community

Showing results for tags 'addeventhandler'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 6 results

  1. addEventHandler + group elements I noticed that some people like to add 10000000000000000 addEventHandlers for each element, while you probably only need 1 addEventHandler. Using ONE addEventHandler on a group of elements? Answer: local group = createElement("groupMyCutePeds") -- Create a custom element and save it in to the variable <group>. -- Create 3 peds. local ped1 = createPed(120, 5540.6654, 1020.55122, 1240.545) local ped2 = createPed(120, 5541.6654, 1021.55122, 1240.545) local ped3 = createPed(120, 5542.6654, 1022.55122, 1240.545) -- Set the parent of the 3 peds. setElementParent(ped1, group) setElementParent(ped2, group) setElementParent(ped3, group) -- Add an addEventHandler and use the <group> as <attachedTo> element. addEventHandler("onPedWasted", group, -- "onPedWasted" = serverside. "onClientPedWasted" = clientside. function () outputChatBox("One of my cute peds just died. ;'( No exceptions!") end) Code is untested, but the method is tested. Syntax for functions in example createElement syntax element createElement ( string elementType, [ string elementID = nil ] ) setElementParent syntax bool setElementParent ( element theElement, element parent ) addEventHandler syntax bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [ bool getPropagated = true, string priority = "normal" ] ) DO NOT disable getPropagated getPropagated: A boolean representing whether the handler will be triggered if the event was propagated down or up the element tree (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to false will only be triggered if source == this). If you disable this, children of the <group> element are not included. Make use of the element tree Element tree For applying addEventHandlers to elements created by the resource: Use: resourceRoot / getResourceRootElement For applying addEventHandlers to elements created by scripts of the resource: Use: getResourceDynamicElementRoot For applying addEventHandlers to elements created by maps of the resource: Use: getResourceMapRootElement I hope your code will be without... print(10^10^10^10) -- Print here: https://www.lua.org/cgi-bin/demo ...addEventHandlers in the future.
  2. Alguém consegue me responder pq a function finish n é chamada? function markerb1() if CurrentMarker >= 2 then destroyElement(marker) destroyElement(blip) end if CurrentMarker == 2 then --42 = ultima outputChatBox("Você terminou, entre na auto-escola para ver sua avaliação.", getRootElement(), 0, 255, 0) health = getElementHealth(car) fnh = createMarker(-2026.83, -114.85, 1034, "cylinder", 1.0, _,_,_,_, getRootElement()) setElementInterior(fnh, 3) destroyElement(car) addEventHandler("onMarkerHit", fnh, finish) else marker = createMarker(markersb[CurrentMarker][1], markersb[CurrentMarker][2], markersb[CurrentMarker][3], "checkpoint", 5.0, 255, 0, 0, 90, getRootElement()) blip = createBlipAttachedTo(marker, _, _, _, _, _, _, _, _, getRootElement()) CurrentMarker = CurrentMarker + 1 end end function finish(hitElement, matchingDimension) if health >= 900 then outputChatBox("Você aprovado, agora você possui habilitação tipo B.", getRootElement(), 0, 255, 0) account = getPlayerAccount(hitElement) setAccountData(account, "habilitacao.tipob", true) else outputChatBox("Você foi reprovado, tente novamente.", getRootElement(), 255, 0, 0) end started = false end Ele chega a me mostrar a mensagem de que terminou, e cria a marker dentro da auto-escola, mas qnd eu passo nela, nada acontece, já troquei o onMarkerHit pelo onPlayerMarkerHit, mas anyway, não funcionou
  3. Alguem Pode Me Ajudar ? function AirNewQuit (source) if (veh[source]) and isElement(veh[source]) then setElementVisibleTo ( AirNew77744, source, false ) destroyElement (veh[source]) outputChatBox ("#ffffff[ #FFA136Trabalho #ffffff] - #FFFFFFVoce Saiu Do Veiculo E Perdeu O Emprego", source ,0,0,0,true) else end end addEventHandler ( "onVehicleExit", getRootElement(), AirNewQuit ) --- Quando O Jogador Sai Do Veiculo ( Funcionando ) addEventHandler ( "onPlayerWasted", getRootElement(), AirNewQuit ) --- Quando O Jogador Morre ( Nao Funciona ) addEventHandler ( "onPlayerQuit", getRootElement(), AirNewQuit ) --- Quando O Jogador Quita Do Servidor ( Nao Funciona ) Queria Saber Porque As Duas Ultimas Linhas Nao Funcionam, Se Alguem Puder Me Ajudar Ficaria AGRADECIDO.
  4. 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.
  5. The text appears succesfully but i cant make it disappear:/ Pls help! [lua] function fadeDX() startTick = getTickCount() addEventHandler("onClientRender",root,text) end function text() local currentTick = getTickCount() local progress = (currentTick-startTick)/duration local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad") dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3) setTimer ( function() startTick = nil,nil removeEventHandler("onClientRender",root,text) local currentTick = getTickCount() local progress = (currentTick+startTick)/duration local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad") dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3) end, 8000, 1 ) end [/lua]
×
×
  • Create New...