Jump to content

Vazern

Members
  • Posts

    94
  • Joined

  • Last visited

Posts posted by Vazern

  1. Olá pessoal!
    Estou tendo um pequeno problema, sou iniciante em scripting e estava usando o recurso Object_Preview em um script, e vi um exemplo disso em GUI, mas não sei como fazê-lo em Dx.

     

    GUI EXEMPLO:

    https://wiki.multitheftauto.com/wiki/Resource:Object_preview

    Meu código:

    local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 10)
    
    local myObject,myElement = nil, nil
    
    local screenW, screenH = guiGetScreenSize()
    local resW, resH = 1360,768
    local x, y = (screenW/resW), (screenH/resH)
    
    function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
    	if 
    		type( sEventName ) == 'string' and 
    		isElement( pElementAttachedTo ) and 
    		type( func ) == 'function' 
    	then
    		local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
    		if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
    			for i, v in ipairs( aAttachedFunctions ) do
    				if v == func then
    					return true
    				end
    			end
    		end
    	end
    
    	return false
    end
    
    
    
    
    function menu()
    
    
    
        color = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495) then --  M4
        	--exports.preview:setPositionOffsets(m4view,0,1.5,0.1)
        	--exports.preview:setRotation(m4view, getTickCount()/10, 0, 0)
            color = tocolor(16, 102, 231, 100)
        end
    
        color2 = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495) then --  Desert
            color2 = tocolor(16, 102, 231, 100)
        end
    
        color3 = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495) then --  Cacetete 
            color3 = tocolor(16, 102, 231, 100)
        end
    
        color4 = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495) then --  Vida e colete
            color4 = tocolor(16, 102, 231, 100)
        end
    
        colorF = tocolor(0, 0, 0, 0)
        if isCursorOnElement(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469) then 
            colorF = tocolor(255, 0, 0, 150)
        end
    
        myElement = createObject(356,0,0,0)
        myObject = exports.preview:createObjectPreview(myElement,0,0,1,1,1,1, true, true, true)   
    
            dxDrawRectangle(screenW * 0.3221, screenH * 0.2656, screenW * 0.3551, screenH * 0.4844, tocolor(0, 0, 0, 185), false)
            dxDrawRectangle(screenW * 0.3221, screenH * 0.2656, screenW * 0.3551, screenH * 0.0469, tocolor(0, 0, 0, 185), false)
            dxDrawText("Menu de itens - #1066E7PMESP", screenW * 0.3294, screenH * 0.2786, screenW * 0.4971, screenH * 0.3242, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469, colorF, false)
            dxDrawText("X", screenW * 0.6618, screenH * 0.2786, screenW * 0.8294, screenH * 0.3242, tocolor(255, 255, 255, 200), x*1.30, "default-bold", "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495, color, false)
            dxDrawText("(#1066E7Armamento#FFFFFF) M4", screenW * 0.3368, screenH * 0.3438, screenW * 0.5044, screenH * 0.3893, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495, color2, false)
            dxDrawText("(#1066E7Armamento#FFFFFF) Desert Eagle", screenW * 0.3368, screenH * 0.3932, screenW * 0.5044, screenH * 0.4388, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495, color3, false)
            dxDrawText("(#1066E7Armamento#FFFFFF) Cacetete", screenW * 0.3368, screenH * 0.4427, screenW * 0.5044, screenH * 0.4883, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495, color4, false)
            dxDrawText("Vida e Colete", screenW * 0.3368, screenH * 0.4922, screenW * 0.5044, screenH * 0.5378, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.5612, screenW * 0.3360, screenH * 0.1615, tocolor(0, 0, 0, 185), false)
            
    
    
    end
    
    function render()
    	if not isEventHandlerAdded("onClientRender", root, menu) then
    	    addEventHandler("onClientRender", root, menu)
    	    showCursor(true)
    	    showChat(false)
    	   -- l_0_1 = true
    	end
    end
    addEvent("openMenuPM", true)
    addEventHandler("openMenuPM", root, render)
    
    
    function close(_,state)
        if isEventHandlerAdded("onClientRender", root, menu) then  
            if state == "down" then
                if isCursorOnElement(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469) then 
    		        showCursor(false)
                    showChat(true)
                    playSound("sfx/hit.mp3", false)
                    removeEventHandler("onClientRender", root, menu)
                    if l_0_1 then
                        l_0_1 = false
                    end
                end
            end
        end
    end
    addEventHandler("onClientClick", root, close)
    
    
    function m4(_,state)
        if isEventHandlerAdded("onClientRender", root, menu) then  
            if state == "down" then
                if isCursorOnElement(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495) then
                    triggerServerEvent("m4", localPlayer)
                    removeEventHandler("onClientRender", root, menu)
                    showChat(true)
                    showCursor(false)
                    playSound("sfx/hit.mp3", false) 
                    if l_0_1 then
                        l_0_1 = false
                    end
                end
            end
        end
    end
    addEventHandler("onClientClick", root, m4)
    
    
    
    function isCursorOnElement( posX, posY, width, height )
      if isCursorShowing( ) then
        local mouseX, mouseY = getCursorPosition( )
        local clientW, clientH = guiGetScreenSize( )
        local mouseX, mouseY = mouseX * clientW, mouseY * clientH
        if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then
          return true
        end
      end
      return false
    end

     

  2. Teste assim: 

     

    local aSavePlaces = 
    {
    	{1587.1513671875, -1152.365234375,245, 160};  -- BOSS LS
    	{2372.2763671875, 1836.701171875,150, 160};  -- BOSS LV
    	{-2140.8330078125, 124.470703125,150, 185};  -- BOSS SF
    }
    
    local aRadarAreaPlaces = 
    {
    
    	{1587.1513671875, -1152.365234375,245, 160,255,0,0,100};  -- BOSS LS
    	{2372.2763671875, 1836.701171875,150, 160,255,0,0,100};  -- BOSS LV
    	{-2140.8330078125, 124.470703125,150, 185,255,0,0,100};  -- BOSS SF
    }
    
    
    function criandoareas( )
    
    for _, a in ipairs( aRadarAreaPlaces ) do
    				pRadarArea = createRadarArea ( unpack( a ) )
    				setElementData( pRadarArea, "zombieProof", true )
    			end	
    
    for _, b in ipairs( aSavePlaces ) do
    		        zona = createColRectangle ( unpack( b ) )				
    			end		
    end
    addEventHandler ( "onResourceStart", resourceRoot,criandoareas)
    
    							
    function entrando( pHitElement )
    	if getElementType( pHitElement ) == 'player' then	     
    		 outputChatBox("[BOSS] - Você entrou em área BOSS.", pHitElement, 0, 145, 0, true)
    	elseif getElementData(pHitElement,"zombie") and getElementType( pHitElement ) == 'ped' then
    	    killPed(pHitElement)                          	
    	end				
    end
    addEventHandler ( "onColShapeHit", zona, entrando) 	
    
    				
    function saindo( pHitElement ) 
    	if getElementType( pHitElement ) == 'player' then
         outputChatBox("[BOSS] - Você saiu da área BOSS.", pHitElement, 145, 0, 0, true)	
    	elseif getElementData(pHitElement,"zombie") and getElementType( pHitElement ) == 'ped' then
    	    killPed(pHitElement) 
    	end
    end		
    addEventHandler ( "onColShapeLeave", zona, saindo)

     

     

    • Like 1
  3. Hello guys!
    I'm having a little problem, I'm a beginner in scripting and I was using the Object_Preview resource in a script, and I saw an example of it in GUI, but I do not know how to do it in Dx.

     

    GUI EXAMPLE: 

    https://wiki.multitheftauto.com/wiki/Resource:Object_preview

     

    Code:

    local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 10)
    
    local myObject,myElement = nil, nil
    
    local screenW, screenH = guiGetScreenSize()
    local resW, resH = 1360,768
    local x, y = (screenW/resW), (screenH/resH)
    
    function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
    	if 
    		type( sEventName ) == 'string' and 
    		isElement( pElementAttachedTo ) and 
    		type( func ) == 'function' 
    	then
    		local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
    		if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
    			for i, v in ipairs( aAttachedFunctions ) do
    				if v == func then
    					return true
    				end
    			end
    		end
    	end
    
    	return false
    end
    
    
    
    
    function menu()
    
    
    
        color = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495) then --  M4
        	--exports.preview:setPositionOffsets(m4view,0,1.5,0.1)
        	--exports.preview:setRotation(m4view, getTickCount()/10, 0, 0)
            color = tocolor(16, 102, 231, 100)
        end
    
        color2 = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495) then --  Desert
            color2 = tocolor(16, 102, 231, 100)
        end
    
        color3 = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495) then --  Cacetete 
            color3 = tocolor(16, 102, 231, 100)
        end
    
        color4 = tocolor(0, 0, 0, 185)
        if isCursorOnElement(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495) then --  Vida e colete
            color4 = tocolor(16, 102, 231, 100)
        end
    
        colorF = tocolor(0, 0, 0, 0)
        if isCursorOnElement(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469) then 
            colorF = tocolor(255, 0, 0, 150)
        end
    
        myElement = createObject(356,0,0,0)
        myObject = exports.preview:createObjectPreview(myElement,0,0,1,1,1,1, true, true, true)   
    
            dxDrawRectangle(screenW * 0.3221, screenH * 0.2656, screenW * 0.3551, screenH * 0.4844, tocolor(0, 0, 0, 185), false)
            dxDrawRectangle(screenW * 0.3221, screenH * 0.2656, screenW * 0.3551, screenH * 0.0469, tocolor(0, 0, 0, 185), false)
            dxDrawText("Menu de itens - #1066E7PMESP", screenW * 0.3294, screenH * 0.2786, screenW * 0.4971, screenH * 0.3242, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469, colorF, false)
            dxDrawText("X", screenW * 0.6618, screenH * 0.2786, screenW * 0.8294, screenH * 0.3242, tocolor(255, 255, 255, 200), x*1.30, "default-bold", "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495, color, false)
            dxDrawText("(#1066E7Armamento#FFFFFF) M4", screenW * 0.3368, screenH * 0.3438, screenW * 0.5044, screenH * 0.3893, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.3802, screenW * 0.3360, screenH * 0.0495, color2, false)
            dxDrawText("(#1066E7Armamento#FFFFFF) Desert Eagle", screenW * 0.3368, screenH * 0.3932, screenW * 0.5044, screenH * 0.4388, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.4297, screenW * 0.3360, screenH * 0.0495, color3, false)
            dxDrawText("(#1066E7Armamento#FFFFFF) Cacetete", screenW * 0.3368, screenH * 0.4427, screenW * 0.5044, screenH * 0.4883, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.4792, screenW * 0.3360, screenH * 0.0495, color4, false)
            dxDrawText("Vida e Colete", screenW * 0.3368, screenH * 0.4922, screenW * 0.5044, screenH * 0.5378, tocolor(255, 255, 255, 200), x*1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
            dxDrawRectangle(screenW * 0.3294, screenH * 0.5612, screenW * 0.3360, screenH * 0.1615, tocolor(0, 0, 0, 185), false)
            
    
    
    end
    
    function render()
    	if not isEventHandlerAdded("onClientRender", root, menu) then
    	    addEventHandler("onClientRender", root, menu)
    	    showCursor(true)
    	    showChat(false)
    	   -- l_0_1 = true
    	end
    end
    addEvent("openMenuPM", true)
    addEventHandler("openMenuPM", root, render)
    
    
    function close(_,state)
        if isEventHandlerAdded("onClientRender", root, menu) then  
            if state == "down" then
                if isCursorOnElement(screenW * 0.6544, screenH * 0.2656, screenW * 0.0228, screenH * 0.0469) then 
    		        showCursor(false)
                    showChat(true)
                    playSound("sfx/hit.mp3", false)
                    removeEventHandler("onClientRender", root, menu)
                    if l_0_1 then
                        l_0_1 = false
                    end
                end
            end
        end
    end
    addEventHandler("onClientClick", root, close)
    
    
    function m4(_,state)
        if isEventHandlerAdded("onClientRender", root, menu) then  
            if state == "down" then
                if isCursorOnElement(screenW * 0.3294, screenH * 0.3307, screenW * 0.3360, screenH * 0.0495) then
                    triggerServerEvent("m4", localPlayer)
                    removeEventHandler("onClientRender", root, menu)
                    showChat(true)
                    showCursor(false)
                    playSound("sfx/hit.mp3", false) 
                    if l_0_1 then
                        l_0_1 = false
                    end
                end
            end
        end
    end
    addEventHandler("onClientClick", root, m4)
    
    
    
    function isCursorOnElement( posX, posY, width, height )
      if isCursorShowing( ) then
        local mouseX, mouseY = getCursorPosition( )
        local clientW, clientH = guiGetScreenSize( )
        local mouseX, mouseY = mouseX * clientW, mouseY * clientH
        if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then
          return true
        end
      end
      return false
    end

     

     

  4. The end result was this, I changed to this mode and it worked, thanks for the help!

     

    function tornarPM()
        if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("PMESP")) then
    	    aclGroupAddObject(aclGetGroup("PMESP"), "user."..getAccountName(getPlayerAccount(source)))
    		exports.dxmessages:outputDx(source, "Seja bem vindo a PMESP! Vá até a garagem para aprender como funciona o trabalho!", "success")
        else
            exports.dxmessages:outputDx(source, "Você já é policial.", "error")
        end
    end 
    addEvent("ingressar",true)
    addEventHandler("ingressar", root, tornarPM)
    

     

    • Like 1
  5. Hello guys!
    I'm having a little problem, I'm a beginner in scripting, and I made this function because I'm creating a "police work" system, but when the event is executed, nothing happens that was written on the server, nor any error in the debug.
    (Sorry for English, I use a translator.)

    Server-side:

    function tornarPM(thePlayer)
    if not (isElement(thePlayer)) then return end
      local accountName = getAccountName(getPlayerAccount(thePlayer))
        if accountName then
            aclGroupAddObject(aclGetGroup("PMESP"), "user."..accountName)
    		exports.dxmessages:outputDx(thePlayer, "Seja bem vindo a PMESP! Vá até a garagem para aprender como funciona o trabalho!", "success")
    	end
    end 
    addEvent("ingressar",true)
    addEventHandler("ingressar", root, tornarPM)

     

    Client-side:

    function tornarPM(_,state)
        if isEventHandlerAdded("onClientRender", root, menu) then  
            if state == "down" then
                if isCursorOnElement(screenW * 0.4066, screenH * 0.5117, screenW * 0.1574, screenH * 0.0651) then
                    triggerServerEvent("ingressar", localPlayer)
                    removeEventHandler("onClientRender", root, menu)
                    showChat(true)
                    showCursor(false)
                    playSound("sfx/hit.mp3", false) 
                    if l_0_1 then
                        l_0_1 = false
                    end
                end
            end
        end
    end
    addEventHandler("onClientClick", root, tornarPM)

     

    Screenshot:

    https://i.imgur.com/ZYroOks.jpg

    Mji3ySJ.png

     

     

  6. (I'm Brazilian and I use google translate)

    Hello, I made a script that I searched a lot on the internet and did not find it, so I decided to do it myself. It is simple, when climbing on any bike is generated a helmet on the player's head, works with any skin. You can remove the helmet by typing /removecapa or descending from the motorcycle.

    NOTE: For the script to work you must have the resource "bone_attach".

     

    frKLkpJ.png

    • Like 2
  7. I was informed that it is no use to convert masks and use them for freeroam. The appropriate method is to swap the dff and txd of a small map object and use bone_attach to place them on the player's face. This method worked for me.

    (Google Translate)

  8. 57 minutes ago, 3aGl3 said:

    The code looks like it's ok, however this should be enough.

    
    txd = engineLoadTXD("hockey.txd")
    engineImportTXD(txd, 30376) 
    dff = engineLoadDFF("hockeymask.dff")
    engineReplaceModel(dff, 30376)
    

    If you want any further help please post any error you get etc. I'm also not sure about the names but I personally never used different names for the txd and dff.

    Actually, I used to have the same names as txd and dff, but I changed it, I think the error is not related to that.

    (Google Translate)

  9. I can not convert a mask, I used this code below, but at the time of selecting the MTA date.

    P.S: I have already tested other types of masks and still crashes.

    (Google Translate)

     

    txd = engineLoadTXD("hockey.txd")
    engineImportTXD(txd, 30376) 
    dff = engineLoadDFF("hockeymask.dff",30376)
    engineReplaceModel(dff, 30376)

     

×
×
  • Create New...