HustraDev Posted August 19, 2014 Share Posted August 19, 2014 Hello All, I Made A Car Shop The Idea About it When I Buy a Car from the Main Window the Car Add for A Table And set As data and Shows in grid list so i need some one to repair this code and Shows the bought cars in grid list client side : Tables : cars = { ---- table of the cars { 517,'camry',1999 }, { 331,'Car Name 2',299 }, { 333,'Car Name 3',399 }, { 404,'Car Name 4',499 }, { 413,'Car Name 5',599 }, { 411,'Car Name 6',999 }, } pcars = { ---- Table of the Bought cars } for k,v in ipairs ( pcars ) do local row = guiGridListAddRow (spcar) guiGridListSetItemText (spcar, row, 1,v [1] , false, false) guiGridListSetItemText (spcar, row, 2, v [2], false, false) end for k,v in ipairs ( cars ) do local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1,v [1] , false, false) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v [2], false, false) guiGridListSetItemText (GUIEditor.gridlist[1], row, 3, v [3] , false, false) end function buycar() if (source == GUIEditor.button[2]) then if (guiGridListGetSelectedItem (GUIEditor.gridlist[1])) then local carID = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 1) local carName = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 2) local carPrice = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 3) triggerServerEvent ("createcar", getLocalPlayer(), carID, carName, carPrice) end end end addEventHandler ("onClientGUIClick", getRootElement(), buycar) ----- addEvent ( "table", true ) addEventHandler ( "table", root, function ( carID, carName ) if ( not pcars ) then pcars = { } end table.insert ( pcars, { carID, carName } ) end ) function spawn() if (source == spawncar) then if (guiGridListGetSelectedItem (spcar)) then local carID = guiGridListGetItemText (spcar, guiGridListGetSelectedItem (spcar), 1) local carName = guiGridListGetItemText (spcar, guiGridListGetSelectedItem (spcar), 2) triggerServerEvent ("spawnpla", getLocalPlayer(), carID, carName) end end end addEventHandler ("onClientGUIClick", getRootElement(), spawn) ----- 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)) setAccountData (getPlayerAccount (source), "funmodev2-car", tonumber(CarID)) setAccountData (getPlayerAccount (source), "funmodev2-paintjob", 3) setAccountData (getPlayerAccount (source), "funmodev2-carupg", 0) triggerClientEvent( source, 'table', source , CarID, carName) else outputChatBox ("msg", source, 255, 0, 0, false) end end ) addEvent ("spawnpla", true) addEventHandler ("spawnpla", root, function (CarID,CarName) if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then if (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) and (getElementType(getElementData (source, "hisCar")) == "vehicle") then setElementVelocity (getElementData (source, "hisCar"), 0,0,0) local x,y,z = getElementPosition (source) setVehicleRotation (getElementData (source, "hisCar"), 0, 0, 0) setElementPosition (getElementData (source, "hisCar"), x+2,y,z +1) outputChatBox ("Car spawned.", source, 255, 0, 0) elseif not (getElementData (source, "hisCar")) then local accountData = getAccountData (getPlayerAccount (source), "funmodev2-car") if (accountData) then CarID = getAccountData (getPlayerAccount (source), "funmodev2-car") x,y,z = getElementPosition (source) vehicle = createVehicle (CarID, x +2, y, z +1) setElementID (vehicle, getAccountName (getPlayerAccount(source))) setElementData (source, "hisCar", vehicle) outputChatBox ("carsspwaned.", source, 255, 0, 0) end end end end ) sorry for bad english I hope you understand me Thanks , Link to comment
HustraDev Posted August 20, 2014 Author Share Posted August 20, 2014 Refresh Help ! ~ Link to comment
Captain Cody Posted August 20, 2014 Share Posted August 20, 2014 Hmm well I cant help but I can tell people wat yee need He Needs it so it adds the bought cars to a table but he cant figure out how/ 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