Search the Community

Showing results for tags 'trigger'.

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
    • 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
  • Archive
  • Private Bugtracker

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



About Me





Found 12 results

  1. Hey guys please help!!! I have been researching and researching for almost 8 hours now. And I am just stuck as to what I am fundamentally getting wrong here. Main goal: I would like when the person gets into a vehicle, read the license plates, send plates to the server, read a table in the DB, then send info from table back to the client to use in other functions. What works: I am OK server side, I am able to read from the database and pass that back to the client, but can only trigger server side with a RegisterCommand. Issue: Client side, when I start using triggers inside of an if statement it stops working, (yes I am sure conditions are met). I am currently only able to trigger the server function with a register command, when I try to send a trigger from the client to the server, it will not launch the server function. Working code: client.Lua RegisterNetEvent("servertest:output_status") --from server.Lua AddEventHandler("servertest:output_status", function(argument) TriggerEvent("chatMessage", "[Success]", {0,255,0}, argument) TriggerEvent("servertest:vehStatus", argument) end) Citizen.CreateThread(function() while true do Citizen.Wait(1000) local playerPed = GetPlayerPed(-1) if IsPedInAnyVehicle(playerPed, false) then AddEventHandler("servertest:vehStatus", function(vehstatus) TriggerEvent("chatMessage", "[LOOP]", {0,255,0}, vehstatus) end) end end end) server.Lua: RegisterCommand("get", function(source, args) --I dont want to trigger this way, I want to trigger from client side MySQL.Async.fetchAll('SELECT * FROM vehicle_data WHERE plate = @plate', { ['@plate'] = "TSTPLATE1" }, function(result) if result[1] then local vehstatus = result[1].status TriggerClientEvent("servertest:output_status", source, vehstatus) cb(true) else cb(false) end end) end) What I want to do: client.Lua: RegisterNetEvent("servertest:output_status") --from server.Lua AddEventHandler("servertest:output_status", function(argument) TriggerEvent("chatMessage", "[Success]", {0,255,0}, argument) --never receive message TriggerEvent("servertest:vehStatus", argument) --not used now, save for later use end) Citizen.CreateThread(function() while true do Citizen.Wait(1000) local playerPed = GetPlayerPed(-1) if IsPedInAnyVehicle(playerPed, false) then local playerVeh = GetVehiclePedIsIn(playerPed, false) local vehPlates = GetVehicleNumberPlateText(playerVeh) TriggerServerEvent("servertest:sendInfo", vehPlates) --this trigger never happens even though criteria is met end end end) server.Lua: RegisterNetEvent("servertest:sendInfo") AddEventHandler("servertest:sendInfo", function(plates) MySQL.Async.fetchAll('SELECT * FROM vehicle_data WHERE plate = @plate', { ['@plate'] = plates }, function(result) if result[1] then local vehstatus = result[1].status TriggerClientEvent("servertest:output_status", source, vehstatus) cb(true) else cb(false) end end) end) I guess maybe what I need to know is just how to trigger something server side from the client side without using a RegisterCommand. I don't know how to structure it in my code, do I need to do it outside the while loop? I've tried but haven't been successful.
  2. Scrolling through the tutorials, I found a script that displays players in the server when joining and quitting. function playerCount ( ) outputChatBox("#ff8800[server]: #ffffffPlayers: #ffffff(" .. getPlayerCount() .. "#ffffff)" , root, 255, 0, 0, true) end addEventHandler ( "onPlayerJoin", getRootElement(), playerCount ) addEventHandler ( "onPlayerQuit", getRootElement(), playerCount ) What would I have to add to trigger it with a command, such as "/players"?
  3. I am done. I've made a function to display text on elements, on server-side, and I wanted to trigger client event, but what? Doesn't triggering. Look: allElems = 0 function dxDrawTextOnElem(element, text, height, distance, r, g, b, alpha, size, font) allElems = allElems + 1 triggerClientEvent("dxDraw", resourceRoot, element, text, height or 0, distance or 20, r or 255, g or 0, b or 0, alpha or 255, size or 1, font or "arial", allElems) end Boom, client-side script: --Ofcourse, I've created all tables + in "onClientRender" I put outputChatBox(), outputs "{}" (because tables are empty) addEvent("dxDraw", true) addEventHandler("dxDraw", resourceRoot, function(element, text, height, distance, r, g, b, alpha, size, font, k) local i = table.find(elements, element) --table.find(pattern, s) if i then elements[i] = element texts[i] = text heights[i] = height distances[i] = distance rs[i] = r gs[i] = g bs[i] = b alphas[i] = alpha sizes[i] = size fonts[i] = font else elements[k] = element texts[k] = text heights[k] = height distances[k] = distance rs[k] = r gs[k] = g bs[k] = b alphas[k] = alpha sizes[k] = size fonts[k] = font end end) addEventHandler("onClientRender", root, function() for i, text in ipairs(texts) do dxDrawTextOnElement(elements[i], text, heights[i], distances[i], rs[i], gs[i], bs[i], alphas[i], sizes[i], fonts[i]) end end) Jesus, I'm done with it. Sorry for asking a similar thing, but it's really difficult for me. For real, I'm like doing it second time, still fails.
  4. Как правильно триггерить на сервер? У меня есть вот такая функция function ClickSclad(botao, state) if botao == "left" and state == "down" then if sklad.visible then if cursorPosition(570, 274, 227, 27) then triggerServerEvent("GiveWeaponeAndArmor", getLocalPlayer(), "Nightstick") elseif cursorPosition(570, 311, 227, 27) then triggerServerEvent("GiveWeaponeAndArmor", getLocalPlayer(), "Deagle") elseif cursorPosition(570, 348, 227, 27) then triggerServerEvent("GiveWeaponeAndArmor", getLocalPlayer(), "Shotgun") elseif cursorPosition(570, 385, 227, 27) then triggerServerEvent("GiveWeaponeAndArmor", getLocalPlayer(), "MP5") elseif cursorPosition(570, 422, 227, 27) then triggerServerEvent("GiveWeaponeAndArmor", getLocalPlayer(), "M4") elseif cursorPosition(570, 459, 227, 27) then triggerServerEvent("GiveWeaponeAndArmor", getLocalPlayer(), "Armor") elseif cursorPosition(707, 508, 85, 23) then showCursor(false) removeEventHandler("onClientRender", root, wnd_sklad) sklad.visible = false end end end end addEventHandler("onClientClick", getRootElement(), ClickSclad) и вот function GiveWeaponeSklad (source, inf) if inf == Deagle then giveWeapon( source, 24 ) setWeaponAmmo( source, 24, 100 ) setPedWeaponSlot ( source, 2 ) elseif inf == Nightstick then giveWeapon( source, 3 ) setPedWeaponSlot ( source, 1 ) elseif inf == Shotgun then giveWeapon( source, 25 ) setWeaponAmmo( source, 25, 100 ) setPedWeaponSlot ( source, 3 ) elseif inf == MP5 then giveWeapon( source, 29 ) setWeaponAmmo( source, 29, 300 ) setPedWeaponSlot ( source, 7 ) elseif inf == M4 then giveWeapon( source, 31 ) setWeaponAmmo( source, 31, 300 ) setPedWeaponSlot ( source, 7 ) elseif inf == Armor then setPedArmor( source, 100 ) end end addEvent("GiveWeaponeAndArmor", true) addEventHandler("GiveWeaponeAndArmor", getRootElement(), GiveWeaponeSklad) И у меня в дебаге пишет, что 1 аргумент, допустим в Armor, got string 'Armor'. То есть у меня не получается правильно триггернуть на сервер. Заранее спасибо, надеюсь объяснил понятно
  5. My question is how to send a data to the server in a personal way with the client, that is, without including all the clients. Client side function AAB (pia) triggerServerEvent ("KnowAmount", getLocalPlayer(), pia ) end --====================================================================== Server Side function KnowAmountFunction (pia) outputChatBox ("AA") -- This show ALL Client, and that's what I want to avoid if (pia == 1) then PasajENP = PasajENP_a1 -- This change for all players, and it should not be like that triggerClientEvent (client, "GotoClient", resourceRoot, PasajENP ) end end addEvent( "KnowAmount", true ) addEventHandler( "KnowAmount", getRootElement(), KnowAmountFunction )
  6. Hi guys,im stuck here... I want when i press on GUIEditor.button[1] it sends that i typed in GUIEditor.edit[1] to selected player.. --client GUIEditor = { edit = {}, button = {}, window = {}, label = {}, gridlist = {} } addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() GUIEditor.window[1] = guiCreateWindow((screenW - 528) / 2, (screenH - 183) / 2, 528, 183, "dm panel - gat", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(29, 32, 186, 142, false, GUIEditor.window[1]) local column = guiGridListAddColumn(GUIEditor.gridlist[1], "players", 0.9) GUIEditor.button[1] = guiCreateButton(247, 107, 271, 60, "DM", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.edit[1] = guiCreateEdit(247, 32, 269, 65, "", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(216, 63, 31, 15, "close", false, GUIEditor.window[1]) for id, player in pairs(getElementsByType("player")) do local row = guiGridListAddRow ( GUIEditor.gridlist[1]) guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, getPlayerName ( player ), false, false ) guiSetVisible(GUIEditor.window[1], false ) end end ) function show () if guiGetVisible(GUIEditor.window[1] ) then guiSetVisible(GUIEditor.window[1], false ) showCursor (false) else guiSetVisible(GUIEditor.window[1], true ) showCursor (true) end end addCommandHandler("dm", show) function clickin () if source == GUIEditor.label[1] then guiSetVisible(GUIEditor.window[1], false ) showCursor (false) elseif source == GUIEditor.button[1] then if guiGetText(GUIEditor.edit[1] ) == "" then return end --im stoped here, showCursor (false) guiSetVisible(GUIEditor.window[1], false ) end end addEventHandler("onClientGUIClick", root, clickin)
  7. I made an script that make staffs can open an panel by using /dm then choose a player and type a message then send it... But my problem is i don't know how to trigger this to put this code in server side outputChatBox(msg, selectedplayer, 255, 255, 255, true) I mean to send the message to selected player only... client variables: msg = guiGetText(editbox) selectedplayer = guiGridListGetSelectedItem(gridlist) Help pls
  8. Al momento de dirigir un dato al servidor funciona todo bien, el caso es cuando al modificar ese valor y devolverlo otro con ClientTrigger, no funciona o por alguna razón no se activa. Client Side (NOTA: La function greetingHandler, el outputChatBox no aparece) function greetingCommand ( Parada01_Ramal_a ) if timer then killTimer(timer) timer = nil end if (actualspeed) <= 20 then veh = getPedOccupiedVehicle( localPlayer ) outputChatBox ("Disponibilidad:" ,255,0,0, true); outputChatBox (DispPasajeros ,255,0,0, true) triggerServerEvent ( "onGreeting", resourceRoot, DispPasajeros ) ---La disponibilidad es el valor que modifico en el servidor end end function greetingHandler ( PasajSuben ) ---Pasajeros Suben, es el valor modificado gracias a la disponibilidad (Y que necesito de vuelta en cliente) CantPasajeros = CantPasajeros + PasajSuben --- Sumo al total con ese dato outputChatBox ("CantidadNueva:" ,255,0,0, true); outputChatBox (CantPasajeros ,255,0,0, true) end addEvent( "onGreeting2", true ) addEventHandler( "onGreeting2", localPlayer, greetingHandler ) Server Side (NOTA: La idea era que con el ELSE que verán a continuación ya devuelva el dato, pero no encontraba la forma de hacerlo) ¿habría una forma de integrar el trigger a la func Parada_58_a_1? function Parada_58_a_1 (DispPasajeros) if (PasajENP_a_1 > 0) and (DispPasajeros > 0) then DispPasajeros = DispPasajeros -1 PasajENP_a_1 = PasajENP_a_1 -1 PasajSuben = PasajSuben +1 outputChatBox ("Pasajeros que suben: " .. PasajSuben, client) outputChatBox ("Pasajeros Disponibles: " .. DispPasajeros, client) setTimer ( Parada_58_a_1, 1000, 1, DispPasajeros) else outputChatBox ("Pasajeros Nuevos Disponibles: " .. DispPasajeros, client) timer = setTimer (greetingCommand, 500, 1, PasajSuben) --Pasa a la otra func, para realizar el Trigger Client end end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", resourceRoot, Parada_58_a_1 ) function greetingCommand ( playerSource, commandName ) local playerSource = getPlayerName( playerSource ) triggerClientEvent ( "onGreeting2", playerSource, PasajSuben ) --Aca es el dato que se pasa a Cliente outputChatBox ("Pasajeros que suben: " .. PasajSuben, client) end Gracias!
  9. Eae pessoal. Estou com uma dúvida rápida aqui. Estou fazendo um sistema de level, nesse sistema existe um verificador server-side que verifica todos os jogadores a cada 1 segundo procurando por players AFK para pausar o Up do level. Até então sem problemas, mas estou querendo colocar o tempo do up de cada jogador aparecer na tela deles, qual procedimento a seguir é MAIS LEVE para fazer isso? cria uma variável, salva o tempo nela e triggerClientEvent a cada 1 segundo, para enviar essa variável atualizada ao cliente. setElementData no jogador a cada 1 segundo, então o client irá sempre mostrar essa data na tela dele. setAccountData no jogador a cada 1 segundo. [Já vi que é inviável fazer assim, até porque não há como receber esse valor client-side] fazer o próprio client calcular o tempo de up? A propósito, o timer em si é este: (server-side) No script client, deverá ter um onClientRender que deverá mostrar o playerLapsed ao jogador. (só que no client, irá formatar os milisegundos em minutos/segundos.)
  10. I tried several ways to make the communication between client and server, but I can not get to the shop that I am armed, my idea is to make different curtains for groups, and each has a color, I can not get that when the person chooses the object who wants to buy, everyone can see the curtain that I would buy in a different color ... The other problem is how to keep it, it has me really disconnected, thank you for your attention. -- Client Side addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas function (player) local getGui = guiGetVisible(Ventana2) if source == Boton9a then triggerServerEvent("PonerCortina", localPlayer, localPlayer) PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) local paintjobID = 1 end end) function addPaintjob2(paintjobID,player) if paintjobID == 1 then myTexture = dxCreateTexture( "cortinasRojas.png" ) elseif paintjobID == 2 then myTexture = dxCreateTexture( "cortinasAzules.png" ) else if player == getLocalPlayer() then outputChatBox ("There is no such paintjob ID!") return end end engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) shader_cars, tec = dxCreateShader ( "shader.fx" ) engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) dxSetShaderValue ( shader_cars, "TX0", myTexture ) end addEvent( "setShader", true ) addEventHandler( "setShader", getLocalPlayer(), addPaintjob2 ) Server-Side function Cortina1() local vehicle = getPedOccupiedVehicle( source ) if ( vehicle ) then local pos = {getElementPosition( vehicle )} Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] ) attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 ) triggerClientEvent (players,"setShader",players,cortina) end end addEvent("PonerCortina", true) addEventHandler("PonerCortina", root, Cortina1)
  11. [Alright, first of all: I just joined the Forums, so if i do anything wrong, just tell me.] Ok, so i got a problem, it's about an event i want to trigger on a certain amount of zombie's, or on a certain timer, that's all fine and such.. But, i want to merge some event's into a resource called "zombies", like the 'onZombieWasted' event, but then for a seperated Event, What i mean with that is i want to have a new 'onNemesisWasted' event working together with the 'onZombieWasted', but they need to sync up with the (if possible exported) createZombie function from the "zombies" resource. And i am aiming to make it to a elementData trigger, that i locally created as for example: local Nemesis = export.zombies:createZombie(etc,etc..), So when i check for that element's data on the name 'Nemesis' by existence (as in: if ( isElement ( Nemesis ) ) then) and in combination on the 'onNemesisWasted'- event to check if that export of createZombie (ped works aswel) is dead or not, after all of that if the createZombie (ped) is actually dead, then i wan't it to trigger the reward system together with the other piece's of code. To clear out this idea and problem, i also recorded the ZTown Nemesis Event Script and also post the 2 main scripts that hold me from finishing the Nemesis: The Video of me, quickly explaining what, how, and showing the problem: "youtube" And the 2 script's, there both Server-Side, The Nemesis.lua is changed to test it's functionality and quick testing, but feel free to change the code and re-post it here to function with 'onNemesisWasted' additions!.. the first setTimer(function() is there to prevent complication problems from other zombie resource's and scripts, just delaying it for better run's. Also, the second setTimer(function() is just to delay it's Blip creation and Attaching to prevent the Blip not being attached to the createZombie named nemesis. Nemesis.lua (start/event): function nemesisON() setTimer(function() if ( not isElement ( Nemesis ) ) then local nemesis = exports.zombies:createZombie ( 2343, 57, 26.5, 90, 38, 0, 0, nemesis, 0, "hunting", true ) setPedHeadless(nemesis, true) exports.extrahealth:setElementExtraHealth ( nemesis, 150 ) setElementData ( nemesis, "nemesis", true ) setTimer(function() myBlip = createBlipAttachedTo ( nemesis, 23 ) outputChatBox ('#FFFFFF[#7CFC00ZTown#FFFFFF]: #00BFFF A #00FFFFNemesis #00BFFFHas been spawned inside ZTown! #FFFFFF(#7CFC00Nemesis Boss Event#FFFFFF)', root, 255, 255, 255, true) triggerClientEvent(root, "event", root, "start") end,2500,1) end end,2500,1) end addEventHandler ( "onResourceStart", getRootElement(), nemesisON) monemesi.lua (check/reward): addEvent ( "onNemesisWasted", true ) addEventHandler ( "onNemesisWasted", root, function ( killer ) if ( isElement ( Nemesis ) ) then givePlayerMoney(killer,math.random(5000,25000)) killer = getPlayerName(killer) destroyElement ( myBlip ) outputChatBox ('#FFFFFF[#7CFC00ZTown#FFFFFF]: #00BFFF The #00FFFFNemesis #00BFFFHas been killed! #FFFFFF(#7CFC00Nemesis-Boss Event#FFFFFF)', root, 255, 255, 255, true) triggerClientEvent(root, "event", root, "stop") end end ) I hope sombady could find a way to make this function correctly, because i have try'ed loads of ways, and the way to use slothbot together with zombies resource... nahh, won't work, they wil keep fighting together like d*cks. EDIT: if ( isElement ( Nemesis ) ) = nemesis, i already changed that, but right after i posted it, derp.. Gr.xboxxxxd
  12. BucketBull


    hey guys! I want to make a carshop but i have to trigger a server side marker to client side. The problem is the marker is a part of a function. How shall i trigger the marker?