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

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

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
54 minutes ago, Mikhail said:

script

am just added the second argument in

isElementWithinMarker(thePlayer)

to make it like this

isElementWithinMarker(thePlayer,marker1)

 

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

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

Posted
4 minutes ago, Mikhail said:

created

u better use table+loop

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

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