Jump to content

script error ~ I need Help


Booo

Recommended Posts

hi

my script have errors ...

can any one fix it please .!

  
  
  
  
function see() 
        local players = getElementsByType ( "player" ) 
            for k,v in ipairs(players) do 
            local seemark = getElementData(v,"seemark") 
                if seemark then 
                    return v 
                                          else 
                                       return false 
                end 
            end 
end 
  
function consoleCreateMarker ( thePlayer, commandName ) 
   if ( thePlayer ) then 
      local x, y, z = getElementPosition ( thePlayer )  
      setElementData(thePlayer,"seemark",true) 
      local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) 
   end 
end 
addCommandHandler ( "createmarker", consoleCreateMarker ) 
  
  
  
  
  
  
  
  

Edited by Guest
Link to comment

I fixed it for you and added some help:

function see() 
local players = getElementsByType ( "player" ) 
    for k,v in ipairs(players) do 
    local seemark = getElementData(v,"seemark") 
        if seemark == true then -- If the element data is true 
            return v 
            else 
            return false 
            end 
    end 
end 
  
function consoleCreateMarker ( thePlayer, commandName ) 
   if ( thePlayer ) then 
      local x, y, z = getElementPosition ( thePlayer ) 
      setElementData(thePlayer,"seemark","true") -- set it true 
      local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) 
   end 
end 
addCommandHandler ( "createmarker", consoleCreateMarker ) 

(tested)

Link to comment
I fixed it for you and added some help:
function see() 
local players = getElementsByType ( "player" ) 
    for k,v in ipairs(players) do 
    local seemark = getElementData(v,"seemark") 
        if seemark == true then -- If the element data is true 
            return v 
            else 
            return false 
            end 
    end 
end 
  
function consoleCreateMarker ( thePlayer, commandName ) 
   if ( thePlayer ) then 
      local x, y, z = getElementPosition ( thePlayer ) 
      setElementData(thePlayer,"seemark","true") -- set it true 
      local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) 
   end 
end 
addCommandHandler ( "createmarker", consoleCreateMarker ) 

(tested)

not work !!

Link to comment

Try now:

function see() 
local players = getElementsByType ( "player" ) 
    for k,v in ipairs(players) do 
    local seemark = getElementData(v,"seemark") 
        if seemark == "true" then -- If the element data is true 
            return v 
            else 
            return false 
            end 
    end 
end 
  
function consoleCreateMarker ( thePlayer, commandName ) 
   if ( thePlayer ) then 
      local x, y, z = getElementPosition ( thePlayer ) 
      setElementData(thePlayer,"seemark","true") -- set it true 
      local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) 
   end 
end 
addCommandHandler ( "createmarker", consoleCreateMarker ) 

Link to comment

It's wrong.

In last argument you attach function -_-

Here

local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) 

Also

if ( thePlayer ) then 

This condition not needed. This command triggered when you type this command. So if you type this command player is element in any case.

Better way

addCommandHandler ( 'createmarker',  
    function( uPlayer ) 
        local nX, nY, nZ = getElementPosition ( uPlayer ) 
        local uMarker = createMarker ( nX + 2, nY + 2, nZ, 'cylinder', 1.5, 255, 255, 0, 170, uPlayer ) 
    end 
) 

Link to comment

What I understand is that you want to show the marker to the player who created it, if so you can use setElementVisibleTo.

function consoleCreateMarker ( thePlayer ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170 ) 
    setElementVisibleTo ( theMarker, root, false ) -- Hide the marker to everyone. 
    setElementVisibleTo ( theMarker, thePlayer, true ) -- Show the marker to the player. 
end 
addCommandHandler ( "createmarker", consoleCreateMarker ) 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...