Jump to content

[HELP] markers


Recommended Posts

Fala pessoal, estou aqui novamente com outra dúvida...

Queria saber como eu faço pra atrelar um modelo de skin a cada marca, para quando o player do team X entrar na marker Y que contenha a id da skin Z...

local pos = {
{2346.400390625,-1272.5,26.89999961853}, -- sobre
{2339.8999023438,-1272.5,26.89999961853},
{2333.5000000000,-1272.5,26.89999961853},
{2325.400390625,-1272.5,26.89999961853},

{2346.400390625,-1272.5,26.89999961853}, -- assssino
{2339.8999023438,-1272.5,26.89999961853},
{2333.5000000000,-1272.5,26.89999961853},
{2325.400390625,-1272.5,26.89999961853},

{2346.400390625,-1272.5,26.89999961853}, -- caçador
{2339.8999023438,-1272.5,26.89999961853},
{2333.5000000000,-1272.5,26.89999961853},
{2325.400390625,-1272.5,26.89999961853},

{2346.400390625,-1272.5,26.89999961853}, -- multi
{2339.8999023438,-1272.5,26.89999961853},
{2333.5000000000,-1272.5,26.89999961853},
{2325.400390625,-1272.5,26.89999961853},

{2346.400390625,-1272.5,26.89999961853}, -- pro
{2339.8999023438,-1272.5,26.89999961853},
{2333.5000000000,-1272.5,26.89999961853},
{2325.400390625,-1272.5,26.89999961853},

}

function createMarkersSkins ()
	for i, v in ipairs(pos) do
		local x, y, z = unpack(v)
		marker = createMarker(x, y, z, "cylinder", 1.5, 200 ,200, 0, 155)
		addEventHandler("onMarkerHit", marker, skins)
	end
end
addEventHandler("onResourceStart", resourceRoot, createMarkersSkins)


function skins(thePlayer)
   local team = getTeamName(getPlayerTeam( thePlayer ))
   if (team == "SOBREVIVENTE") then
      setElementModel(thePlayer, 71)
   outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
   
   elseif (team == "ASSASSINO" )then
      setElementModel(thePlayer, 73)
   outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
   
   elseif (team == "CAÇADOR")then
      setElementModel(thePlayer, 73)
   outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
   
   elseif (team == "MULTILADOR")then
      setElementModel(thePlayer, 74)
   outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
   
   elseif (team == "PROFISSIONAL")then
   setElementModel(thePlayer, 75)
   outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
end
end

obs: as markers estão iguais apenas para exemplo.

Me ajudem pls <3

Edited by Marcos^v7
Link to comment

Esses grupos de coordenadas seriam para respectivos times ?

Se eu entendi bem, você pode fazer assim:


local pos = {
	["SOBREVIVENTE"]= {
		{2346.400390625,-1272.5,26.89999961853}, -- sobre
		{2339.8999023438,-1272.5,26.89999961853},
		{2333.5000000000,-1272.5,26.89999961853},
		{2325.400390625,-1272.5,26.89999961853},
		teamSkin = 71
	},
	["ASSASSINO"]= {
		{2346.400390625,-1272.5,26.89999961853}, -- assssino
		{2339.8999023438,-1272.5,26.89999961853},
		{2333.5000000000,-1272.5,26.89999961853},
		{2325.400390625,-1272.5,26.89999961853},
		teamSkin = 73
	},
}

-- criando as marcas
function createMarkersSkins ()
	for k, v in pairs(pos) do
		for i=1, #v do
			local x, y, z = unpack(pos[k][i])
			setElementID( createMarker(x, y, z, "cylinder", 1.5, 200 ,200, 0, 155), k )
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, createMarkersSkins)

addEventHandler( "onMarkerHit", resourceRoot,
	function( hitPlayer )
		if getElementType(hitPlayer) == "player" then
			local g_team = getPlayerTeam(hitPlayer)
			if g_team and getTeamName(g_team) == getElementID(source) then
			
			end
		end
	end
)


function skins(thePlayer)
	local team = getPlayerTeam( thePlayer )
	if not team then return outputChatBox( "Você não está em nenhuma equipe", thePlayer ) end
	
	local table_data = pos[getTeamName(team)] or false
	if table_data then
		setElementModel(thePlayer, table_data.teamSkin)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	end
end

Coloquei identificação para as marcas, caso seja necessário obter qual o time que ela pertence.

  • Like 1
Link to comment
14 minutes ago, DNL291 said:

Esses grupos de coordenadas seriam para respectivos times ?

Se eu entendi bem, você pode fazer assim:


local pos = {
	["SOBREVIVENTE"]= {
		{2346.400390625,-1272.5,26.89999961853}, -- sobre
		{2339.8999023438,-1272.5,26.89999961853},
		{2333.5000000000,-1272.5,26.89999961853},
		{2325.400390625,-1272.5,26.89999961853},
		teamSkin = 71
	},
	["ASSASSINO"]= {
		{2346.400390625,-1272.5,26.89999961853}, -- assssino
		{2339.8999023438,-1272.5,26.89999961853},
		{2333.5000000000,-1272.5,26.89999961853},
		{2325.400390625,-1272.5,26.89999961853},
		teamSkin = 73
	},
}

-- criando as marcas
function createMarkersSkins ()
	for k, v in pairs(pos) do
		for i=1, #v do
			local x, y, z = unpack(pos[k][i])
			setElementID( createMarker(x, y, z, "cylinder", 1.5, 200 ,200, 0, 155), k )
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, createMarkersSkins)

addEventHandler( "onMarkerHit", resourceRoot,
	function( hitPlayer )
		if getElementType(hitPlayer) == "player" then
			local g_team = getPlayerTeam(hitPlayer)
			if g_team and getTeamName(g_team) == getElementID(source) then
			
			end
		end
	end
)


function skins(thePlayer)
	local team = getPlayerTeam( thePlayer )
	if not team then return outputChatBox( "Você não está em nenhuma equipe", thePlayer ) end
	
	local table_data = pos[getTeamName(team)] or false
	if table_data then
		setElementModel(thePlayer, table_data.teamSkin)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	end
end

Coloquei identificação para as marcas, caso seja necessário obter qual o time que ela pertence.

Queria fazer assim, tipo cada marker corresponder a um modelo de skin diferente... sendo 4 markers para cada team

	skin model 101	{2346.400390625,-1272.5,26.89999961853}, -- sobre
	skin model 102	{2339.8999023438,-1272.5,26.89999961853},
	skin model 103	{2333.5000000000,-1272.5,26.89999961853},
	skin model 104	{2325.400390625,-1272.5,26.89999961853},

 

Edited by Marcos^v7
Link to comment

Só colocar dentro da própria tabela das coordenadas:

{2346.400390625,-1272.5,26.89999961853, 101}, -- sobre
{2339.8999023438,-1272.5,26.89999961853, 102},
{2333.5000000000,-1272.5,26.89999961853, 103},
{2325.400390625,-1272.5,26.89999961853, 104},

--

function skins(thePlayer)
	local team = getPlayerTeam( thePlayer )
	if not team then return outputChatBox( "Você não está em nenhuma equipe", thePlayer ) end
	
	local table_data = pos[getTeamName(team)] or false
	if table_data then
		local skinID = table_data[1][4] -- skin 101
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	end
end

 

  • Like 1
Link to comment

testei assim, mais sem sucesso...

        local pos = {
    	["SOBREVIVENTE"]= {
    		{2346.400390625,-1272.5,26.89999961853,276}, -- sobre
    		{2339.8999023438,-1272.5,26.89999961853,277},
    		{2333.5000000000,-1272.5,26.89999961853,278},
    		{2325.400390625,-1272.5,26.89999961853,279},   		
    	},
    	["ASSASSINO"]= {
    		{2346.400390625,-1276.5,26.89999961853,234}, -- assssino
    		{2339.8999023438,-1276.5,26.89999961853,235},
    		{2333.5000000000,-1276.5,26.89999961853,236},
    		{2325.400390625,-1276.5,26.89999961853,237},
    	},
    }

    -- criando as marcas
    function createMarkersSkins ()
    	for k, v in pairs(pos) do
    		for i=1, #v do
    			local x, y, z = unpack(pos[k][i])
    			setElementID( createMarker(x, y, z, "cylinder", 1.5, 200 ,200, 0, 155), k )
    		end
    	end
    end
    addEventHandler("onResourceStart", resourceRoot, createMarkersSkins)

    addEventHandler( "onMarkerHit", resourceRoot,
    	function( hitPlayer )
    		if getElementType(hitPlayer) == "player" then
    			local g_team = getPlayerTeam(hitPlayer)
    			if g_team and getTeamName(g_team) == getElementID(source) then
    			skins(hitPlayer)
    			end
    		end
    	end
    )


function skins(thePlayer)
	local team = getPlayerTeam( thePlayer )
	if not team then return end
	
	local table_data = pos[getTeamName(team)] or false
	if table_data then
	  if table_data[1] then
		local skinID = table_data[1][4] -- skins 276, 234
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	  elseif table_data[2] then
		local skinID = table_data[2][4] -- skins 277, 235
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	  elseif table_data[3] then
		local skinID = table_data[3][4] -- skins 278, 236
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	  elseif table_data[4] then
		local skinID = table_data[4][4] -- skins 279, 237
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	end
end
end

sou meio ruim pra explicar como penso, mais acho que vc já tem uma noção de como quero fazer. Me ajude se puder.

Link to comment

Tente isto:

-- criando as marcas
function createMarkersSkins ()
	for k, v in pairs(pos) do
		for i=1, #v do
			local x, y, z = unpack(pos[k][i])
			setElementID( createMarker(x, y, z, "cylinder", 1.5, 200 ,200, 0, 155), k.."-"..tostring(i) )
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, createMarkersSkins)
	
addEventHandler( "onMarkerHit", resourceRoot,
	function( hitPlayer )
		if getElementType(hitPlayer) == "player" then
			local g_team = getPlayerTeam(hitPlayer)
			local marker_id = getElementID(source)
			if g_team and getTeamName(g_team) == marker_id:sub( 1, #id-2 ) then
				skins( hitPlayer, marker_id:sub( #id ) )
			end
		end
	end
)

function skins(thePlayer, index)
	local team = getPlayerTeam( thePlayer )
	if not team or not index then return end
	
	local table_data = pos[getTeamName(team)] or false
	if table_data and table_data[index] then
		local skinID = table_data[index][4] -- skins 276, 234
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	end
end

Se não funcionar, digite /debugscript 3 e veja se o debug mostra algum erro.

  • Like 1
Link to comment
4 minutes ago, DNL291 said:

Substitua id com marker_id (na condição e na função skins).

		if g_team and getTeamName(g_team) == marker_id:sub( 1, #marker_id-2 ) then
    				skins( hitPlayer, marker_id:sub( #marker_id ) )

assim?

Edited by Marcos^v7
Link to comment
addEventHandler( "onMarkerHit", resourceRoot,
	function( hitPlayer )
		if getElementType(hitPlayer) == "player" then
			local g_team = getPlayerTeam(hitPlayer)
			local marker_id = getElementID(source)
			outputChatBox("@marker_id: "..tostring(marker_id))
			if g_team and getTeamName(g_team) == marker_id:sub( 1, #marker_id-2 ) then
				outputChatBox("@teamName: "..tostring(getTeamName(g_team)))
				skins( hitPlayer, marker_id:sub( #marker_id ) )
			end
		end
	end
)

function skins(thePlayer, index)
	local team = getPlayerTeam( thePlayer )
	if not team or not index then return end
	outputChatBox("@index: "..tostring(index))
	outputChatBox("@thePlayer: "..tostring(thePlayer))
	
	local table_data = pos[getTeamName(team)] or false
	outputChatBox("@table_data: "..tostring(table_data))
	if table_data and table_data[index] then
		outputChatBox("@table_data[index]: "..tostring(table_data[index]))
		local skinID = table_data[index][4] -- skins 276, 234
		outputChatBox("@skinID: "..tostring(skinID))
		setElementModel(thePlayer, skinID)
		outputChatBox (getPlayerName(thePlayer).." você trocou sua skin",thePlayer, 0, 255, 0,true)
	end
end

Faça um teste usando essas duas funções e mostre aqui todas saídas no chat, por favor.

  • Like 1
Link to comment
@marker_id: SOBREVIVENTE-1
@teamName: SOBREVIVENTE
@index: 1
@thePlayer: userdata: 00000EA2
@table_data: table: 00B66668

@marker_id: SOBREVIVENTE-2
@teamName: SOBREVIVENTE
@index: 2
@thePlayer: userdata: 00000EA2
@table_data: table: 00B66668

@marker_id: SOBREVIVENTE-3
@teamName: SOBREVIVENTE
@index: 3
@thePlayer: userdata: 00000EA2
@table_data: table: 00B66668

@marker_id: SOBREVIVENTE-4
@teamName: SOBREVIVENTE
@index: 4
@thePlayer: userdata: 00000EA2
@table_data: table: 00B66668

-

@marker_id: ASSASSINO-4
@marker_id: ASSASSINO-3
@marker_id: ASSASSINO-2
@marker_id: ASSASSINO-1

Estou na Sobrevivente

Edited by Marcos^v7
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...