Jump to content

Ayuda donde puede estar el error.


Recommended Posts

local blips = { }
local ref = { }


addCommandHandler ( "ref",
	function ( player )
		local x, y, z = getElementPosition ( player )
		local city = getZoneName ( x, y, z )
		local ref = ref [ player ]
		local blip = blips [ player ]
		if exports.factions:isPlayerInFaction ( player, 1 ) then
			getPolicias ( )
			if ref == false or ref == nil then
				exports.chat:me ( player, "pide refuerzos por su radio." )
				for i=1, #policias do
					local value = policias [ i ]
					blips [ player ] = createBlipAttachedTo ( player, 0, 3, 255, 255, 0 )
					setElementVisibleTo ( blips [ player ], root, false )
					setElementVisibleTo ( blips [ player ], value, true )					
				end
				exports.factions:sendMessageToFaction ( 1, "El compañero "..getPlayerName (player).." ha pedido refuerzos en "..city..". Punto marcado en el GPS.", 255, 255, 0 )				
				ref[ player ] = true
			else
				if isElement ( blip ) then
					destroyElement ( blip )
				end
				exports.chat:me ( player, "cancela los refuerzos por su radio." )
				exports.factions:sendMessageToFaction ( 1, "El compañero "..getPlayerName (player).." ha cancelado los refuerzos.", 255, 255, 0 )
				ref[ player ] = false
			end
		end
	end
)

 

 

¿Donde podria estar el error?, al usar /ref , marca donde esta la persona pero cuando lo vuelvo a poner /ref no se quita el blip sino que pide refuerzos denuevo.

Link to comment

Esto debería de funcionar, la tabla ref esta al dope.

 

local blips = {}

addCommandHandler ( "ref",
	function ( player )
		local x, y, z = getElementPosition ( player )
		local city = getZoneName ( x, y, z )
		if exports.factions:isPlayerInFaction ( player, 1 ) then
			getPolicias ( )
			if not blips[player] then
				exports.chat:me ( player, "pide refuerzos por su radio." )
				for i=1, #policias do
					local value = policias [ i ]
					blips [ player ] = createBlipAttachedTo ( player, 0, 3, 255, 255, 0 )
					setElementVisibleTo ( blips [ player ], root, false )
					setElementVisibleTo ( blips [ player ], value, true )					
				end
				exports.factions:sendMessageToFaction ( 1, "El compañero "..getPlayerName (player).." ha pedido refuerzos en "..city..". Punto marcado en el GPS.", 255, 255, 0 )
			else
				if isElement ( blips[player] ) then
					destroyElement ( blips[player] )
				end
				exports.chat:me ( player, "cancela los refuerzos por su radio." )
				exports.factions:sendMessageToFaction ( 1, "El compañero "..getPlayerName (player).." ha cancelado los refuerzos.", 255, 255, 0 )
				blips[player] = nil
			end
		end
	end
)

 

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...