Jump to content

[AJUDA] Marker com comando de repetição


Recommended Posts

Olá a todos, estou com um problema que está me deixando super desanimado... eu criei um comando de repetição para varias markers pegados nas posições de uma tabela, até ai tudo bem, mas ai usei onMarkerHit, ele só vai para o ultimo marker repetido... já tentei de várias formas, criei função para cada marker... mas ai o getElementID que eu utilizei foi para outra posição...

Server-side

Boxs = {
	Positions = {
		{1368.09497, -1279.76941, 13.54688 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
		{2333.50806, 61.62383, 26.70579 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
		{-2625.85010, 208.34500, 4.81250 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
		{2158.97290, 943.12683, 10.82031 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4}
	},
	Create = {}
}

addEventHandler("onResourceStart", resourceRoot,
	function ()
		for i = 1, #Boxs.Positions do
			Boxs.Create.Enter = createMarker(Boxs.Positions[i][1], Boxs.Positions[i][2], Boxs.Positions[i][3], "arrow", 1, 255, 255, 0, 255);
			Boxs.Create.Exit = createMarker(Boxs.Positions[i][4], Boxs.Positions[i][5], Boxs.Positions[i][6], "arrow", 1, 255, 255, 0, 255);
			Boxs.Create.Marker = createMarker(Boxs.Positions[i][7], Boxs.Positions[i][8], Boxs.Positions[i][9], "cylinder", 1, 255, 255, 0, 255);
			createBlipAttachedTo(Boxs.Create.Enter, 6, 2, 0, 255, 0, 0, 0, 7000);
			setElementInterior(Boxs.Create.Exit, Boxs.Positions[i][10]);
			setElementInterior(Boxs.Create.Marker, Boxs.Positions[i][10]);
			setElementID(Boxs.Create.Enter, i);
			addEventHandler("onMarkerHit", Boxs.Create.Enter, markerHitEnter);
		end
	end
) 

addEventHandler("onMarkerHit", resourceRoot, 
	function (Jog, mathDim)
		if (getElementType(Jog) == "player") then
      		if (source == Boxs.Create.Enter) then
                  fadeCamera(Jog, false, 1.0);
                  local x, y, z = getElementPosition(Jog);
                  setTimer( function (Jog)
                      fadeCamera(Jog, true, 1.0);
                      setElementInterior(Jog, Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][10], Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][4]+1.5, Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][5]+1.5, Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][6]);
		end, 2000, 1, Jog)  		
			elseif (source == Boxs.Create.Exit) then
				fadeCamera(Jog, false, 1.0);
				setTimer( function (Jog)
					fadeCamera(Jog, true, 1.0);
					setElementInterior(Jog, 0, Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][1]+1.5,  Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][2],  Boxs.Positions[tonumber(getElementID(Boxs.Create.Enter))][3]);
				end, 2000, 1, Jog)
			elseif (source == Boxs.Create.Marker) then
				triggerClientEvent(Jog, getResourceName(getThisResource())..": onClientSystem", root, "addRenderScript");
			end
		end
	end
)

Eu não sei mais o que fazer.. fiz vários comandos de repetição verificando source no onMarkerHit, não está adiantando nada...

Link to comment

Solução usando diferentes dimensões para cada marker:

Boxs = {
    Positions = {
        {1368.09497, -1279.76941, 13.54688 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
        {2333.50806, 61.62383, 26.70579 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
        {-2625.85010, 208.34500, 4.81250 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
        {2158.97290, 943.12683, 10.82031 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4}
    },

    Data = {}
}

addEventHandler("onResourceStart", resourceRoot,
    function ()
        for i = 1, #Boxs.Positions do
            local enter = createMarker(Boxs.Positions[i][1], Boxs.Positions[i][2], Boxs.Positions[i][3], "arrow", 1, 255, 255, 0, 255);
            local exit = createMarker(Boxs.Positions[i][4], Boxs.Positions[i][5], Boxs.Positions[i][6], "arrow", 1, 255, 255, 0, 255);
            local marker = createMarker(Boxs.Positions[i][7], Boxs.Positions[i][8], Boxs.Positions[i][9], "cylinder", 1, 255, 255, 0, 255);

            createBlipAttachedTo( enter, 6, 2, 0, 255, 0, 0, 0, 7000 );

            setElementInterior( exit, Boxs.Positions[i][10] );
            setElementInterior( marker, Boxs.Positions[i][10] );
            setElementDimension( exit, i );
            setElementDimension( marker, i );

            Boxs.Data[ enter ] = { type = "enter", id = i };
            Boxs.Data[ exit ] = { type = "exit", id = i };
            Boxs.Data[ marker ] = { type = "marker", id = i };
        end
    end
)

addEventHandler("onMarkerHit", resourceRoot,
    function (Jog, mathDim)
        if ( getElementType(Jog) == "player" and mathDim and Boxs.Data[ source ] ) then
              if ( Boxs.Data[ source ]["type"] == "enter" ) then
                local x, y, z = getElementPosition(Jog);
                local id = Boxs.Data[ source ]["id"];

                fadeCamera(Jog, false, 1.0);
                setTimer(
                    function (Jog)
                        fadeCamera(Jog, true, 1.0);
                        setElementDimension ( Jog, id );
                        setElementInterior(Jog, Boxs.Positions[ id ][10], Boxs.Positions[ id ][4]+1.5, Boxs.Positions[ id ][5]+1.5, Boxs.Positions[ id ][6]);
                    end
                , 2000, 1, Jog)

            elseif ( Boxs.Data[ source ]["type"] == "exit" ) then
                local id = Boxs.Data[ source ]["id"];

                fadeCamera(Jog, false, 1.0);
                setTimer(
                    function (Jog)
                        fadeCamera(Jog, true, 1.0);
                        setElementDimension ( Jog, 0 );
                        setElementInterior(Jog, 0, Boxs.Positions[ id ][1]+1.5,  Boxs.Positions[ id ][2],  Boxs.Positions[ id ][3]);
                    end
                , 2000, 1, Jog)

            elseif ( Boxs.Data[ source ]["type"] == "marker") then
                triggerClientEvent(Jog, getResourceName(getThisResource())..": onClientSystem", root, "addRenderScript");
            end
        end
    end
)

 

Link to comment
27 minutes ago, n3wage said:

Solução usando diferentes dimensões para cada marker:


Boxs = {
    Positions = {
        {1368.09497, -1279.76941, 13.54688 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
        {2333.50806, 61.62383, 26.70579 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
        {-2625.85010, 208.34500, 4.81250 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4},
        {2158.97290, 943.12683, 10.82031 + 0.8, 285.67160, -86.19171, 1001.52289 + 0.8, 294.71225, -80.24703, 1001.51563 - 0.8, 4}
    },

    Data = {}
}

addEventHandler("onResourceStart", resourceRoot,
    function ()
        for i = 1, #Boxs.Positions do
            local enter = createMarker(Boxs.Positions[i][1], Boxs.Positions[i][2], Boxs.Positions[i][3], "arrow", 1, 255, 255, 0, 255);
            local exit = createMarker(Boxs.Positions[i][4], Boxs.Positions[i][5], Boxs.Positions[i][6], "arrow", 1, 255, 255, 0, 255);
            local marker = createMarker(Boxs.Positions[i][7], Boxs.Positions[i][8], Boxs.Positions[i][9], "cylinder", 1, 255, 255, 0, 255);

            createBlipAttachedTo( enter, 6, 2, 0, 255, 0, 0, 0, 7000 );

            setElementInterior( exit, Boxs.Positions[i][10] );
            setElementInterior( marker, Boxs.Positions[i][10] );
            setElementDimension( exit, i );
            setElementDimension( marker, i );

            Boxs.Data[ enter ] = { type = "enter", id = i };
            Boxs.Data[ exit ] = { type = "exit", id = i };
            Boxs.Data[ marker ] = { type = "marker", id = i };
        end
    end
)

addEventHandler("onMarkerHit", resourceRoot,
    function (Jog, mathDim)
        if ( getElementType(Jog) == "player" and mathDim and Boxs.Data[ source ] ) then
              if ( Boxs.Data[ source ]["type"] == "enter" ) then
                local x, y, z = getElementPosition(Jog);
                local id = Boxs.Data[ source ]["id"];

                fadeCamera(Jog, false, 1.0);
                setTimer(
                    function (Jog)
                        fadeCamera(Jog, true, 1.0);
                        setElementDimension ( Jog, id );
                        setElementInterior(Jog, Boxs.Positions[ id ][10], Boxs.Positions[ id ][4]+1.5, Boxs.Positions[ id ][5]+1.5, Boxs.Positions[ id ][6]);
                    end
                , 2000, 1, Jog)

            elseif ( Boxs.Data[ source ]["type"] == "exit" ) then
                local id = Boxs.Data[ source ]["id"];

                fadeCamera(Jog, false, 1.0);
                setTimer(
                    function (Jog)
                        fadeCamera(Jog, true, 1.0);
                        setElementDimension ( Jog, 0 );
                        setElementInterior(Jog, 0, Boxs.Positions[ id ][1]+1.5,  Boxs.Positions[ id ][2],  Boxs.Positions[ id ][3]);
                    end
                , 2000, 1, Jog)

            elseif ( Boxs.Data[ source ]["type"] == "marker") then
                triggerClientEvent(Jog, getResourceName(getThisResource())..": onClientSystem", root, "addRenderScript");
            end
        end
    end
)

 

Muito obrigado!! Você me ajudou demais!! e até uma possível depressão (Irônico) rs.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...