Murilo_apa Posted December 30, 2022 Share Posted December 30, 2022 function giveV(player, car_id) if player and isElement(player) then if car_id and type(car_id) == 'number' then local _,i = hasV(player, car_id) local garagem = getElementData(player, 'conce.garage') or {} if i then outputChatBox('Você já tem este carro!') --infobox return false else table.insert(garagem, {id = car_id}) setElementData(player, 'conce.garagem', garagem) outputChatBox('Você adquiriu um '..vehicle[car_id].name..'.') --infobox return true end else outputDebugString('Aguardando arg #2 válido para a function hasV') return false end else outputDebugString('Aguardando arg #1 válido para a function hasV') return false end end I'm struggling to make a dealership script, but the giveV function doesn't add the car to the garage list even if the checks pass. Can anyone help? Link to comment
Trust aka Tiffergan Posted December 31, 2022 Share Posted December 31, 2022 Make sure that the vehicle table that is being referenced in the function actually exists and has an entry for the car_id that you are passing to the function. Make sure that the hasV function is correctly implemented and returns the expected values. Check if there are any errors being thrown by the script by enabling debugging in your script editor or by using the outputDebugString function to print error messages to the console. Make sure that the garagem table is being correctly initialized and that it is being set as an element data attribute of the player. Check if the setElementData function is being called correctly and if it is returning the expected result. Make sure that you are calling the giveV function with the correct arguments. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now