Jump to content

insert.table problem


HustraDev

Recommended Posts

Hello All,

i have been scripting a car show with a grid list spawner for the bought cars

but when i use insert.table to insert values to spawn gridlist i Failed typing the code

so i need some help right here

code Server :

  
addEvent ("createcar", true) 
addEventHandler ("createcar", getRootElement(),  
function(carID, carName, carPrice) 
--- 
  if (getPlayerMoney (source) >= tonumber(carPrice)) then 
    outputChatBox ("Bought a " .. carName, source, 255, 0, 0, false) 
    outputChatBox ("ID: " .. carID, source, 255, 0, 0, false) 
    outputChatBox ("Cost: " .. carPrice, source, 255, 0, 0, false) 
    takePlayerMoney (source, tonumber (carPrice)) 
    local x, y, z = getElementPosition ( source ) 
    createVehicle ( carID, x, y + 5, z ) 
    triggerClientEvent( source, 'table', source , carID, carName) 
  else 
    outputChatBox ("no money", source, 255, 0, 0, false) 
  end 
end) 
  

Client :

  
addEvent ( 'table', true)  
addEventHandler( 'table', localPlayer, 
function(carID, carName) 
table.insert(pcars,carID,carName) 
end 
) 
  

Thanks :mrgreen:

Link to comment
I think you were probably trying to get this:
addEvent ( "table", true ) 
addEventHandler ( "table", root, function ( id, name ) 
      if ( not pcars ) then pcars = { } end 
      table.insert ( pcars, { id, name } ) 
end ) 

i try it but nothing shows in gridlist

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