Jump to content

Leaderboard

Popular Content

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

  1. You don't need metatables for the self keyword. Take a look at this small sample: local police = {} -- Take a look: we use the "self" keyword here! function police:setName(name) self.name = name end function police:getName() return self.name end police:setName("Las Venturas Police Department") outputDebugString("Name of Police HQ: " .. police:getName()) Formal description: if you specify a "method" of a table in Lua, then inside the function body you can access the hidden local variable "self" which points to the table itself. This self variable is the first argument to the function specification of the method. Thus an equivalent way of writing above script is: local police = {} -- Here we explicitly specify the self. function police.setName(self, name) self.name = name end function police.getName(self) return self.name end police:setName("Las Venturas Police Department") outputDebugString("Name of Police HQ: " .. police:getName()) Hope this helps!
    2 points
  2. I think you talking about metatables. https://wiki.multitheftauto.com/wiki/OOP_in_Lua
    2 points
  3. اخباركم ان شاء الله بخير سويت مود جديد و حبيت اعرضه عليكم عشان الاقتراحات و النقد الإيجابي المهم اترككم معى الصور ملاحظة السكربت موجه للحياة الوقعية و حرب العصابات و حتى الهجولة طريقة نثل البيانات mysql + xml :PIS:
    1 point
  4. Thank you for sharing your resource with us. I admit that I had to get my head around that zooming logic, because it is math that I was quite unfamiliar with, but here is your function: local map_world_units_width = 6000; function getWorldFromMapPosition(mapX, mapY, posx, posy, x, y, w, h, range) local zoomFactor = ( 180 / range ); local render_pixel_side_distance = 3000 * zoomFactor; -- actual size of the map in pixels inside the render-target. local world_render_distance_w = w / render_pixel_side_distance * map_world_units_width; local world_render_distance_h = h / render_pixel_side_distance * map_world_units_width; local world_tl_start_x = ( posx - world_render_distance_w / 2 ); local world_tl_start_y = ( posy + world_render_distance_h / 2 ); local absCursorX = ( mapX * sx ); local absCursorY = ( mapY * sy ); local real_map_off_x = ( absCursorX - x ); local real_map_off_y = ( absCursorY - y ); -- Cursor outside of the map image? if ( real_map_off_x < 0 ) or ( real_map_off_x >= w ) or ( real_map_off_y < 0 ) or ( real_map_off_y >= h ) then return false; end local relative_map_off_x = ( real_map_off_x / w ); local relative_map_off_y = ( real_map_off_y / h ); local worldX = world_tl_start_x + relative_map_off_x * world_render_distance_w; local worldY = world_tl_start_y - relative_map_off_y * world_render_distance_h; return worldX, worldY; end The clue was to calculate the size of the map that you draw inside the render target, then calculate the fraction of the width and height of how much you draw of the actual map image. So if you draw only a third of the map image, then you can expect the render to cover about 2000 game units. Then we can just linearly interpolate the world position with the relative cursor position on the map render. I noticed that your map does not render using same width and height thus I added further adjustments. Have fun with the code!
    1 point
  5. Fiz um script de pickup que usa setElementData para salvar a skin que o cara tinha quando passou em cima, funcionou tudo normal, mas caso a pessoa que passou em cima esteja com a skin que o pickup da, e o servidor cai/reinicia, o player cai/quita, o script reinicia ou algo assim, ele não salva a skin anterior do player, e quando ele passar em cima do pickup, vai salvar a skin que o pickup deixou nele. Para eu não só vir aqui sem tentar algo, eu tentei com as seguintes linhas abaixo, que peguei do script de Save que uso Funcionou em partes, em que testei no momento (reiniciar e dar stop no resource), mas sempre da o seguinte erro
    1 point
  6. Assim por cima, notei uns control C cabuloso, mas, para salvar na conta do player se utiliza setAccountData. Fiz algumas melhorias (ou melhor, dei uma geral), e dentre disso, você verá seus erro, e te ajudará. -- SCRIPT DO PICKUP -- SERVER SIDE -- local pickup = createPickup(1766.3364257813,-1788.8395996094,16.325000762939, 3, 1275, 1) function skin (hit) local accName = getAccountName ( getPlayerAccount ( hit ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Mecanico") ) then if getElementData(hit,"Servico") == "Sim" then local outSkin = tonumber(getElementData(hit,"skinout")) or 0 setElementModel (hit,outSkin) --/> Alterado setElementData(hit, "Servico", "Não") exports.Scripts_Dxmessages:outputDx(hit, "Você saiu de Serviço com sucesso!", "success") return end local skinatual = getElementModel(hit) --/> Alterado setElementModel (hit, 50) --/> Alterado setElementData(hit, "Servico", "Sim") setElementData(hit, "skinout", skinatual) exports.Scripts_Dxmessages:outputDx(hit, "Você entrou em Serviço com sucesso, Bom Trabalho!", "success") else exports.Scripts_Dxmessages:outputDx(hit, "Você não é um mecanico para poder entrar em Serviço!", "error") end end addEventHandler("onPickupHit", pickup,skin) -- ADICIONADO DEPOIS DO PICKUP -- function player_quit ( ) local account = getPlayerAccount (source) if account and not isGuestAccount(account) then local skinserv = getElementData ( source, "skinout" ) or 0 --/> Alterado local servi = getElementData ( source, "Servico" ) or "Não" --/> Alterado setAccountData ( account, "skinout", skinserv ) --/> Alterado setAccountData ( account, "Servico", servi ) --/> Alterado end end addEventHandler ("onPlayerQuit", getRootElement(), player_quit) function player_login ( ) local account = getPlayerAccount (source) if account and not isGuestAccount(account) then local skinserv = getAccountData ( account, "skinout" ) or 0 local servi = getAccountData ( account, "Servico" ) or "Não" setElementData ( source, "skinout", skinserv ) setElementData ( source, "Servico", servi ) end end addEventHandler ("onPlayerLogin", getRootElement(), player_login ) function start_resource ( ) --/> Alterado / Quase tudo... for i, player in ipairs(getElementsByType("player")) do --/> Adicionado local account = getPlayerAccount (player) --/> Adicionado if account and not isGuestAccount(account) then --/> Adicionado local skinserv = getAccountData ( account, "skinout" ) or 0 local servi = getAccountData ( account, "Servico" ) or "Não" setElementData ( player, "skinout", skinserv ) setElementData ( player, "Servico", servi ) end end end addEventHandler ( "onResourceStart", resourceRoot, start_resource ) --/> Alterado function stop_resource ( ) --/> Alterado / Quase tudo... for i, player in ipairs(getElementsByType("player")) do --/> Adicionado local account = getPlayerAccount (player) --/> Adicionado if account and not isGuestAccount(account) then --/> Adicionado local skinserv = getElementData ( player, "skinout" ) or 0 --/> Alterado local servi = getElementData ( player, "Servico" ) or "Não" --/> Alterado setAccountData ( account, "skinout", skinserv ) --/> Alterado setAccountData ( account, "Servico", servi ) --/> Alterado end end end addEventHandler ( "onResourceStop", resourceRoot, stop_resource ) --/> Alterado
    1 point
  7. Já tentou usar setAccountData Veja o exemplo da wiki e tente fazer... é easy Ah e outra coisa.. pare de usar "não" "sim" Use os padrões ( true e false ) nos elementos
    1 point
  8. se eu entendi direito vc precisa as coordenadas do mapa f11 atraves de click ou algo assim? tem essa funcao getPlayerMapBoundingBox que talvez ajude, peguei esse exemplo da wiki, local screenSize = Vector2(guiGetScreenSize()) local function handleMapTargetBlip() if not isPlayerMapVisible() then showCursor(false, false) wasLeftMouseButtonPressed, wasRightMouseButtonPressed = false, false return end if not isCursorShowing() then showCursor(true, false) end local isLeftMouseButtonPressed = getKeyState("mouse1") if isLeftMouseButtonPressed and isLeftMouseButtonPressed ~= wasLeftMouseButtonPressed then local cursorPos, mapMin, mapMax = Vector2(getCursorPosition()) cursorPos.x, cursorPos.y = cursorPos.x * screenSize.x, cursorPos.y * screenSize.y do local mx, my, Mx, My = getPlayerMapBoundingBox() mapMin = Vector2(mx, my) mapMax = Vector2(Mx, My) end if cursorPos.x >= mapMin.x and cursorPos.y >= mapMin.y and cursorPos.x <= mapMax.x and cursorPos.y <= mapMax.y then local relPos = Vector2((cursorPos.x - mapMin.x) / (mapMax.x - mapMin.x), (cursorPos.y - mapMin.y) / (mapMax.y - mapMin.y)) local worldPlanePos = Vector2(6000 * (relPos.x - 0.5), 3000 - (relPos.y * 6000)) local worldPos = Vector3(worldPlanePos.x, worldPlanePos.y, getGroundPosition(worldPlanePos.x, worldPlanePos.y, 3000)) outputChatBox("x: "..worldPlanePos.x.." y: "..worldPlanePos.y.." z: "..getGroundPosition(worldPlanePos.x, worldPlanePos.y, 3000)) end end end addEventHandler("onClientRender", root, handleMapTargetBlip) e editei uma linha pra que saia as coords no chat quando clica no mapa do f11, mesmo que seu mapa seja diferente do padrao do mta vc pode aproveitar o algoritmo, as coords Z precisa estar perto do player pro getgroundposition funcionar, ou precisa teleportar antes o player pra perto pra carregar os dados de coll e ai sim achar a position Z do chao
    1 point
  9. 1 point
  10. سكربت جميل جدا و رائع لاكن يمكنك ان تجعل UI بشكل احسن عبر اضافة بعض البروبورتي لي DGS و ايضا نقل مكان البيك اب الى مكان جيد يشبه الشركات او ان تقوم مثل ما قال اخونا DmaR..x
    1 point
  11. نايس سكربت وإقتراحي مثل ماقال الأخ دمار تقريباً يكون لكل شركة مكان معين ويروح عليه اللاعب وإلى آخر ذلك أو يكون فيه مكان معين ويروحون عليه اللاعبين ومن هناك يقدرون يبيعون ويستثمرون بالنهاية أنت مبدع كالعادة
    1 point
  12. UPDATE: -Updated deferred rendering by @Ren_712 to latest version, slightly better light rendering and slightly better performance -Fixed a bug that broke sync between players when someone pressed prone -Fixed broken submarine visibility through transparent water -Fixed some issues with broken speed sync between marine units -Fixed visibility of ship / submarine water wakes -Fixed broken sonar detection -Fixed broken submarine sound -Ship wakes do now have a draw distance limit of 800m -Ship captains can now hear it when they get detected by sonar and they get an estimated direction to the target -The sonar detection warning has been visually changed, it is no longer so easy to determine where the sonar ping came from Thats it, there are no known issues left.
    1 point
  13. trabalhar = createMarker ( 2771.0739746094,-2407.8974609375,12.627556800842 , "cylinder", 3, 255,0,0, 255) trabalho2 = createBlipAttachedTo(trabalhar, 51, 3, 255, 0, 0, 255, 0, 65535) pegarcarga = createMarker(2741.2861328125,-2422.1064453125,12.650645256042 , "cylinder", 3, 255,140,0, 255) pegarcargablip = createBlipAttachedTo(pegarcarga, 53, 3, 255, 0, 0, 255, 0, 65535) setElementVisibleTo ( pegarcargablip, root, false ) setElementVisibleTo ( pegarcarga, root, false ) levarcarga = createMarker(2804.0649414063,969.056640625,9.75 , "cylinder", 3, 255,140,0, 255) levarcargablip = createBlipAttachedTo(levarcarga, 53, 3, 255, 0, 0, 255, 0, 65535) setElementVisibleTo ( levarcargablip, root, false ) setElementVisibleTo ( levarcarga, root, false ) veh = {} function pegartrabalho (source) if isElementWithinMarker (source, trabalhar ) then if veh[source] and isElement( veh[source] ) then destroyElement(veh[source] ) veh[source] = nil end local x,y,z = getElementPosition(source) veh[source] = createVehicle(456 ,2765.3432617188,-2401.1748046875,13.6328125 + 2) ------ Id e local onde o veiculo que você usa pro trabalho cai 431 o id o resto é o local warpPedIntoVehicle (source,veh[source]) setElementVisibleTo ( pegarcarga, source, true ) setElementVisibleTo ( pegarcargablip, source, true ) outputChatBox ('#000000[#FF3030Trabalho #000000]#FF0000Vá até a bandeira para carregar seu caminhão',source,255,255,255,true) end end addEventHandler( "onMarkerHit", trabalhar ,pegartrabalho ) function pegarcargam (source) if veh[source] and isElement(veh[source]) then outputChatBox ('#000000[#FF3030Trabalho #000000]#FF0000Espere até que o caminhão esteja carregado',source,255,255,255,true) setElementFrozen( veh[source], true ) setTimer(function() setElementFrozen( veh[source], false ) outputChatBox ('#000000[#FF3030Trabalho #000000]#FF0000Vá até a bandeira para descarregar seu caminhão',source,255,255,255,true) setElementVisibleTo ( pegarcargablip, source, false ) setElementVisibleTo ( pegarcarga, source, false ) setElementVisibleTo ( levarcargablip, source, true ) setElementVisibleTo ( levarcarga, source, true ) end, 6000, 1) end end addEventHandler( "onMarkerHit", pegarcarga, pegarcargam ) function Entregarcarga (source) if veh[source] and isElement(veh[source]) then outputChatBox ('#000000[#FF3030Trabalho #000000]#FF0000Espere até que o caminhão seja descacarregado',source,255,255,255,true) setElementFrozen( veh[source], true ) setTimer(function() setElementFrozen( veh[source], false ) outputChatBox ('#000000[#FF3030Trabalho #000000]#FF0000Parabéns Vc Concluiu o Trabalho e ganhou #FF00FF5000R$',source,255,255,255,true) setElementVisibleTo ( levarcargablip, source, false ) setElementVisibleTo ( levarcarga, source, false ) givePlayerMoney (source, 6000) destroyElement (veh[source]) end, 6000, 1) end end addEventHandler( "onMarkerHit", levarcarga, Entregarcarga ) Timer = {} function sair (source) if (veh[source]) and isElement(veh[source]) then Trabalho = false outputChatBox ('#000000[#FF3030Trabalho #000000]#FF0000Volte Para O Carro em menos de 10 segundos ou vai perder o emprego',source,255,255,255,true) Timer[source] = setTimer(function() setElementVisibleTo ( pegarcargablip, source, false ) setElementVisibleTo ( pegarcarga, source, false ) setElementVisibleTo ( levarcargablip, source, false ) setElementVisibleTo ( levarcarga, source, false ) destroyElement(veh[source] ) Timer[source] = nil end, 10000, 1) end end addEventHandler ("onVehicleExit", root, sair) addEventHandler("onVehicleEnter", root, function(hit, seat) if seat == 0 and hit and veh[hit] and source == veh[hit] then Trabalho = true if Timer[hit] and isTimer(Timer[hit]) then killTimer(Timer[hit]) setElementVisibleTo ( pegarcargablip, source, true ) setElementVisibleTo ( pegarcarga, source, true ) setElementVisibleTo ( levarcargablip, source, true ) setElementVisibleTo ( levarcarga, source, true ) end end end) Notei que você alterou o valor de source na função de exit nesse caso não vejo problemas mais não aconselho que faça isso.
    1 point
  14. Good question. I don't know. A release like 1.6 should probably be pretty big. And we have lots of management decisions to make (relating to software update processes, branch processes, etc). So more time is needed. I'd guess before the summer?
    1 point
  15. Hi, This year I decided to make an unofficial CLI for MTA. For now I have: Resource is restarting after you will change source file (ex. .Lua) You can create new resource by typing "mta create <resourceName>" (i think it's great for begginers) You can compile all .Lua files to .luac just simply typing "mta compile" into CMD This CLI isn't finished yet so I'm looking for some feedback and features to add. You can test it today simply by installing it as global npm package. Full instalation manual is on repository. You can find it here: https://github.com/pawel-miczka/mta-cli Installation process is simple. First you need NodeJS on local computer. Then in CMD type: npm install -g mta-cli and then you can type into your CMD: mta --help for more details. If you don't have NodeJS installed I highly recommend doing it via chocolatey package manager (https://chocolatey.org/). If you have Chocolatey on your computer just simply type: choco install nodejs and NodeJS should get installed. You can install NodeJS in any different way.
    1 point
  16. The mapping is without custom textures.
    1 point
  17. And people still think openMP will be released
    1 point
×
×
  • Create New...