Jump to content

How to destroy marker with command??


Mikhail

Recommended Posts

Posted (edited)

I did this

 

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 marker1 = 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 )

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

 

(I'm new in scripting)

but this gives me this:

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

Edited by Mikhail
Posted (edited)
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 marker1 = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 255, 0, 170 )
      if ( marker1 ) 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 )

function marker11 (thePlayer )
    if isElementWithinMarker(thePlayer, marker1) then -- checking if player is in a marker 
        destroyElement ( marker1)
    end 
end
addCommandHandler("deletema", marker11 )

 

Edited by Dimos7
Posted
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:
      marker1 = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 255, 0, 170 )
      if ( marker1 ) 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 )

function marker11 (thePlayer )
    if isElementWithinMarker(thePlayer) then -- checking if player is in a marker 
        destroyElement ( marker1)
    end 
end
addCommandHandler("deletema", marker11 )

 

Posted (edited)
9 hours ago, Gw8 said:

change marker to a global variable.

how to do it? sorry im new in lua. 

 

@Dimos7

 

Bad argument @ 'isElementWithinMarker' [Expected marker at argument 2, got none]

 

i think the entire destroy function is wrong... is another way to write it?

Edited by Mikhail
Posted
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:
      marker1 = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 255, 0, 170 )
      if ( marker1 ) 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 )

function marker11 (thePlayer )
    if isElementWithinMarker(thePlayer,marker1) then -- checking if player is in a marker 
        destroyElement ( marker1)
    end 
end
addCommandHandler("deletema", marker11 )

enjoy

Posted

@Master_MTA

 

ok your script said it:         lua:20: unexpected symbol near 'ï' 

addCommandHandler("deletema", marker11 )

 

but I rewrote it to:

addCommandHandler ( "deletee", marker11)

and it worked!

 

but I have a query, could you explain in detail what change you in my script? because obviously you modify something, could you tell me my mistake and what do you modify? So I learn! although I am reading the wiki, we learn from mistakes, and better if you explain it to me ..

Posted

@Master_MTA

 

oh. ok... im trying to put some more and in the chat dont shows...

function marker11 (thePlayer )
	if isElementWithinMarker(thePlayer,marker1) then -- checking if player is in a marker
	destroyElement ( marker1)
	else
	outputConsole ( "you should be in the marker to delete it", thePlayer)	
    end 
end
addCommandHandler ( "deletee", marker11)

and there are conflicts when I create more than 1 marker and I want to delete them 1 by 1 ... how would the command or the constant to delete all created?

 

this would end the script ..

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