Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 28/03/20 in all areas

  1. local myCar = getPedOccupiedVehicle(source) Source of this event is the player that left vehicle not the vehicle itself, also you can directly use the vehicle argument of your function function removeHelmetOnExit ( vehicle, seat, jacked ) local engine = getVehicleEngineState (vehicle) if engine then setElementData(vehicle,"engine",1) elseif not engine then setElementData(vehicle,"engine",0) end end addEventHandler ( "onPlayerVehicleExit", getRootElement(), removeHelmetOnExit )
    2 points
  2. Yes, I see no problem in the code.
    1 point
  3. Hello enzoDs, you seem to know about the functions toJSON and fromJSON, don't you? If you have any problems with using these functions then please explain and we will help you
    1 point
  4. Mais fácil vc simplesmente impedir que caracteres não numéricos apareçam naquele campo de input. Dessa forma, se apertar em alguma letra ou símbolo, não vai acontecer nada. addEventHandler ("onClientGUIChanged", moneyedit, function() guiSetText (source, string.gsub (guiGetText (source), "%D", "")) -- Apaga qualquer caractere não numérico do moneyedit. end)
    1 point
  5. Basicamente, seu erro diz o seguinte : Foi enviado um trigger do server-side para o client-side , porem, quando foi chamado esse evento, não foi encontrado no seu client-side, porquê? está dentro de uma função. Modo Errado (O que você fez). function fechar_painel () if painel == true then painel = false removeEventHandler("onClientRender", getRootElement(), dx_Painel) addEvent("Event:Fechar_Painel", true) --/> O ERRO ESTA AQUI ! addEventHandler("Event:Fechar_Painel", getRootElement(), fechar_painel) --/> O ERRO ESTA AQUI ! end end Modo Correto. function fechar_painel () if painel == true then painel = false removeEventHandler("onClientRender", getRootElement(), dx_Painel) end end addEvent("Event:Fechar_Painel", true) addEventHandler("Event:Fechar_Painel", getRootElement(), fechar_painel)
    1 point
  6. Let me help you a little bit. Please replace your client-side script with this: client-side function setTimeClientSide (timehour,timeminute) setTime(timehour,timeminute) end addEvent( "eventSetTimeOnJoin", true ) addEventHandler( "eventSetTimeOnJoin", localPlayer, setTimeClientSide ) triggerServerEvent("playerIsReady", localPlayer) I have got years of experience in making MTA resources and this client synchronization is a common issue I faced.
    1 point
  7. addCommandHandler("wv", function(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) for index, value in ipairs(getElementsWithinColShape(colshape, "vehicle")) do if (getElementData(value, "uid") == 0) then setVehicleLocked ( value, true ) outputChatBox("lock", player, 220, 220, 0) break -- only one car. end end end) The line that I added is line 7. If you have a way to get the real "uid" by player then please modify that if-condition.
    1 point
  8. How do you want to decide which car they player "needs" or wants to close? Does the player have a list of cars that he owns?
    1 point
  9. I think that Bartje has given you a really good script. Using the recommended script you can create a "remote car key" script where you lock all vehicles that are close to your player. Let me help you by fixing it: addCommandHandler("wv", function(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) for index, value in ipairs(getElementsWithinColShape(colshape, "vehicle")) do setVehicleLocked ( value, true ) outputChatBox("lock", player, 220, 220, 0) end end)
    1 point
  10. 1 point
  11. Good solution! Sorry if my reply were a little confusing because I tried to understand the scope of your problem. But if you just want to use the standard game time system then this should work. But you made one tiny mistake: you used the event "onPlayerJoin" for the clientside addEventHandler call, should have been "eventSetTimeOnJoin". clientside script: function setTimeClientSide (timehour,timeminute) setTime(timehour,timeminute) end addEvent( "eventSetTimeOnJoin", true ) addEventHandler( "eventSetTimeOnJoin", localPlayer, setTimeClientSide ) EDIT: there is a race condition in your script if the client has not loaded the Lua files yet but you trigger the eventSetTimeOnJoin anyway. To fix that you have to trigger a server event "onPlayerReady" at the end of your clientside script, then add this event "onPlayerReady" on the server-side + attach the server-side event handler, previously from "onPlayerJoin", you made to that.
    1 point
  12. Not exactly sure what your question is. But I do believe this topic could help you out: Check out 'myonlake's' reply on it. He draws a colshape on the players position and warps all vehicle within that range to his location. You could use this code as well but instead of warping the vehicles, you could do other things with them like opening or closing the doors. Is this what you were looking for?
    1 point
  13. obrigado mt Lord henry e CrowleySCR e foi mal ter pego bastante do tempo de vcs mais serio vcs ajudaram um server a crescer vlw
    1 point
  14. Sounds like a lag issue due to the server-side event "onPlayerVehicleEnter". Could you try using the clientside event "onClientPlayerVehicleEnter" instead and using the clientside version of setVehicleLightState?
    1 point
  15. iniMarker = createMarker( 1191.2342529297, -1356.9774169922, 13.377763748169, "cylinder", 1.5, 255,255,255,50) destroyM = createMarker( 1188.9282226563, -1316.4439697266, 13.565052032471, "cylinder", 1.9, 255,255,255,100) function msg(player) outputChatBox("#ffffff»Voce Pegou Uma Viatura«®", player, 255,255,255,true) end addEventHandler("onMarkerHit", iniMarker, msg) veh = {} function spawnVehicle(player) if isElementWithinMarker(player, iniMarker) then if veh[player] and isElement( veh[player] ) then destroyElement(veh[player]) veh[player] = nil end veh[player] = createVehicle(520, 1196.2437744141, -1381.0944824219, 13.293451309204) warpPedIntoVehicle(player, veh[player]) end end addEventHandler("onMarkerHit", iniMarker, spawnVehicle) function msgDestroy(player) outputChatBox("Voce Destroiu uma Viatura", player, 255,255,255,true) end addEventHandler("onMarkerHit", destroyM, msgDestroy) function destroy(player) if isElementWithinMarker(player, destroyM) then if isPedInVehicle(player) == true then destroyElement(veh[player]) outputChatBox("", player, 255,255,255,true) else outputChatBox("", player, 255,255,255,true) end end end addEventHandler("onMarkerHit", destroyM, destroy) -------------------------------------------------------------------------- iniMarker2 = createMarker( 1321.8447265625, -1387.7661132813, 13.605491638184, "cylinder", 1.5, 255,255,255,50) destroyM2 = createMarker( 1316.8660888672, -1413.1188964844, 13.507630348206, "cylinder", 1.9, 255,255,255,100) function msg(player) outputChatBox("#ffffff»Voce Pegou Uma Viatura«®", player, 255,255,255,true) end addEventHandler("onMarkerHit", iniMarker2, msg) veh = {} function spawnVehicle(player) if isElementWithinMarker(player, iniMarker2) then if veh[player] and isElement( veh[player] ) then destroyElement(veh[player]) veh[player] = nil end veh[player] = createVehicle(590, 1288.7540283203,-1403.7777099609,13.142773628235) warpPedIntoVehicle(player, veh[player]) end end addEventHandler("onMarkerHit", iniMarker2, spawnVehicle) function msgDestroy(player) outputChatBox("Voce Destroiu uma Viatura", player, 255,255,255,true) end addEventHandler("onMarkerHit", destroyM2, msgDestroy) function destroy(player) if isElementWithinMarker(player, destroyM2) then if isPedInVehicle(player) == true then destroyElement(veh[player]) outputChatBox("", player, 255,255,255,true) else outputChatBox("", player, 255,255,255,true) end end end addEventHandler("onMarkerHit", destroyM2, destroy) Olá, coloque isso. ( testei ) O erro foi o mesmo nome das markers.
    1 point
  16. Have you replaced the "jailTime1" event handler with the code I posted? That is all that you have to do.
    1 point
  17. المنتدى ممكن يكون قل تفاعله بالقسم العربي, لكن القسم الأجنبي كمثال لا زال متفاعل وبقوة اللعبة يومياً تحقق ارقام قياسية جديدة, تأكد من معلوماتك
    1 point
  18. Poste seu código na formatação Lua. Use o botão <> do fórum.
    1 point
  19. I also need the answer to that
    1 point
  20. We are going to Release Verison 5.0 Soon Wait us
    1 point
  21. Fiz para você como ficará, diante as dicas do Lord --/> SALVAR ROUBAS AI SAIR. function save_player_quit ( ) local texture = {} local model = {} for i=0, 17 do local clothesTexture, clothesModel = getPedClothes(source, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local setTextures = table.concat(texture, ",") local setModels = table.concat(model, ",") local account = getPlayerAccount(source) setAccountData(account, "setexture", setTextures) setAccountData(account, "setmodel", setModels) texture = {} model = {} end addEventHandler("onPlayerQuit", getRootElement(), save_player_quit ) --/> CARREGAR ROUPAS AO LOGAR. function load_player_login ( ) local textures = {} local models = {} local account = getPlayerAccount(source) local textureLoad = getAccountData(account, "setexture") local modelLoad = getAccountData(account, "setmodel") if not textureLoad and not modelLoad then --/> Adicionado ! return --/> Adicionado ! end --/> Adicionado ! local textures = split(textureLoad, 44) local models = split(modelLoad, 44) setElementModel(source,0) for i=0, 17 do if ( textures[i+1] ~= " " ) then addPedClothes(source, textures[i+1], models[i+1], i) end end textures = {} models = {} end addEventHandler( "onPlayerLogin", getRootElement(), load_player_login )
    1 point
  22. Linha 3 e linha 26 estão erradas. player não é o parâmetro de função pros eventos onPlayerLogin e onPlayerQuit. E não use load como nome de função, pois essa é uma palavra reservada na linguagem Lua.
    1 point
  23. Não. Dá uma olhada nas páginas explicativas dos dois eventos que mencionei, na wiki do MTA. Essas páginas mostrarão como deve usar o evento.
    1 point
  24. Se o site for seu, você vai precisar integrar MySQL entre o site e seu script... É uma idéia bem interessante, só envolve muito conhecimento em Lua e HTML...
    1 point
  25. Hello iwalidza, if you want to have selection support inside edit boxes you need to play around with the text-width. First you have to establish text of a certain font with a certain scale. This gives you the ability to call dxGetTextWidth to obtain metrics about your text. Knowing that you need to search for the text offset into your editbox content at click event. I suggest to set the middle of each character as tipping point. -- THIS IS JUST SAMPLE CODE! It has not been tested using Unicode/UTF-8 so be warned! local strsub = string.sub; local dxGetTextWidth = dxGetTextWidth; function getTextLogicalOffset(text, offset, charScale, charFont) local n = 1; local len = #text; local curOffset = 0; local charWidth; while (n <= len) do charWidth = dxGetTextWidth(strsub(text, n, n), charScale, charFont); curOffset = curOffset + charWidth; n = n + 1; if (curOffset > offset) then break; end end if not (n == 1) and (curOffset - offset > charWidth * 0.5) then return n-1, curOffset - charWidth; end return n, curOffset; end (taken from resedit resource at https://github.com/quiret/resedit/blob/master/utilities_client.Lua#L822) It is very important to establish drag&drop inside of your editbox. This is done by remembering when the player triggered "mouse1" to start the selection and disabling it when he released "mouse1". While the player is pressing down "mouse1" you should update the selection every time the mouse cursor is moved. local select_start = 1 local select_end = 0 local text = "test" local font = "sans" local fontScale = 1.2 local text_pixels_off_x = 2 local is_selecting = false local function has_selection() return ( select_start <= select_end ) end local function mouse_click(x_abs, y_abs) if not (is_selecting) then select_start = getTextLogicalOffset(text, x_abs - text_pixels_off_x, fontScale, font) is_selecting = true end end local function mouse_move(x_abs, y_abs) select_end = getTextLogicalOffset(text, x_abs - text_pixels_off_y, fontScale, font) - 1 end local function mouse_release() if (is_selecting) then is_selecting = false end end (this code has not been tested yet) At render-time you should highlight the text that is selected using a custom rectangle backdrop. This is done by simply remembering start-offset and end-offset of the selection and, if the selection is not empty, using dxDrawRectangle before or after rendering the text at text render offset start-offset to end-offset. I leave it to you as an exercise.
    1 point
  26. Hello again, This script is server-side. Few things you should know: - localPlayer: built-in source after 1.1 for client-side only - client-side: clients download the Lua file on their own computer, meaning that they are able to read your code if it's not compiled. Not much lag. However you should -always- try to make your scripts server-side. - server-side: clients will not download the Lua file on their on computer, meaning that the server reads the code. This lags more than client-side. - bugs: happens if not considered about them because of hurry There is a small 'bug' in this code, it's about that warping. It might end rough if many cars in the colshape. And to fix that, go to the previous page and take a look at the first reply. It's one option, use your imagination and ask help if you're not sure. Just remember to tell us some details what you think'll work. addCommandHandler("warpvehicle", function(player, cmd) local element = "vehicle" local radius = 100 local warp_successful = "Nearest vehicles warped to you." local x, y, z = getElementPosition(player) local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) for index, value in ipairs(getElementsWithinColShape(colshape, element)) do setElementPosition(value, tonumber(x) - 2, tonumber(y), tonumber(z)) outputChatBox(tostring(warp_successful), player, 220, 220, 0) end destroyElement(colshape) end)
    1 point
  27. Peguei um sistema de samu da internet, porém não manjo em mecher muito em script, daí queria coloca pra quando um jogador leva HeadShot ele cair ao invés dele morrer, também queria mudar o tempo de 3 minutos para 10, como Fasso isso alguém disposto a me ajudar
    0 points
×
×
  • Create New...