Jump to content

Search the Community

Showing results for tags 'client'.

  • 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

  1. server triggered clientside event notify, but event is not added clientside I need help with this error, I'm trying a command but when I run this error, someone help me!!! Client: local sound = nil function uiEfeito() exports["Blur"]:dxDrawBluredRectangle(x*0, y*0, x*1366, y*768, tocolor(255, 255, 255, 150)) dxDrawImage(x*0, y*0, x*1366, y*768, "files/gfx/others/efeito.png", 0, 0, 0, tocolor(0, 254, 6, 255), false) end addEvent("worth:fumar:maconha", true) addEventHandler("worth:fumar:maconha", getRootElement(), function() sound = playSound("files/sfx/efeito.mp3", true) setRainLevel(5) addEventHandler("onClientRender", getRootElement(), uiEfeito) setPedControlState(localPlayer, "walk", true) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) setGameSpeed(0.5) setTimer(function() setRainLevel(0) stopSound(sound) resetWindVelocity() setCameraShakeLevel(1) setGameSpeed(1) removeEventHandler("onClientRender", getRootElement(), uiEfeito) end, 33000, 1) end) Server: local algemados = {} local fumando = {} local utilizando = {} local maconhado = {} -- Global mascaras = {} jbl = {} --=-=-=-=-=-=-=-=-=-=-=-=-=-=- [ EVENTO ] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-- addEvent("use:item:worth:inventario", true) addEventHandler("use:item:worth:inventario", getRootElement(), function(player, item, quantidade) local itemInfos = getItemInfos(item) if (itemInfos) then if (itemInfos.outros.evento == "worth:beber") then local sede = (getElementData(player, config["Elements"].Sede) or 0) if (sede < 100) then if not (utilizando[player]) then utilizando[player] = true takeItem(player, item, 1) setElementData(player, config["Elements"].Sede, sede+itemInfos.outros.enche) setPedAnimation(player, "VENDING", "VEND_Drink_P", 4000, false, false, false, false) sendMessageServer(player, "Você bebeu 1x "..itemInfos.nome.."!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/bebendo.mp3") setTimer(function() utilizando[player] = false end, 4000, 1, player) else sendMessageServer(player, "Aguarde para usar este item!", "info") end else sendMessageServer(player, "Você não está com sede!", "error") end elseif (itemInfos.outros.evento == "worth:comer") then local fome = (getElementData(player, config["Elements"].Fome) or 0) if (fome < 100) then if not (utilizando[player]) then utilizando[player] = true takeItem(player, item, 1) setElementData(player, config["Elements"].Fome, fome+itemInfos.outros.enche) setPedAnimation(player, "VENDING", "vend_eat1_P", 4000, false, false, false, false) sendMessageServer(player, "Você comeu 1x "..itemInfos.nome.."!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/comendo.mp3") setTimer(function() utilizando[player] = false end, 4000, 1, player) else sendMessageServer(player, "Aguarde para usar este item!", "info") end else sendMessageServer(player, "Você não está com fome!", "error") end elseif (itemInfos.outros.evento == "worth:arma") then local arma_equip1 = getElementData(player, "llotus:arma:equip:1") or false local arma_equip2 = getElementData(player, "llotus:arma:equip:2") or false for i, v in ipairs(config["Outros"]["Weapons_Primary"]) do if (v[1] == item) then if (arma_equip1 == false) then takeItem(player, item, 1) setElementData(player, "llotus:arma:equip:1", {item, v[2]}) giveWeapon(player, v[2], 1) sendMessageServer(player, "Você equipou a sua arma primaria!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/reload.mp3") else sendMessageServer(player, "Você já tem 1 arma primaria equipada!", "error") end end end for i, v in ipairs(config["Outros"]["Weapons_Secundary"]) do if (v[1] == item) then if (arma_equip2 == false) then takeItem(player, item, 1) setElementData(player, "llotus:arma:equip:2", {item, v[2]}) giveWeapon(player, v[2], 1) sendMessageServer(player, "Você equipou a sua arma secundaria!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/reload.mp3") else sendMessageServer(player, "Você já tem 1 arma secundaria equipada!", "error") end end end elseif (itemInfos.outros.evento == "worth:munição") then local arma_equip1 = getElementData(player, "llotus:arma:equip:1") or false local arma_equip2 = getElementData(player, "llotus:arma:equip:2") or false for i, v in pairs(config["Outros"]["Ammo_Weapons"]) do if (i == item) then for index, arma in pairs(v) do if (arma_equip1) and (arma == arma_equip1[1]) then setElementData(player, "llotus:ammo:equip:1", item) takeItem(player, item, quantidade) giveWeapon(player, arma_equip1[2], quantidade) reloadPedWeapon(player) sendMessageServer(player, "Você recarregou sua arma!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/reload.mp3") end if (arma_equip2) and (arma == arma_equip2[1]) then setElementData(player, "llotus:ammo:equip:2", item) takeItem(player, item, quantidade) giveWeapon(player, arma_equip2[2], quantidade) reloadPedWeapon(player) sendMessageServer(player, "Você recarregou sua arma!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/reload.mp3") end end end end elseif (itemInfos.outros.evento == "worth:colete") then local colete = getPedArmor(player) if (colete <= 80) then takeItem(player, item, 1) setPedArmor(player, 100) sendMessageServer(player, "Você equipou o seu colete!", "success") else sendMessageServer(player, "Você já tem 1 colete bom equipado!", "error") end elseif (itemInfos.outros.evento == "worth:algemar") then local target = getNearestPlayer(player, 2) if (target) then if not (algemados[target]) then algemados[target] = true setElementFrozen(target, true) toggleAllControls(target, false) setPedAnimation(target, "GRAVEYARD", "mrnM_loop", -1, true, false, false, false) takeItem(player, item, 1) sendMessageServer(player, "Você algemou o cidadão!", "success") sendMessageServer(target, "Você foi algemado!", "info") else sendMessageServer(player, "Este cidadão já está algemado!", "error") end else sendMessageServer(player, "Chegue mais perto do cidadão para algema-lo!", "error") end elseif (itemInfos.outros.evento == "worth:desalgemar") then local target = getNearestPlayer(player, 2) if (target) then if (algemados[target]) then algemados[target] = false setElementFrozen(target, false) toggleAllControls(target, true) giveItem(player, "Algemas", 1) setPedAnimation(target, nil) sendMessageServer(player, "Você desalgemou o cidadão!", "success") sendMessageServer(target, "Você foi desalgemado!", "info") else sendMessageServer(player, "Este cidadão não está algemado!", "error") end else sendMessageServer(player, "Chegue mais perto do cidadão para algema-lo!", "error") end elseif (itemInfos.outros.evento == "worth:analgesico") then local vida = getElementHealth(player) if (vida < 100) then takeItem(player, item, 1) setElementHealth(player, vida+10) sendMessageServer(player, "Você usou 1x "..itemInfos.nome.."!", "success") else sendMessageServer(player, "Você já esta com sua saude boa!", "error") end elseif (itemInfos.outros.evento == "worth:bandagem") then local vida = getElementHealth(player) if (vida < 100) then takeItem(player, item, 1) setElementHealth(player, vida+20) sendMessageServer(player, "Você usou 1x "..itemInfos.nome.."!", "success") else sendMessageServer(player, "Você já esta com sua saude boa!", "error") end elseif (itemInfos.outros.evento == "worth:cigarro") then local isqueiro = getItem(player, "Isqueiro") if (isqueiro and isqueiro >= 1) then local vida = getElementHealth(player) if (vida-5 > 20) then if not (fumando[player]) then fumando[player] = true takeItem(player, item, 1) setElementHealth(player, vida-5) setPedAnimation(player, "GANGS", "smkcig_prtl_F", 8000, false, false, false, false) sendMessageServer(player, "Você fumou 1x "..itemInfos.nome.."!", "success") triggerClientEvent(player, "worth:play:sound:client", player, "files/sfx/fumando.mp3") setTimer(function() fumando[player] = false end, 8000, 1, player) else sendMessageServer(player, "Aguarde para fumar novamente!", "info") end else sendMessageServer(player, "Você está com a saúde baixa!", "error") end else sendMessageServer(player, "Você precisa ter um isqueiro para fumar!", "error") end elseif (itemInfos.outros.evento == "worth:kitreparo") then if not (isPedInVehicle(player)) then local vehicle = getNearestVehicle(player, 3) if (vehicle) then local health = getElementHealth(vehicle) if (health < 900) then takeItem(player, item, 1) fixVehicle(vehicle) sendMessageServer(player, "Você concertou o veiculo!", "success") else sendMessageServer(player, "Veiculo não está danificado!", "error") end else sendMessageServer(player, "Você está longe de mais de um veiculo!", "error") end else sendMessageServer(player, "Você não pode está dentro de um veiculo!", "error") end elseif (itemInfos.outros.evento == "worth:maço") then if (getSpaceItem(player, "Cigarro", 20)) then takeItem(player, item, 1) giveItem(player, "Cigarro", 20) sendMessageServer(player, "Você abriu 1x "..itemInfos.nome.."!", "success") else sendMessageServer(player, "Você não tem espaço para cigarros!", "error") end elseif (itemInfos.outros.evento == "worth:kitmedico") then local vida = getElementHealth(player) if (vida < 100) then takeItem(player, item, 1) setElementHealth(player, 100) sendMessageServer(player, "Você usou 1x "..itemInfos.nome.."!", "success") else sendMessageServer(player, "Você já esta com sua saude boa!", "error") end elseif (itemInfos.outros.evento == "worth:mochila") then local pesoAtual, pesoMaximo = getSpace(player) if not (pesoMaximo == itemInfos.outros.pesoSuportado) then if (pesoAtual <= itemInfos.outros.pesoSuportado) then inventarios[player]["Dados"].pesoMaximo = itemInfos.outros.pesoSuportado updateClientInventory(player) takeItem(player, item, 1) sendMessageServer(player, "Você colocou 1x "..itemInfos.nome.."!", "success") else sendMessageServer(player, "Você não pode por está mochila, ela é muito pequena para oque você esta carregando!", "error") end else sendMessageServer(player, "Você já está usando esta mochila!", "error") end elseif (itemInfos.outros.evento == "worth:nitro") then local parafusadeira = getItem(player, "Parafusadeira") if (parafusadeira and parafusadeira >= 1) then if not (isPedInVehicle(player)) then local vehicle = getNearestVehicle(player, 3) if (vehicle) then takeItem(player, item, 1) setElementFrozen(player, true) setPedAnimation(player, "BOMBER", "BOM_Plant", 3000, false, false, false, false) sendMessageServer(player, "Você começou a instalar o nitro!", "info") setTimer(function(player, vehicle) addVehicleUpgrade(vehicle, "1010") setPedAnimation(player, nil) setElementFrozen(player, false) sendMessageServer(player, "Você instalou o nitro no seu veiculo!", "success") end, 3000, 1, player, vehicle) else sendMessageServer(player, "Você está longe de mais de um veiculo!", "error") end else sendMessageServer(player, "Você não pode está dentro de um veiculo!", "error") end else sendMessageServer(player, "Você precisa ter uma parafusadeira!", "error") end elseif (itemInfos.outros.evento == "worth:bolar") then local dichavador = getItem(player, "Dichavador") if (dichavador and dichavador >= 1) then local seda = getItem(player, "Seda") if (seda and seda >= 1) then local maconha = getItem(player, "Maconha") if (maconha and maconha >= 1) then takeItem(player, "Seda", 1) takeItem(player, "Maconha", 1) giveItem(player, "CigarroMaconha", 1) sendMessageServer(player, "Você bolou um baseado!", "success") else sendMessageServer(player, "Você precisa ter uma maconha!", "error") end else sendMessageServer(player, "Você precisa ter uma seda!", "error") end else sendMessageServer(player, "Você precisa ter um dichavador!", "error") end elseif (itemInfos.outros.evento == "worth:moeda") then local random = math.random(1, 100) if (random > 50) then outputChatBox(getPlayerName(player).." jogou a moeda e deu cara!", root, 255, 255, 255, false) else outputChatBox(getPlayerName(player).." jogou a moeda e deu coroa!", root, 255, 255, 255, false) end elseif (itemInfos.outros.evento == "worth:caixaseda") then if (getSpaceItem(player, "Seda", 10)) then takeItem(player, item, 1) giveItem(player, "Seda", 10) sendMessageServer(player, "Você abriu 1x "..itemInfos.nome.."!", "success") else sendMessageServer(player, "Você não tem espaço para sedas!", "error") end elseif (itemInfos.outros.evento == "worth:dado") then local x, y, z = getElementPosition(player) local random = math.random(1, 6) for i, v in ipairs(getElementsByType("player")) do local x2, y2, z2 = getElementPosition(v) local distancia = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if (distancia <= 5) then outputChatBox(getPlayerName(player).." jogou o dado e caiu "..random.." !", v, 255, 255, 255, false) end end elseif (itemInfos.outros.evento == "worth:pegar:jbl") then if (playerInAclTable(player, itemInfos.outros.acls)) then if not (jbl[player]) then local dim = getElementDimension(player) jbl[player] = createObject(2226,0,0,0) setElementDimension(jbl[player], dim) setObjectScale(jbl[player], 0.95) exports.bone_attach:attachElementToBone(jbl[player], player, 12, 0, 0, 0.4, 0, 180, 0) sendMessageServer(player, "Você pegou a JBL!", "success") else exports.bone_attach:detachElementFromBone(jbl[player], player) if (isElement(jbl[player])) then destroyElement(jbl[player]) end triggerClientEvent(root, "worth:parar:musica:jbl", root, player, jbl[player]) jbl[player] = nil sendMessageServer(player, "Você guardou a JBL!", "success") end else sendMessageServer(player, "Você não tem permissão para usar este item!", "error") end elseif (itemInfos.outros.evento == "worth:textura:jbl") then if (playerInAclTable(player, itemInfos.outros.acls)) then if (jbl[player]) then triggerEvent("worth:server:aplicar:textura", player, jbl[player], itemInfos.outros.textureID) sendMessageServer(player, "Você aplicou a textura na JBL!", "success") else sendMessageServer(player, "Você não tem uma JBL em mãos!", "error") end else sendMessageServer(player, "Você não tem permissão para usar este item!", "error") end elseif (itemInfos.outros.evento == "worth:cigarromaconha") then local isqueiro = getItem(player, "Isqueiro") if (isqueiro and isqueiro >= 1) then if not (maconhado[player]) then maconhado[player] = true triggerClientEvent(player, "worth:fumar:maconha", player) takeItem(player, item, 1) setTimer(function() maconhado[player] = false end, 33000, 1, player) else sendMessageServer(player, "Aguarde para fumar maconha novamente!", "info") end else sendMessageServer(player, "Você precisa de um isqueiro para fumar maconha!", "error") end elseif (itemInfos.outros.evento == "worth:mascaras") then if not (getElementData(player, "worth:mascara:equipada")) then setElementData(player, "worth:mascara:equipada", item) local mascara_vestida = getElementData(player, "worth:mascara:equipada") sendMessageServer(player, "Você vestiu a mascara "..itemInfos.nome.." !", "success") mascaras[player] = createObject(itemInfos.outros.idObject, 0, 0, 0, 0, 0, 0) takeItem(player, item, 1) if (mascara_vestida == "Cachorro") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.02, -0.55, 0, 0, 90) elseif (mascara_vestida == "Palhaco") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.02, -0.55, 0, 0, 90) elseif (mascara_vestida == "Samurai") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.02, -0.55, 0, 0, 90) elseif (mascara_vestida == "Bandana") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.02, -0.58, 0, 0, 90) elseif (mascara_vestida == "Dogao") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.02, -0.55, 0, 0, 90) elseif (mascara_vestida == "Macaco") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.01, -0.55, 0, 0, 90) elseif (mascara_vestida == "Bandido") then exports["bone_attach"]:attachElementToBone(mascaras[player], player, 1, 0, 0.02, -0.55, 0, 0, 90) end else sendMessageServer(player, "Você já tem uma mascara vestida!", "error") end end end end)
  2. When I randomly tap my voice button or just hold it for sec, I experience bug when event "onClientPlayerVoiceStop" is not being called. Anyone experience it yet? Image with UI representation of bug https://imgur.com/a/LfysaBA thanks for any replay ;)
  3. getJobMarker = createMarker(872.03754, -29.07278, 62.3000, "cylinder", 1.0, 0, 255, 255, 255, getRootElement()) ped = createPed(159, 872.92389, -27.08743, 63.94565, 160) setPedFrozen(ped, true) blip = createBlipAttachedTo(getJobMarker, 56) function hitMarkerWindow() window = guiCreateWindow(0.35, 0.35, 0.35, 0.30, "wood job", true) memo = guiCreateMemo(0.10, 0.20, 0.80, 0.4, "this is wood cutting job", true, window) accept = guiCreateButton(0.10, 0.75, 0.22, 0.14, "Accept Job", true, window) leave = guiCreateButton(0.35, 0.75, 0.22, 0.14, "Leave Job", true, window) close = guiCreateButton(0.60, 0.75, 0.22, 0.14, "Close", true, window) showCursor(true) guiMemoSetReadOnly(memo, true) end addEventHandler("onClientMarkerHit", getJobMarker, hitMarkerWindow) function clientClick() if source == close then guiSetVisible(window, false) showCursor(false) triggerServerEvent("cancelButton", resourceRoot, localPlayer) elseif source == accept then guiSetVisible(window, false) showCursor(false) triggerServerEvent("acceptWoodJob", resourceRoot, localPlayer) elseif source == leave then guiSetVisible(window, false) showCursor(false) triggerServerEvent("leaveJob", resourceRoot, localPlayer) end end addEventHandler("onClientGUIClick", root, clientClick)
  4. Hello, I recently returned to making a server after a year and I wanted to remind myself how the "source", "root", "this", "sourceResource", "sourceResourceRoot", "client" etc. Elements worked. Unfortunately, when I checked the MTA wiki, I didn't understand any of these elements. In general, the best help would be if someone explained to me how these elements work on examples for AddEventHandler because in mta wiki there is only one example for a "source" and I guess "root"? element
  5. It's about cambering the cars, but when I use the script and turn on ENBseries, the tires disappear due to a reflection that appears in the script for the tires. I want to remove that reflection from the resource. A video to watch : https://drive.google.com/file/d/1LmfHwTCUimI2Zb9B4CGD9KovExWfb4Cs/view?usp=sharing The resource: https://drive.google.com/file/d/1oUXeCGbVBb8uJbmUoesovndYl3rGumny/view?usp=sharing Help me please
  6. function fetchRemoteE() fetchRemote("site", function(responseData, errors) if errors == 0 then local finalResult = "Liberar" if responseData:match(finalResult) then -- ERRO ( Está comparando com todas as linhas do site juntas, ao invez de uma por uma.) print("FUNCIONANDO") else print(errors) print(responseData) print(finalResult) end end end) end COMO EU PODERIA FAZER PARA ELE COMPARAR LINHA POR LINHA COM O 'finalResult' ?
  7. (Sorry if the text contains errors, I'm Russian). Hello! I decided to make a telephone. As we know, in order to create a picture on the screen, we need a client. But, since the main part is on the server, you need to call the client function on the server. It seems like I did everything right (you can see the screenshots below), but it does not work: the picture does not appear. No errors are displayed in the console. Can you please help with this error? Server Client
  8. Всем привет! Я решил сделать телефон. Как мы знаем, чтобы создать картинку на экране, нам нужен клиент. Но, так как основная часть на сервере, нужно вызвать клиентскую функцию на сервере. Вроде как сделал всё правильно (скриншоты можете видеть ниже), но не работает: картинка не появляется. В консоле никаких ошибок не выводится. Можете, пожалуйста, помочь с этой ошибкой? Сервер Клиент
  9. Esta Dando Esse Erro 'end' expected (to close 'function' at line 5) near '<eof>' Server-Side function dxMsg(source, text, type) exports.dxmessages:outputDx(source, text, type) end function darDinheiro (source) if commandDelay[source] == nil and not istimer(commandDelay[source]) then local Dinheiro = getPlayerMoney(source) if Dinheiro >= 1200 then return dxMsg(source, "Você possui dinheiro de mais para receber o auxílio.", "error") end givePlayerMoney(source, 1200) dxMsg(source, "Você recebeu o auxílio.", "success") resetCommand(source, 1000) else dxMsg(source, "Você ja recebeu o auxílio.", "warning") end addCommandHandler('auxilio', darDinheiro)
  10. I would like to know about two things: 1. Are the server-side and client-side timers dangerous and why? 2. Is it possible to do the function GetTickCount () timer?
  11. I have one question about client objects, if I use the "TriggerClientEvent" function on the server side script, whether the object that was saved on the client side and will be set with the triggerClientEvent function on the server side, will every player see it and will work in the same way as normally I would call it in the server side script "createObject (object, x, y, z)"? For example, such -- client addEvent("createObject", true) addEventHandler("createObject", root, function(object, x, y, z) createObject(x, y, z) end ) -- server triggerClientEvent(root, "createObject", root, 1372, 0, 0, 5) -- Would that be the same as this? -- server createObject(1372, 0, 0, 5)
  12. moh2006

    help in code

    plz help in car trunk code client GUIEditor = { button = {}, window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(1105, 265, 251, 282, "car remote", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1],false) GUIEditor.button[1] = guiCreateButton(23, 35, 88, 45, "unlock", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(144, 35, 88, 45, "lock", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(144, 127, 88, 45, "trunk", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(23, 127, 88, 45, "start", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(83, 211, 88, 45, "close", false, GUIEditor.window[1]) end ) local Key = "F7" bindKey(Key,"down", function() guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) addEventHandler("onClientGUIClick",root,function() if (source == GUIEditor.button[5]) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end) addEventHandler("onClientGUIClick",root,function() if (source == GUIEditor.button[5]) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end) addEventHandler("onClientGUIClick", getRootElement() , function (state) if state == "left" then if source == GUIEditor.button[2] then local spieler = getLocalPlayer() triggerServerEvent("doLockVehicle", spieler, spieler) end end end ) addEventHandler("onClientGUIClick", getRootElement() , function (state) if state == "left" then if source == GUIEditor.button[1] then local spieler = getLocalPlayer() triggerServerEvent("doUnlockVehicle", spieler, spieler) end end end ) addEventHandler("onClientGUIClick", getRootElement() , function (state) if state == "left" then if source == GUIEditor.button[4] then local spieler = getLocalPlayer() triggerServerEvent("motoranaus", spieler, spieler) end end end ) addEventHandler("onClientGUIClick", getRootElement() , function (state) if state == "left" then if source == GUIEditor.button[3] then local spieler = getLocalPlayer() triggerServerEvent("trunk", spieler, spieler) end end end ) -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSound("siren.mp3") -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) function resourcestart () guiSetVisible(carbild, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourcestart) function fenster( ) guiSetVisible ( carbild, not guiGetVisible ( carbild ) ) showCursor ( guiGetVisible ( carbild ) ) end bindKey("z", "down", fenster) --[[ function oeffne_fenster() local IsWindowVisible = guiGetVisible(carbild) if (IsWindowVisible == true) then guiSetVisible(carbild, false) showCursor(false) end if (IsWindowVisible == false) then guiSetVisible(carbild, true) showCursor(true) end end bindKey("z", "down", oeffne_fenster) ]]-- addEventHandler("onClientGUIClick", getRootElement() , function (state) if state == "left" then if source == start_stop_b then local spieler = getLocalPlayer() triggerServerEvent("motoranaus", spieler, spieler) end end end ) server function motoran ( source ) local theVehicle if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then -- off or not set local lights = getVehicleOverrideLights ( theVehicle ) if ( getElementData( theVehicle, "cl_enginestate" ) == false ) then setElementData( theVehicle, "cl_enginestate", true) setVehicleEngineState( theVehicle, true ) else -- on -- set to off setElementData( theVehicle, "cl_enginestate", false ) setVehicleEngineState( theVehicle, false ) end setVehicleOverrideLights ( theVehicle, lights ) else Err_Msg("ليس لديك سيارة", source ) end end addEvent("motoranaus",true) addEventHandler("motoranaus", getRootElement() , motoran) -- ================= -- Car Locks ( server ) -- by moh2006 -- ================= -- player element data -- -- cl_ownedvehicle -- vehicle element data -- -- cl_vehicleowner -- cl_vehiclelocked -- cl_enginestate -- resource starts - ends function initCarLocks () -- Initilize Player Element Data local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "l", "down", doToggleLocked ) end -- Initilize Vehicle Element Data local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) -- player joins function cl_PlayerJoin ( ) bindKey ( source, ";", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) -- player quits function cl_PlayerQuit ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) -- player dies function cl_PlayerWasted ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) -- player tries to enter vehicle function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner -- locked and not owner entering if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then -- make sure they dont enter --cancelEvent(); end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) -- player enters a vehicle function cl_PlayerDriveVehicle ( player, seat, jacked ) -- Driver Enter if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) -- not entering player's own owned vehicle if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePlayerFromVehicle( player ) Err_Msg("Este veículo está trancado.", player) return false end -- set element data for vehicle and owner cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) -- vehicle respawns function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) -- vehicle explosion function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) -- set vehicle owner function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then -- unlock old car removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) removeElementData ( oldVehicle, "cl_enginestate" ) setVehicleLocked ( oldVehicle, false ) -- set vars for new car end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( owned, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end -- flash the lights twice function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end -- flash once function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end -- get vehicle owner ( according to vehicle's element data ) function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end -- is vehicle locked ( according to vehicle's element data ) function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end -- messaging functions -- send red error message function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end -- send message to all occupants of vehicle function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end -- send aquamarine message to player function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end -- commands function doToggleLockeds ( source ) local theVehicle , strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) -- already locked if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("ليس لديك سيارة", source) end end addEvent("doUnlockVehicle",true) addEventHandler("doUnlockVehicle", getRootElement() , doToggleLockeds) function doToggleLocked ( source ) local theVehicle , strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) -- already locked if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then strout = "Your " .. vehiclename .. " is already locked." Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", true) setVehicleLocked ( theVehicle, true ) Car_Msg( "Arac " .. vehiclename .. " قفل السيارة.", theVehicle) Info_Msg ( "تم فك قفل السيارة", source ) if ( getVehicleController ( theVehicle ) == false ) then cl_FlashLights ( source ) end end else Err_Msg("ليس لديك سيارة", source) end end addEvent("doLockVehicle",true) addEventHandler("doLockVehicle", getRootElement() , doToggleLocked) function doUnlockVehicle ( source ) local theVehicle, strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == false ) then strout = "السيارات " .. vehiclename .. " مقفلة بالفعل." Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", false) setVehicleLocked ( theVehicle, false ) Car_Msg( "السيارة " .. vehiclename .. " فتحت.", theVehicle ) Info_Msg ( "فتح القفل.", source ) if ( getVehicleController ( theVehicle ) == false ) then cl_FlashOnce ( source ) end end else Err_Msg("ليس لديك سيارة", source) end end function doToggleLights ( source, beep ) local theVehicle if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then -- if he was in one if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then -- if the current state isn't 'force on' setVehicleOverrideLights ( theVehicle, 2 ) -- force the lights on -- play sound close to element if ( beep == true ) then local theElement = theVehicle triggerClientEvent ( getRootElement(), "onPlaySoundNearElement", getRootElement(), theElement, 5) end else setVehicleOverrideLights ( theVehicle, 1 ) -- otherwise, force the lights off end else Err_Msg("ليس لديك سيارة", source ) end end addEvent("doToggleLight",true) addEventHandler("doToggleLight", getRootElement() , doToggleLights) addCommandHandler ( "engine", motoran ) addCommandHandler ( "lights", doToggleLight, false) addCommandHandler ( "lock", doLockVehicle ) addCommandHandler ( "unlock", doUnlockVehicle ) addCommandHandler ("trunk", trunk) if you help thanks for help....
  13. Hello MTA team i've expected an error while trying to run mta on linux . this is the screenshot of the error : https://cdn.discordapp.com/attachments/623268793803603999/757220417923448862/unknown.png and thank you in advance :)
  14. Hello there. I'm looking for way to make markers of type 'arrow' to move up and down like enex markers in singleplayer, how can I do it?
  15. function StandardWep() local x, y, z = getElementPosition(getLocalPlayer()) wep = createWeapon("m4", x+5, y, z) setWeaponFlags(wep, "shoot_if_blocked", false) setWeaponFiringRate(wep, 35) setWeaponProperty(wep, "damage", 25) setWeaponClipAmmo(wep, 35) setWeaponAmmo(wep, 100) end addCommandHandler("OnStandardWep", function(command, state) local s = string.upper(state) if s=="ON" then setWeaponState(wepM16, "firing") elseif s=="false" then setWeaponState(wepM16, "ready") else outputChatBox("There is no such condition of the weapon, you can only use 'ON / OFF'", 255, 50, 0) end end ) The point is that it does not hurt other players, what's more, other players do not even see the line of fire (I mean the yellow line which means how fast the bullets are moving and in which direction) and the weapon itself (M4), I know that you need to use triggerClientEvent but no I know how to apply it, please help me with an example ; -;
  16. The question is the following needs to get an item from the server side to the client side, how can I do it? (Elements such as markers, vehicles etc.)
  17. I would like to know how I could get ElementData from server to client and vice versa -- server side marker = createMarker(0, 0, 1.5, "cylinder", 2, 255, 0, 0) setElementData(marker, "Item", 5) addEvent("GetItem", true) addEventHandler("GetItem", root, function() ClientMarker = marker ItemOfClientMarker = getElementData(marker, "Item") end) addEventHandler("onMarkerHit", marker, function(hp) triggerClientEvent("Element", resourceRoot) setElementData(hp, "ItemTwo", ElementVariable+getElementData(marker, "Item")) end) -- client side function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end setElementData(getLocalPlayer(), "ItemTwo", 0) addEvent("Element", true) addEventHandler("Element", root, function() ElementVariable = getElementData(getLocalPlayer() , "ItemTwo") end) addEventHandler("onClientRender", root, function() triggerServerEvent("GetItem", root) dxDrawTextOnElement(ClientMarker, tostring(ItemOfClientMarker), 2, 50, 255, 255, 0, 3, "arial") end) Does it have a chance to work? because that's something I imagine...
  18. The case looks like this, I have a variable (Let's call it Ammo) that IS TO be in the giveWeapon function (source, 22, Ammo, true) but the problem is that this Ammo variable has the script type "client" and the function is the server script type, so how can I make this variable in this function? If someone has not understood what is going on, there is still a code to simplify... -- Client side local Ammo = 60 local AmmoMarker = createMarker(0, 0, 1, "cylinder", 2.0) local WeaponMarker = createMarker(0, 0, 1, "cylinder", 2.0) addEventHandler("onClientMarkerHit", AmmoMarker, function() Ammo = Ammo + 1 end) addEventHandler("onClientMarkerHit", WeaponMarker, function() -- Here I get a weapon, the variable "Ammo" is the number of bullets end) -- Server Side --??? Problem with importing variable "Ammo"
  19. 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.
  20. Hello, I have a doubt: Is possible enable individually Cbug? By example: Type /cbug and the player that typed the command can get the glitches activated, not the other players. It's possible?
  21. Hi, I want to get list of visible elements (in my case pickups) to player in client-side code so I can loop through these elements. By visible, I mean literally player can "see" with their own eyes. You can also think it as loaded/rendered elements within given range. eg. element list of in 400.0 meters radius with player in center. I couldn't find proper function for it. Thank you for your further helps. Edit: these pickups are created server-side
  22. Hello, does anyone here know how to install MTA without administrator privileges? I can't install it on my old computer since the admin account is disabled. I just wanna play the game, but it says that I've to have admin perms. Does anyone have a portable MTA or something?
  23. I've been working on a script that realistically manipulates the wheels. I've gotten to the point I can hide the original wheels, in hopes I can later attach a new set in the same place. I'm aware I might have to use attachElements, and several other functions. For the moment, I'd like to attach a single wheel. I've got this: -- All GUI elements. local vehicle = getPedOccupiedVehicle(localPlayer) local x1, y1, z1 = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local x2, y2, z2 = getVehicleComponentPosition(vehicle, "wheel_rf_dummy") local x3, y3, z3 = getVehicleComponentPosition(vehicle, "wheel_lb_dummy") local x4, y4, z4 = getVehicleComponentPosition(vehicle, "wheel_rb_dummy") local function replace1 () attachElements (1097, vehicle, x1, y2, z1, 0, 0, 0) end addEventHandler ("onClientGUIClick", set1, replace1, false) -- Function runs when button called 'set1' is clicked. -- Everything else. Here's my thought process: First, I get the player's vehicle. Then, I get the position of all four wheels in the player's vehicle, and represent them with x1, y1 and z1. With all wheels hidden by another function, I then attach the wheel model in the same place as the front left wheel. At the moment, I'm only aiming at the position; I'll handle the rotation later. DB 3 can't identify '1097', and thus asks for a valid element. Am I on the right path?
  24. I decided to dive into the world of rotations. I know this might be incomplete and even incorrect: function openCapo() local theVeh = getPedOccupiedVehicle(localPlayer) local value1 = guiScrollBarGetScrollPosition(caposcroll) if theVeh and value1 then setVehicleComponentRotation (theVeh, bonnet_dummy, value1, rY, rZ) end end I've a GUI already created, and the visibility key bound. The first scrollbar (caposcroll) should affect the bonnet_dummy. This was made with absolute basic thinking process: "if I want doors to open, I need to get the position of the scrollbar". However, I know I still need to tell the game what's the math.min, what's the math.max, and, I think, to also give the order to respond only when the scrollbar is moved. I would appreciate a finger to point me in the right direction.
  25. Here's the script: inFourD = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function inFourDragons (player, matchingDimension) if (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == true) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", hitPlayer, 0, 0, 0, true) elseif (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == false) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Ingresaste al casino '#DD0000Four Dragons#FFFFFF'.", hitPlayer, 0, 0, 0, true) setElementInterior (player, 10) setElementPosition (player, 2016.9376220703, 1017.0843505859, 996.875 ) setElementRotation (player, 0, 0, 90) end end addEventHandler ("onMarkerHit", getRootElement(), inFourDragons) Doing it client-side gives the invisible players. I read an old post that this had to be done server-side to fix the invisible players; however, I can't pinpoint the problem. As of this moment, with this script: - When in vehicle, player + vehicle is teleported to the same coords and interior 10, which results in an invisible world, player and vehicle, and it outputs "You've entered FDC.", when it should enter "Cars are not allowed". - When on foot, nothing happens. What could be the problem?
×
×
  • Create New...