Jump to content

Getting Number, Not Tabel


xXMADEXx

Recommended Posts

Posted

For some reason, its saying that @ line 5 (client) ( local name = getVehicleNameFromModel(v) ) that "V" is a bad argument

- Server

function addGroupSpawner(pos,cars,color) 
    x,y,z,rotz = unpack(pos) 
    local r,g,b = unpack (color) 
    marker = createMarker(x, y, z - 1, "cylinder", 2, r, g, b, 150) 
    addEventHandler("onMarkerHit",marker, 
        function (p) 
            triggerClientEvent(p,"showGroupVehicleSpawners",p,cars) 
        end 
    ) 
end 
  
addGroupSpawner({1319.1091308594, -2584.6645507813, 13.5390625}, {{411}, {412}}, {120, 0, 255}) 
  
----------------------- 
-- Unfinsihed 
----------------------- 
vehicle = {} 
function onCreateGroupVehicle(id) 
    if (id) then 
        vehicle[source] = createVehicle(id, x, y, z, rotz) 
    end 
end 
addEvent("onCreateGroupVehicle",true) 
addEventHandler("onCreateGroupVehicle",root,onCreateGroupVehicle) 
  

- Bugged client area

function showGroupVehicleSpawners(cars) 
    guiSetVisible(window['groups'],true) 
    showCursor(true) 
    for i,v in ipairs (cars) do 
        local name = getVehicleNameFromModel(v)  
        row = guiGridListAddRow(gridlist['groups']) 
        guiGridListSetItemText(gridlist['groups'], row, 1, name, false, false) 
        guiGridListSetItemData(gridlist['groups'], row, 1, v) 
    end 
end 
addEvent("showGroupVehicleSpawners",true) 
addEventHandler("showGroupVehicleSpawners",root,showGroupVehicleSpawners) 

Posted
Where is "cars" define?

on srever side:

addGroupSpawner({1319.1091308594, -2584.6645507813, 13.5390625}, {{411}, {412}}, {120, 0, 255})

(the "{{411}, {412}}")

Posted

Well it's obviously gona give you Bad Arg, Because ipairs loops all the table, And when you try to get the id from that table it won't work, because you'll get some wrong car IDs ..

Posted
Well it's obviously gona give you Bad Arg, Because ipairs loops all the table, And when you try to get the id from that table it won't work, because you'll get some wrong car IDs ..

so, how exacly do i fix this?

Posted
Well it's obviously gona give you Bad Arg, Because ipairs loops all the table, And when you try to get the id from that table it won't work, because you'll get some wrong car IDs ..

so, how exacly do i fix this?

Use pairs instead.

Posted
Well it's obviously gona give you Bad Arg, Because ipairs loops all the table, And when you try to get the id from that table it won't work, because you'll get some wrong car IDs ..

so, how exacly do i fix this?

Use pairs instead.

I already tried that, and can someone tell me the differance between pairs and ipairs?

Posted

If cars table is {{411}, {412}}, then v will be {411} and {412} and getVehicleNameFromModel only accepts numbers, not tables.

Posted

Your table has to be like this:

myTable = 
{ 
    item1, 
    item2, 
    item3, 
    etc... 
} 

And yours is like this:

myTable = 
{ 
    { 
        item1 
    }, 
    { 
        item2 
    }, 
    { 
        item3 
    }, 
    { 
        etc... 
    } 
} 

Posted
Your table has to be like this:
myTable = 
{ 
    item1, 
    item2, 
    item3, 
    etc... 
} 

And yours is like this:

myTable = 
{ 
    { 
        item1 
    }, 
    { 
        item2 
    }, 
    { 
        item3 
    }, 
    { 
        etc... 
    } 
} 

Thank you castillo.

Please lock topic, i solved it.

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