Jump to content

Table problem


SkatCh

Recommended Posts

guys please i need some help here :

example :

jobsLocation = { 
{job = "Police Officer", x = 249.6259765625,y = 67.8125,z = 1002.9, r = 67, g = 156, b = 255, int = 6 , dim = 1 , team = "Police Force", skin = {280, 281, 282, 283, 284, 288}, jobEvent = "policeTaken", maxWL = 0, description =" bla bla bla bla bla"},   

function ceateJobLocations() 
    for index, val in pairs(jobsLocation) do 
        marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) 
        name[marker] = val.job 
        setElementDimension (marker , val.dim ) 
        setElementInterior (marker , val.int) 
        addEventHandler("onMarkerHit", marker, enteredMarker) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) 

warnings :

"setElementinterior " [Excepted number at argument 2 , got nil ] and the same warnig with setElementDimension , so please how can i fix it .

Link to comment
  
    function ceateJobLocations() 
        for index, val in pairs(jobsLocation) do 
            marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) 
            name[marker] = val.job 
            setElementDimension (marker , val.dimen ) 
            setElementInterior (marker , val.inter) 
            addEventHandler("onMarkerHit", marker, enteredMarker) 
        end 
    end 
    addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) 
  

  
    jobsLocation = { 
    {job = "Police Officer", x = 249.6259765625,y = 67.8125,z = 1002.9, r = 67, g = 156, b = 255, inter = 6 , dimen = 1 , team = "Police Force", skin = {280, 281, 282, 283, 284, 288}, jobEvent = "policeTaken", maxWL = 0, description =" bla bla bla bla bla"},   
  

Link to comment
function ceateJobLocations() 
    for index, val in pairs(jobsLocation) do 
        marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) 
        name[marker] = val.job 
        setElementDimension (marker , val[1][8] ) 
        setElementInterior (marker , val[1][9]) 
        addEventHandler("onMarkerHit", marker, enteredMarker) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) 

Link to comment
  • Moderators

There is only 1 way to find out. Which a scripter should first do, before posting his code here on the forum. :|

ALSO KNOWN AS DEBUGGING

jobsLocation = { 
    {job = "Police Officer", x = 249.6259765625,y = 67.8125,z = 1002.9, r = 67, g = 156, b = 255, interior = 6 , dimension = 1 , team = "Police Force", skin = {280, 281, 282, 283, 284, 288}, jobEvent = "policeTaken", maxWL = 0, description =" bla bla bla bla bla"}   
} 

function ceateJobLocations() 
    for index, val in pairs(jobsLocation) do 
        local marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) 
        if marker then 
            name[marker] = val.job 
            local dimension = tonumber(val.dimension) 
            if dimension then 
                setElementDimension (marker, dimension ) 
            else 
                outputDebugString("Failed to set dimension, variable is nil/false. Table index: " .. index .. " .") 
            end 
            local interior = tonumber(val.interior) 
            if interior then 
                setElementInterior (marker, interior) 
            else 
                outputDebugString("Failed to set interior, variable is nil/false. Table index: " .. index .. " .") 
            end 
             
            addEventHandler("onMarkerHit", marker, enteredMarker) 
        else 
            outputDebugString("Failed to create marker. Table index: " .. index .. " .") 
        end 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) 

Link to comment
  • Moderators

You never know, because I have the feeling he has more items inside his table then he is showing us at the moment.

He may have defined one with a string or even a userdata.

If you want to know what is going wrong, you have to keep open all options and possibility's.

Link to comment
You never know, because I have the feeling he has more items inside his table then he is showing us at the moment.

He may have defined one with a string or even a userdata.

If you want to know what is going wrong, you have to keep open all options and possibility's.

+1

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