Jump to content

isElementVisibleTo strange error


kuwalda

Recommended Posts

I got this function going on for me

function testejam(thePlayer, command) 
    if ( getElementData( thePlayer, "allowrace"  ) == 1 ) then 
                if ( getElementData ( thePlayer, "dbid" ) == 2 ) then 
                    setElementData(thePlayer, "laiks", getTickCount ()) 
                end 
            local ciga = getElementData ( thePlayer, "dbid" ) 
            outputChatBox("Tavs ID:"..tonumber(ciga)..".", thePlayer, 255, 255, 0) 
            destroyElement(markeritis) 
            markeritis = createMarker ( blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170 ) 
            setElementVisibleTo(markeritis, root, false) 
            setElementVisibleTo(markeritis, thePlayer, true) 
            if ( #blueBerryRally == ciga ) then 
                outputChatBox(Finished", thePlayer, 255, 255, 0) 
                outputChatBox("Finisha time:"..(getTickCount () - getElementData( thePlayer, "laiks" )) / 1000 .."sec. GL NEXT TIME", root, 255, 255, 0) 
                setElementData(thePlayer, "dbid", 1) 
            end  
            setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) 
        if isElementVisibleTo(markeritis,source) then 
            addEventHandler( "onMarkerHit", markeritis, testejam ) 
        end 
    end 
end 
addCommandHandler("race", testejam) 
 

And my question is - why does it give

Bad argument @ 'isElementVisibleTo' [Expected element at argument 2, got nil] ? Have tried alot of variables, none of them worked. :|

Link to comment
function testejam(thePlayer, command) 
    if ( getElementData( thePlayer, "allowrace"  ) == 1 ) then 
                if ( getElementData ( thePlayer, "dbid" ) == 2 ) then 
                    setElementData(thePlayer, "laiks", getTickCount ()) 
                end 
            local ciga = getElementData ( thePlayer, "dbid" ) 
            outputChatBox("Tavs ID:"..tonumber(ciga)..".", thePlayer, 255, 255, 0) 
            destroyElement(markeritis) 
            markeritis = createMarker ( blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170 ) 
            setElementVisibleTo(markeritis, root, false) 
            setElementVisibleTo(markeritis, thePlayer, true) 
            if ( #blueBerryRally == ciga ) then 
            outputChatBox("Finished", thePlayer, 255, 255, 0) 
                outputChatBox("Finisha time:"..(getTickCount () - getElementData( thePlayer, "laiks" )) / 1000 .."sec. GL NEXT TIME", root, 255, 255, 0) 
                setElementData(thePlayer, "dbid", 1) 
            end  
            setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) 
        if isElementVisibleTo(markeritis,source) then 
            addEventHandler( "onMarkerHit", markeritis, testejam ) 
        end 
    end 
end 
addCommandHandler("race", testejam) 

Use Mta Script Editor to see the Error of the Script ,

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