Jump to content

Script para borrar marcador?


Recommended Posts

Hola, soy nuevo y buscando en la wiki puse este comand

 

Spoiler

function consoleCreateMarker ( thePlayer, commandName )
   if ( thePlayer ) then
      local x, y, z = getElementPosition ( thePlayer ) -- get the player's position
      -- create a cylindrical marker next to the player:
      local theMarker = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 255, 0, 170 )
      if ( theMarker ) then -- check if the marker was created successfully
         outputConsole ( "El marcador se ha creado correctamente", thePlayer )
      else
         outputConsole ( "Failed to create marker", thePlayer )
      end
   end
end
addCommandHandler ( "createma", consoleCreateMarker )

Pero como hago un comando para borrar este elemento?

 

 

Edited by Mikhail
Link to comment

hice esto pero no me funciona, me dice

 

Spoiler

function marker11 ( marker11 )
    if isElementWithinMarker(thePlayer) then -- checking if player is in a marker 
        destroyElement ( marker )
    end 
end

 

Bad argument @ 'isElementWithinMarker' [Expected element at argument 1, got nil]

Edited by Mikhail
Link to comment
  • 3 weeks later...

function ConsoleEliminarMarker ( thePlayer, commandName )
   if ( thePlayer ) then
      if ( theMarker ) then -- check if the marker was created successfully
         destroyElement ( theMarker )
      else
         outputConsole ( "Failed to delete marker", thePlayer )
      end
   end
end
addCommandHandler ( "deletetema", ConsoleEliminarMarker )

Link to comment
On 19/10/2018 at 19:19, MedicenMarcos said:

function ConsoleEliminarMarker ( thePlayer, commandName )
   if ( thePlayer ) then
      if ( theMarker ) then -- check if the marker was created successfully
         destroyElement ( theMarker )
      else
         outputConsole ( "Failed to delete marker", thePlayer )
      end
   end
end
addCommandHandler ( "deletetema", ConsoleEliminarMarker )

function ConsoleEliminarMarker ( thePlayer, commandName )
	if isElement(theMarker) then
		destroyElement(theMarker)
		theMarker = nil
	else
		outputConsole( "Failed to delete marker", thePlayer )
	end
end
addCommandHandler( "deletetema", ConsoleEliminarMarker )

Cuando creas un elemento y lo guardas en una variable asegúrate de limpiar esa variable para liberar memoria.

Link to comment
On 23/10/2018 at 14:05, Enargy, said:

function ConsoleEliminarMarker ( thePlayer, commandName )
	if isElement(theMarker) then
		destroyElement(theMarker)
		theMarker = nil
	else
		outputConsole( "Failed to delete marker", thePlayer )
	end
end
addCommandHandler( "deletetema", ConsoleEliminarMarker )

Cuando creas un elemento y lo guardas en una variable asegúrate de limpiar esa variable para liberar memoria.

? Ok gracias por la sugerencia!

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