Search the Community

Showing results for tags 'function'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
    • 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
  • Private Bugtracker

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start







Found 22 results

  1. Client.lua: function processLockUnlock(vehicle) if vehicle then local vehicleID = tonumber(getElementData(vehicle, "veh:id")) or -1 local vehFaction = tonumber(getElementData(vehicle, "veh:faction")) or 0 local vehOwner = tonumber(getElementData(vehicle, "veh:owner")) or -1 local vehJobID = tonumber(getElementData(vehicle, "veh:jobvehID")) or -1 local locked = isVehicleLocked(vehicle) local vehID = getElementModel(vehicle) local vehName = getVehicleRealName(vehID) if isPedInVehicle(localPlayer) then playSounds("lockin") else playSounds("lockout") end if locked then triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, false) else triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, true) end else outputChatBox("#FFFFFF Nincs kulcsod ehhez a járműhöz.", 169,139,101, true) end end local klikkTimer = false function setVehicleLockState() if klikkTimer then return end if isTimer(klikkTimerRun) then return end klikkTimer = true klikkTimerRun = setTimer(function() klikkTimer = false end,1000,1) local vehicle = getPedOccupiedVehicle ( localPlayer ) if vehicle then processLockUnlock(vehicle) else local int2 = getElementInterior(localPlayer) local dim2 = getElementDimension(localPlayer) local mx,my,mz = getElementPosition(localPlayer) local interior = getElementData(localPlayer, "interior") or false if not interior then for k,v in ipairs(getElementsByType("vehicle")) do local x,y,z = getElementPosition(v) local int = getElementInterior(v) local dim = getElementDimension(v) local dist = getDistanceBetweenPoints3D(x,y,z,mx,my,mz) if dist <= 3 and int2 == int and dim2 == dim then processLockUnlock(v) return end end end end end bindKey("k", "down", setVehicleLockState) setTimer(function() if not bindKey("k", "down", setVehicleLockState) then bindKey("k", "down", setVehicleLockState) end end, 1000, 0) Server.lua: addEvent("vehicleLock",true) addEventHandler("vehicleLock",getRootElement(),function(player,veh,value) setVehicleLocked(veh, value) veh:setData("veh:status", value) end) No errors / warnings in debugscript... if i press the [K] button, nothing happens... what wrong in this code? how to fix?
  2. function asdasdsas() playSound("") end addCommandHandler("test",asdasdsas) what wrong? the API working fine, but the playSound not.. how to fix?
  3. Andres99907

    How can i delay a function? Help :(

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

    Remove an Event Handler

    Hello ! when there's an event handler like below, function vehicleEnter(vehicle,seat) if seat == 0 then outputChatBox("You have entered a "..getVehicleName(vehicle),source,255,255,0) end end addEventHandler("onPlayerVehicleEnter",root,vehicleEnter) we can remove it from one line code like below, removeEventHandler("onPlayerVehicleEnter",root,vehicleEnter) So that's all. BUT !, when there's an event handler like below, addEventHandler("onPlayerVehicleEnter",root, function (vehicle,seat) if seat == 0 then outputChatBox("You have entered a "..getVehicleName(vehicle),source,255,255,0) end end ) How to remove that event handler ? are there any way ?
  5. Hello forums! I've been working on a project of mine, and I'm in need of a function which is similar to getPositionFromElementOffset (scroll down to examples). I can't wrap my head around matrices at all, and I would love to have a similar function, but with rotations instead (getting a rotation offset from an element). Would someone be able to help me out? I'd be very thankful!

    How to freeze my player?

    I don't understand this Error = [Expected bool at argument 2, got none]... how to use function clientSide setElementFrozen ? --client side script function FPlayer () setElementFrozen (this, true) --This is how this method? end
  7. It's because of the onClientResourceStart event, but i dont know why its triggering it twice. Thanks function create() triggerServerEvent ( "create_s", resourceRoot) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), create) and the server function create_s() outputChatBox("lol") end addEvent("create_s", true) addEventHandler("create_s", resourceRoot, create_s)
  8. This is the code: And i get this warnings: bad argument @ 'stopSound' [expected sound at argument 1, got nil] and bad argument @ 'detachElement' [expected element at argument 1, got nil] .. -.- how to fix this?
  9. This is the code: addEvent ( "aPlayer", true ) addEventHandler ( "aPlayer", _root, function ( player, action, data, additional, additional2, kickedname ) if checkClient( "command."..action, source, 'aPlayer', action ) then return end if not isElement( player ) then return -- Ignore if player is no longer valid end if ( hasObjectPermissionTo ( source, "command."..action ) ) then local admin = source local mdata = "" local more = "" if ( action == "kick" ) then local reason = data or "" mdata = reason~="" and ( "(" .. reason .. ")" ) or "" setTimer ( kickPlayer, 100, 1, player, source, reason ) exports.ig_kickban:showBoxS (root ,"Kirúgás", player.." kirúgta "..source.." nevű játékost", "kick") the exports.ig_ki...etc line does not working.. why? i get this error: "Attempt to concatenate global source (a userdata value)"
  10. Hi, i have a trouble with my fuction . It's simply trigerred by hiting marker but the clue is that i want it to be trigerred ONLY ONCE like "onceTrigerredonMarkerHit". My code as an example : marker2=createMarker(3399.2,-1899.2,30.1,"corona",2,0,0,255,0) tr1=createVehicle(584,3357.5,-1956.8,31.29,0,0,90) tr2=createVehicle(515,3347.2,-1957,31.29,0,0,90) function open_smashb() ... function m() ... blowVehicle(tr) blowVehicle(tr2) end setTimer(m,2000,1) end addEventHandler("onMarkerHit", marker2, open_smashb)
  11. Starztec

    Solo a veces funciona

    Estoy teniendo un problema hace un mes y no lo puedo solucionar de ninguna manera y recurro para ver si alguno sabe el origen del problema. El script funciona: Jugador > Accede al panel > Boton > Trabajo > Empieza el primer marker > Apenas llega debería congelar (Pero solo a veces congela, otras sigue de largo) y a veces reiniciando el script funciona Cliente: addEventHandler("onClientGUIClick", guiRoot, function() local getGui = guiGetVisible(Ventana2) if source == BOTON1 then if getGui then guiSetVisible(Ventana2, false) showCursor(false) Marker1 = createMarker(2459.083984375, 1901.0810546875, 10.768750190735-1,"cylinder",2,0,255,0) addEventHandler( "onClientMarkerHit", Marker1, Siguientemarker1 ) Marker1BLIP = createBlipAttachedTo ( Marker1, 0 ) outputChatBox ("----------------------------",255,0,0, true) outputChatBox ("¡Para empezar ve al marker!.",0,218,255, true) outputChatBox ("----------------------------",255,0,0, true) end end end ) function Siguientemarker1 (element) if element == localPlayer then if timer then killTimer(timer) timer = nil end timer = setTimer(Siguientemarker2, 30000, 1) setElementFrozen ( veh, true ) ------Aca deberia congelar siempre outputChatBox ("----------------------------",255,0,0, true) outputChatBox ("Cargando..." ,0,255,255, true) outputChatBox ("----------------------------",255,0,0, true) end end function Siguientemarker2() destroyElement ( Marker1 ) destroyElement ( Marker1BLIP ) Marker1 = nil Marker2= createMarker(2502.048828125, 2153.3330078125, 10.296809196472-1,"cylinder",2,0,255,0) if veh then setElementFrozen ( veh, false ) Marker2BLIP = createBlipAttachedTo ( Marker2, 0 ) timer = nil addEventHandler( "onClientMarkerHit", Marker2, Siguientemarker2B ) end end Aclaraciones: * Hay varios botones con la misma función diferente nombre * El "Siguientemarker" sigue hasta ejemplo 32 markers. (Apenas comienza es cuando no "congela" si congela al principio, congela en todos los markers.
  12. Starztec

    GET account ID

    Boton8 = guiCreateLabel(137, 142, 111, 25, "LEGAJO2", false, Ventana);guiSetProperty(Boton8, "NormalTextColour", "FF27F512") addCommandHandler("p", function() local team = getPlayerTeam(localPlayer) if team then local teamName = getTeamName(team) if teamName == "MOBSA" then local getGui = guiGetVisible(Ventana) if not getGui then guiSetVisible(Ventana, true) guiSetText(Boton10, getPlayerMoney(localplayer)) guiSetText(Boton2, teamName) guiSetText(Boton4, getPlayerName(localPlayer)) guiSetText(Boton8, ID ) --<<Aca necesitaria poner la id del jugador, digamos que aparesca su id showCursor(true) else guiSetVisible(Ventana, false) showCursor(false) print ("Tu trabajas de chofer actualmente") end else print ("Tu trabajas de chofer actualmente") end end end ) Buenas, mi duda es como sacar la id de los jugadores? Veo cual son porque quedan guardadas pero como hago para volcar esos datos en estos textos? Gracias!
  13. Hi As it says in the Title, i have a problem with this .. I looked up on the Wiki and used guiGridListGetItemData, I read the example provided, didn't make it for what I need . function BuyDrink ( button ) if button == "left" then local nRow, nColumn = guiGridListGetSelectedItem( GridList ) if nRow ~= -1 and nColumn ~= - 1 then local row, col = guiGridListGetSelectedItem ( GridList ) local selected = guiGridListGetItemData ( GridList, row, col ) -- This Gives "nil" output outputChatBox ( "You Bought " .. tostring(selected) ) -- Output the Text from selected row of the first Column only end end end Basically I want the Text of my first column selected row, not an int . I hope I made it clear to understand Any help is appreciated .
  14. i have this played time script: and i want add to this a command, which the admins can add more hours for anyone, how to make this command??
  15. Erknneto

    [HELP] DX functions

    Hello everyone. I need some help here. I wan't to create a DX Inventory for my server, with some buttons. I created a script that creates the inventory but only 1 button is working. local newInvItems = { {"Assault Rifle"}, {"AK-47"}, {"Sniper"}, {"Pump Shotgun"}, {"Crossbow"}, {"Custom SMG"}, {"Shotgun"}, {"Semi-Automatic Pistol"}, {"Machete"}, {"5.56 Rifle Ammo"}, {"Sniper Rifle Ammo"}, {"12 Gauge"}, {"Pistol Bullet"}, {"Wooden Arrow"}, {"SMG Ammo"}, {"Apple"}, {"Banana"}, {"Orange"}, {"Tomato"}, {"Cereal Box"}, {"Juice Box"}, {"Milk Bottle"}, {"Water Bottle"}, {"Raw Meat"}, {"Cooked Meat"}, {"Battery"}, {"Gallon (Fuel)"}, {"Gallon (Empty)"}, {"Bottle (Empty)"}, {"Medical Satchel"}, {"Rags"}, {"Cloth"}, {"Gun Powder"}, {"Alcohol Bottle"}, {"Wood"}, {"Metal"}, {"Stone"}, {"Building Tool"}, {"Fishing Rod"}, {"Cannabis Seed"}, {"Cannabis Medicinal"}, {"Sulphur"}, {"Charcoal"}, {"Axe"}, {"Pickaxe"}, {"C4"}, {"Lock"}, {"Map"}, {"GPS"}, {"Watch"}, {"Toolbox"}, {"Medium Backpack"}, {"Large Backpack"}, {"Top Hat"}, {"Witch Hat"}, {"Horn Hat"}, {"Pizza Hat"}, {"Police Hat"}, {"SWAT Hat"}, {"SWAT Armour"}, {"Chicken Head"}, {"Gas Mask"}, {"Eyepatch"}, {"Motorcycle Helmet"}, } local screenW, screenH = guiGetScreenSize() local inventoryLimit = 28 showCursor(true) function renderInventory () mainTable = dxDrawRectangle(10, (screenH - 583) / 2, 260, 598, tocolor(0, 0, 0, 170), false) lootTable = dxDrawRectangle(10, (screenH - 670) / 2, 260, 38, tocolor(0, 77, 126, 150), false) rowNumber = 0 for i,item in ipairs(newInvItems) do if ( getElementData(getLocalPlayer(),item[1]) >= 1 ) then if not ( rowNumber > inventoryLimit ) then rowNumber = rowNumber + 1 itemBackground = dxDrawRectangle(20, 85+rowNumber*20, 185, 15, tocolor(0, 77, 126, 150), false) takeBackground = dxDrawRectangle(210, 85+rowNumber*20, 50, 15, tocolor(0, 77, 126, 150), false) itemText = dxDrawText(item[1].." ("..getElementData(getLocalPlayer(),item[1]).."x)",25,85+rowNumber*20,tocolor(255,255,255, 255)) takeText = dxDrawText("Take",221,85+rowNumber*20,tocolor(255,255,255, 255)) end end end end addEventHandler("onClientRender", root, renderInventory) function inventoryClickDetect (button,state,x,y) if ( button == "left" ) then if ( state == "down" ) then if ( x >= 210 and x <= 210 + 50 and y >= 85+rowNumber*20 and y <= 85+rowNumber*20 + 15 ) then outputChatBox("Test!") end end end end addEventHandler("onClientClick",root,inventoryClickDetect) It creates all buttons and all things, but only the last button created is working. How can I make for every button to work? sorry for my bad english, I'm brazilian
  16. Hola a todos!! Les cuento lo que me esta pasando, quiero crear una función que me permita que a partir de presionar un boton, se active una función de crearse un marker y despues que desaparesca al pisarlo, alguien sabe? Este es el código que hice: ----------------------------------------------------- -- Esto seria la parte del panel para que empieze a la función, osea con "BOTON" ----------------------------------------------------- addEventHandler("onClientGUIClick", guiRoot, function() local getGui = guiGetVisible(Ventana2) if source == BOTON then --Para que se cree el marquer pulsar este boton if getGui then guiSetVisible(Ventana2, false) showCursor(false) setElementVisibleTo ( Marker1, root, true ) --El voton "Crearia el marker 1" end end end end ) setElementVisibleTo ( Marker1, root, false ) Marker1 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255) --Supuestamente apareceria cuando lo apretaria function Inicio () if isElementWithinMarker(source, Marker1) --Cuando toca sobre el marker desaparesca then destroyElement ( Marker1 ) --Se destruye el marker1 Marker2 = createMarker(2482.2924804688, 1917.4254150391, 9.768750190735,"cylinder",2,0,218,255) --se crea el marker2 end end end addEventHandler( "onMarkerHit", Marker1, Inicio ) -------------------------------
  17. 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?
  18. Ghost-Gamer


    ابي اسوي مود بصمات بس ابي ال function عشان اسويه ملاحظة هذا للحياة واقعية مثلا شخص قتل شخص يجي المباحث يدور على ادلة و بصمات و لمن يخلص يكتب امر اعرف كيف اسوي الامر ما يحتاج و لمن يكتب الامر يطلع تحميل حق مودات تحت يمشي 5 5 يعني يمشي 5 10 15 20 و الخ و لمن يخلص يطلع اسم الي قتل الشخص و بس اقدر اسوي مود زي مذا ولا مستحيل ض؟
  19. local titles = { "AdminSegéd", "Moderátor", "SzuperModerátor", "Admin", "FőAdmin", "Tulajdonos", "Fejlesztő" } function getPlayerAdminTitle() local text = titles if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then text = "Tulajdonos" elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("FoAdmin")) then text = "FőAdmin" elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Adminseged")) then text = "AdminSegéd" elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("KisAdmin")) then text = "Admin" elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Fejleszto")) then text = "Fejlesztő" elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then text = "Moderátor" end end function getFixedName(player) if isElement(player) then local hisName = getPlayerName(player) if hisName then result = string.gsub(hisName, '#%x%x%x%x%x%x', '') if result then return result end end end end function adminuzi(thePlayer, commandName, ...) if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("FoAdmin")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Adminseged")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("KisAdmin")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Fejleszto")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Moderator")) then if not (...) then outputChatBox("#00FF7F[Használat]:#FFFFFF /".. commandName .." [üzenet]", thePlayer, 0, 206, 209,true) else local adminrang = getPlayerAdminTitle(thePlayer) message = table.concat({...}, " ") local playerName = getFixedName ( thePlayer ) outputChatBox("#0088FF[SUPERFUN-Admin]#d8001f "..playerName..": "..message,getRootElement(),0,0,0,true) end end end addCommandHandler("asay", adminuzi, false, false) i have this script, and i get this warnings/error: How to fix this?
  20. السلام عليكم ورحمة الله وبركاته طبعاً كلنا نعرف ان البرمجة عبارة عن اكواد واوامر وما الا غيره وطبعاً فيه كثير من المودات - الاضافات او السكربتات - تحتاج اكوادها تتصل ببعضها . طيب انا بقولكم شيء يمكن يفيدكم ورح يكون عبارة عن امر function . طبعاً الفنكشن العادي بيكون كدة function FunctionName () -- FunctionName تقدر تسويه متل ما تبي -- Code end طيب كدة سوينا الامر بس هل اذا شغلت المود رح يشتغل هذا الامر ؟ طبعاً لا لأنك ما سويت له اشارة او حدث مثال كيف تسوي له حدث function DeveloperAhmed () -- DeveloperAhmed اسم الامر وتقدر تسويه اي شي -- Code end addEventHandler ( "onPlayerWasted", root, DeveloperAhmed ) -- هذا حدث وقت اللاعب يموت يسوي الامر DeveloperAhmed طيب الحين مثال على - كيف تسويه بإشارة function KillerProject () -- ليكن مثلاً هذا امر بحدث DeveloperAhmed () -- بعد ما الحدث بدأ رح يسوي إشارة لهذا الامر DeveloperAhmed end addEventHandler ( "onPlayerJoin", root, KillerProject ) -- حدث اذا الاعب دخل يسوي الامر هذا KillerProject function DeveloperAhmed () -- هذا امر بإشارة -- Code end ملخص الشرح الامر يمكن تشغيله بطريقتين - حسب ما توصلت - واللي هما الحدث والاشارة DeveloperAhmed () -- اشارة -- او حدث addEventHandler("onPlayerWasted", root, DeveloperAhmed ) -- حدث -- وطبعاً هذا هو الامر function DeveloperAhmed () -- Code end -- وفي حالة انك وضعته بهذا الشكل مارح يكون له اي تأثير -- تأثيره رح يظهر في الحالتين اما الاشارة او الحدث اتمنى اكون افدتكم بأي شي او سهلت عليكم موضوع الاوامر هذا والربط بينهم واعتذر اذا الشرح سيء والسلام عليكم ورحمة الله وبركاته
  21. I want make more than one function to math.random, when i click on a button, choose a function, for example god mode, or give weapons, how to make it? Sorry for my very bad english.
  22. ViRuZGamiing

    Call/Exports function

    Hi guys I was looking into: call and I was wondering, for example; you have the function outputChatBox("") which works both client and server side with the same name. Will I be able to do the same with exports. Example; Client function drawDxStuff () --dx stuff end addEvent("drawDxStuff", true) addEventHandler("drawDxStuff", getRootElement(), drawDxStuff) Server function drawDxStuff() triggerClientEvent(source, "drawDxStuff", source) --source would probably be the player calling the function end Meta <export function="drawDxStuff" type="server"/> <export function="drawDxStuff" type="client"/> Would this work or will this give an error cause they have the same name or for other reasons? Kind Regards