DRW Posted April 23, 2015 Share Posted April 23, 2015 I have a problem. There is a resource called "carsystem" by diesel974, and I want it to save every modification that I do to my car, so when I respawn it, the upgrades would appear. This is the part I want to modify. addEvent("spawncar1",true) addEventHandler("spawncar1",getRootElement(), function() if not (isGuestAccount(getPlayerAccount(client))) then if not (isPedInVehicle(client)) then local x,y,z = getElementPosition(client) if (getElementData(client,"mycar1")) and (getElementData(client,"mycar1")~= nil) --[[and (getElementType(getElementData(client,"mycar1")) =="vehicle")]] then local vehicle = getElementData(client,"mycar1") destroyElement(vehicle) removeElementData(client,"mycar1") --local x,y,z = getElementPosition(vehicle) --setElementPosition(vehicle,x,y,z) outputChatBox("Vehicle destroyed",client) --[[ local vehicle = getElementData(client,"mybik1") destroyElement(vehicle) removeElementData(client,"mybik1") outputChatBox("Vehicle destroyed",client)]] elseif not (getElementData(client,"mycar1")) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot1 WHERE PlayerName = ?",name) if (playercar) then if #playercar > 0 then local x,y,z = getElementPosition(client) local vehicle = createVehicle(playercar[1].Model,x + 5,y +2,z) setVehiclePaintjob(vehicle,playercar[1].Paintjob) setElementData(vehicle,"vehicleOwner","mycar1") setElementData (vehicle,"mycar1",getPlayerName(source)) setElementData (client, "mycar1", vehicle) setElementData(vehicle,"VOwner",getPlayerName(client)) outputChatBox ("Car spawned.", source, 255, 0, 0) addVehicleUpgrade(vehicle, playercar[1].Upgrade0) addVehicleUpgrade(vehicle, playercar[1].Upgrade1) addVehicleUpgrade(vehicle, playercar[1].Upgrade2) addVehicleUpgrade(vehicle, playercar[1].Upgrade3) addVehicleUpgrade(vehicle, playercar[1].Upgrade4) addVehicleUpgrade(vehicle, playercar[1].Upgrade5) addVehicleUpgrade(vehicle, playercar[1].Upgrade6) addVehicleUpgrade(vehicle, playercar[1].Upgrade7) addVehicleUpgrade(vehicle, playercar[1].Upgrade8) addVehicleUpgrade(vehicle, playercar[1].Upgrade9) addVehicleUpgrade(vehicle, playercar[1].Upgrade10) addVehicleUpgrade(vehicle, playercar[1].Upgrade11) addVehicleUpgrade(vehicle, playercar[1].Upgrade12) addVehicleUpgrade(vehicle, playercar[1].Upgrade13) addVehicleUpgrade(vehicle, playercar[1].Upgrade14) addVehicleUpgrade(vehicle, playercar[1].Upgrade15) addVehicleUpgrade(vehicle, playercar[1].Upgrade16) local col1 = gettok (playercar[1].Color, 1, string.byte(',') ) local col2 = gettok (playercar[1].Color, 2, string.byte(',') ) local col3 = gettok (playercar[1].Color, 3, string.byte(',') ) local col4 = gettok (playercar[1].Color, 4, string.byte(',') ) local col5 = gettok (playercar[1].Color, 5, string.byte(',') ) local col6 = gettok (playercar[1].Color, 6, string.byte(',') ) outputChatBox(col1) if col1 then setVehicleColor(vehicle, tonumber(col1), tonumber(col2), tonumber(col3), tonumber(col4), tonumber(col5), tonumber(col6)) end else outputChatBox("No has comprado un vehículo en esta ranura.",client) end end end else outputChatBox("Primero sal del coche",client) end else outputChatBox("¡Loguéate!",client) end end) There is the complete Server-Sided script. carMarker1 = createMarker(-510.4805,2601.1999,52.27031,"cylinder",2,100,100,0,200) carMarker2 = createMarker(-1951.9349,273.04946,34.468,"cylinder",2,100,100,0,200) carMarker3 = createMarker(542.237426,-1290.63793,17.24218,"cylinder",2,100,100,0,200) createBlipAttachedTo(carMarker1,55,2,0,0,0,255,0,180) createBlipAttachedTo(carMarker2,55,2,0,0,0,255,0,180) createBlipAttachedTo(carMarker3,55,2,0,0,0,255,0,180) bikMarker1 = createMarker(1045.79919,1016.98663,11,"cylinder",2,100,0,100,200) bikMarker2 = createMarker(-1883.037597,825.024597,35.174198,"cylinder",2,100,0,100,200) bikMarker3 = createMarker(1108.807250,-1796.07531,16.59375,"cylinder",2,100,0,100,200) createBlipAttachedTo(bikMarker1,8,2,0,0,0,255,0,180) createBlipAttachedTo(bikMarker2,8,2,0,0,0,255,0,180) createBlipAttachedTo(bikMarker3,8,2,0,0,0,255,0,180) planeMarker1 = createMarker(1668.717529,1471.637207,10.77422,"cylinder",2,0,100,100,200) planeMarker2 = createMarker(-1261.489624,39.369747,14.139139,"cylinder",2,0,100,100,200) planeMarker3 = createMarker(1644.834960,-2286.074951,-1.202478,"cylinder",2,0,100,100,200) createBlipAttachedTo(planeMarker1,5,2,0,0,0,255,0,180) createBlipAttachedTo(planeMarker2,5,2,0,0,0,255,0,180) createBlipAttachedTo(planeMarker3,5,2,0,0,0,255,0,180) boatMarker1 = createMarker(2019.428466,1545.56347,10.8271465,"cylinder",2,100,150,200,200) boatMarker2 = createMarker(-1738.0865478,30.515306,3.55468,"cylinder",2,100,150,200,200) boatMarker3 = createMarker(154.420471,-1943.23535,3.773437,"cylinder",2,100,150,200,200) createBlipAttachedTo(boatMarker1,9,2,0,0,0,255,0,180) createBlipAttachedTo(boatMarker2,9,2,0,0,0,255,0,180) createBlipAttachedTo(boatMarker3,9,2,0,0,0,255,0,180) addEventHandler("onMarkerHit",getRootElement(), function(hitElement) if (source == carMarker1) or (source == carMarker2) or (source == carMarker3) then triggerClientEvent(hitElement,"showcarmarker",hitElement) elseif (source == bikMarker1) or (source == bikMarker2) or (source == bikMarker3) then triggerClientEvent(hitElement,"showbikmarker",hitElement) elseif (source == planeMarker1) or (source == planeMarker2) or (source == planeMarker3) then triggerClientEvent(hitElement,"showplanemarker",hitElement) elseif (source == boatMarker1) or (source == boatMarker2) or (source == boatMarker3) then triggerClientEvent(hitElement,"showboatmarker",hitElement) end end) function createsql () executeSQLQuery("CREATE TABLE IF NOT EXISTS carslot1 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS carslot2 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS bikslot1 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS bikslot2 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS planeslot1 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS planeslot2 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS boatslot1 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") executeSQLQuery("CREATE TABLE IF NOT EXISTS boatslot2 (PlayerName TEXT, Model NUMERIC, Cost NUMERIC, Paintjob NUMERIC, Color TEXT, Upgrade0 NUMERIC, Upgrade1 NUMERIC, Upgrade2 NUMERIC, Upgrade3 NUMERIC, Upgrade4 NUMERIC, Upgrade5 NUMERIC, Upgrade6 NUMERIC, Upgrade7 NUMERIC, Upgrade8 NUMERIC, Upgrade9 NUMERIC, Upgrade10 NUMERIC, Upgrade11 NUMERIC, Upgrade12 NUMERIC, Upgrade13 NUMERIC, Upgrade14 NUMERIC, Upgrade15 NUMERIC, Upgrade16 NUMERIC)") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createsql) addEvent("buycar1",true) addEventHandler("buycar1",getRootElement(), function(id,cost,name) if (getPlayerMoney(client)>= tonumber(cost)) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot1 WHERE PlayerName = ?",name) if #playercar > 0 then outputChatBox("No puedes comprar este coche mientras tengas el espacio libre.",client) else --[[local c1xml = xmlLoadFile("buyingc1.dat") if not c1xml then c1xml = xmlCreateFile("buyingc1.dat","wang") end local node = xmlCreateChild(c1xml,"buyc1") local msg = name.." tried to buy vehicle "..getVehicleNameFromModel(id) local success1 = xmlNodeSetValue(node,msg)]] local paintjob = 3 local color = "88,88,83,70,89,122" takePlayerMoney(client,tonumber(cost)) local addVehicle = executeSQLQuery("INSERT INTO carslot1 (PlayerName,Model,Cost,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", tostring(name), tonumber(id), tonumber(cost), tonumber(paintjob), tostring(color), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") if addVehicle then -- local msg2 = name.." succeeded in sale $"..cost --local node2 = xmlCreateChild(c1xml,"buyc1") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle bought successfully",client) else --local msg2 = name.." failed in sale $"..cost --local node2 = xmlCreateChild(c1xml,"buyc1") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle has not been bought",client) end --xmlSaveFile(c1xml) --xmlUnloadFile(c1xml) end else outputChatBox("No tienes suficiente dinero.",client) end end) addEvent("buycar2",true) addEventHandler("buycar2",getRootElement(), function(id,cost,name) if (getPlayerMoney(client)>= tonumber(cost)) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot2 WHERE PlayerName = ?",name) if #playercar > 0 then outputChatBox("No puedes comprar este coche mientras la ranura esté ocupada.",client) else --[[local c2xml = xmlLoadFile("buyingc2.dat") if not c2xml then c2xml = xmlCreateFile("buyingc2.dat","wang") end local node = xmlCreateChild(c2xml,"buyc2") local msg = name.." tried to buy vehicle "..getVehicleNameFromModel(id) local success1 = xmlNodeSetValue(node,msg)]] local paintjob = 3 local color = "88,88,83,70,89,122" takePlayerMoney(client,tonumber(cost)) local addVehicle = executeSQLQuery("INSERT INTO carslot2 (PlayerName,Model,Cost,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", tostring(name), tonumber(id), tonumber(cost), tonumber(paintjob), tostring(color), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") if addVehicle then --local msg2 = name.." succeeded in sale $"..cost --local node2 = xmlCreateChild(c2xml,"buyc2") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle bought successfully",client) else --local msg2 = name.." failed in sale $"..cost --local node2 = xmlCreateChild(c2xml,"buyc2") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle has not been bought",client) end --xmlSaveFile(c2xml) --xmlUnloadFile(c2xml) end else outputChatBox("You dont have enough money to buy this car",client) end end) addEvent("buybik1",true) addEventHandler("buybik1",getRootElement(), function(id,cost,name) if (getPlayerMoney(client)>= tonumber(cost)) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM bikslot1 WHERE PlayerName = ?",name) if #playercar > 0 then outputChatBox("You cant buy this car since you already have one in this slot",client) else --[[local b1xml = xmlLoadFile("buyingb1.dat") if not b1xml then b1xml = xmlCreateFile("buyingb1.dat","wang") end local node = xmlCreateChild(b1xml,"buyb1") local msg = name.." tried to buy vehicle "..getVehicleNameFromModel(id) local success1 = xmlNodeSetValue(node,msg)]] local paintjob = 3 local color = "88,88,83,70,89,122" takePlayerMoney(client,tonumber(cost)) local addVehicle = executeSQLQuery("INSERT INTO bikslot1 (PlayerName,Model,Cost,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", tostring(name), tonumber(id), tonumber(cost), tonumber(paintjob), tostring(color), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") if addVehicle then --local msg2 = name.." succeeded in sale $"..cost --local node2 = xmlCreateChild(b1xml,"buyb1") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle bought successfully",client) else --local msg2 = name.." failed in sale $"..cost --local node2 = xmlCreateChild(b1xml,"buyb1") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle has not been bought",client) end --xmlSaveFile(b1xml) --xmlUnloadFile(b1xml) end else outputChatBox("You dont have enough money to buy this car",client) end end) addEvent("buybik2",true) addEventHandler("buybik2",getRootElement(), function(id,cost,name) if (getPlayerMoney(client)>= tonumber(cost)) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM bikslot2 WHERE PlayerName = ?",name) if #playercar > 0 then outputChatBox("You cant buy this car since you already have one in this slot",client) else --[[local b2xml = xmlLoadFile("buyingb2.dat") if not b2xml then b2xml = xmlCreateFile("buyingb2.dat","wang") end local node = xmlCreateChild(b2xml,"buyb2") local msg = name.." tried to buy vehicle "..getVehicleNameFromModel(id) local success1 = xmlNodeSetValue(node,msg)]] local paintjob = 3 local color = "88,88,83,70,89,122" takePlayerMoney(client,tonumber(cost)) local addVehicle = executeSQLQuery("INSERT INTO bikslot2 (PlayerName,Model,Cost,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", tostring(name), tonumber(id), tonumber(cost), tonumber(paintjob), tostring(color), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") if addVehicle then --local msg2 = name.." succeeded in sale $"..cost --local node2 = xmlCreateChild(b2xml,"buyb2") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle bought successfully",client) else --local msg2 = name.." failed in sale $"..cost --local node2 = xmlCreateChild(b2xml,"buyb2") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle has not been bought",client) end --xmlSaveFile(b2xml) --xmlUnloadFile(b2xml) end else outputChatBox("You dont have enough money to buy this car",client) end end) addEvent("buyplane1",true) addEventHandler("buyplane1",getRootElement(), function(id,cost,name) if (getPlayerMoney(client)>= tonumber(cost)) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM planeslot1 WHERE PlayerName = ?",name) if #playercar > 0 then outputChatBox("You cant buy this car since you already have one in this slot",client) else --[[local p1xml = xmlLoadFile("buyingp1.dat") if not p1xml then p1xml = xmlCreateFile("buyingp1.dat","wang") end local node = xmlCreateChild(p1xml,"buyp1") local msg = name.." tried to buy vehicle "..getVehicleNameFromModel(id) local success1 = xmlNodeSetValue(node,msg)]] local paintjob = 3 local color = "88,88,83,70,89,122" takePlayerMoney(client,tonumber(cost)) local addVehicle = executeSQLQuery("INSERT INTO planeslot1 (PlayerName,Model,Cost,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", tostring(name), tonumber(id), tonumber(cost), tonumber(paintjob), tostring(color), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ") if addVehicle then --local msg2 = name.." succeeded in sale $"..cost --local node2 = xmlCreateChild(p1xml,"buyp1") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle bought successfully",client) else --local msg2 = name.." failed in sale $"..cost --local node2 = xmlCreateChild(p1xml,"buyp1") --local success2 = xmlNodeSetValue(node2,msg2) outputChatBox("Vehicle has not been bought",client) end --xmlSaveFile(p1xml) --xmlUnloadFile(p1xml) end else Link to comment
Dimos7 Posted April 24, 2015 Share Posted April 24, 2015 addEvent("spawncar1",true) addEventHandler("spawncar1",getRootElement(), function() if not (isGuestAccount(getPlayerAccount(client))) then if not (isPedInVehicle(client)) then local x,y,z = getElementPosition(client) if (getElementData(client,"mycar1")) and (getElementData(client,"mycar1")~= nil) --[[and (getElementType(getElementData(client,"mycar1")) =="vehicle")]] then local vehicle = getElementData(client,"mycar1") destroyElement(vehicle) removeElementData(client,"mycar1") --local x,y,z = getElementPosition(vehicle) --setElementPosition(vehicle,x,y,z) outputChatBox("Vehicle destroyed",client) --[[ local vehicle = getElementData(client,"mybik1") destroyElement(vehicle) removeElementData(client,"mybik1") outputChatBox("Vehicle destroyed",client)]] elseif not (getElementData(client,"mycar1")) then local account = getPlayerAccount(client) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot1 WHERE PlayerName = ?",name) if (playercar) then if #playercar > 0 then local x,y,z = getElementPosition(client) local vehicle = createVehicle(playercar[1].Model,x + 5,y +2,z) setVehiclePaintjob(vehicle,playercar[1].Paintjob) setElementData(vehicle,"vehicleOwner","mycar1") setElementData (vehicle,"mycar1",getPlayerName(source)) setElementData (client, "mycar1", vehicle) setElementData(vehicle,"VOwner",getPlayerName(client)) outputChatBox ("Car spawned.", source, 255, 0, 0) addVehicleUpgrade(vehicle, playercar[1].Upgrade0) addVehicleUpgrade(vehicle, playercar[1].Upgrade1) addVehicleUpgrade(vehicle, playercar[1].Upgrade2) addVehicleUpgrade(vehicle, playercar[1].Upgrade3) addVehicleUpgrade(vehicle, playercar[1].Upgrade4) addVehicleUpgrade(vehicle, playercar[1].Upgrade5) addVehicleUpgrade(vehicle, playercar[1].Upgrade6) addVehicleUpgrade(vehicle, playercar[1].Upgrade7) addVehicleUpgrade(vehicle, playercar[1].Upgrade8) addVehicleUpgrade(vehicle, playercar[1].Upgrade9) addVehicleUpgrade(vehicle, playercar[1].Upgrade10) addVehicleUpgrade(vehicle, playercar[1].Upgrade11) addVehicleUpgrade(vehicle, playercar[1].Upgrade12) addVehicleUpgrade(vehicle, playercar[1].Upgrade13) addVehicleUpgrade(vehicle, playercar[1].Upgrade14) addVehicleUpgrade(vehicle, playercar[1].Upgrade15) addVehicleUpgrade(vehicle, playercar[1].Upgrade16) local col1 = gettok (playercar[1].Color, 1, string.byte(',') ) local col2 = gettok (playercar[1].Color, 2, string.byte(',') ) local col3 = gettok (playercar[1].Color, 3, string.byte(',') ) local col4 = gettok (playercar[1].Color, 4, string.byte(',') ) local col5 = gettok (playercar[1].Color, 5, string.byte(',') ) local col6 = gettok (playercar[1].Color, 6, string.byte(',') ) getVehicleUpgradeOnSlot(vehicle, 0) getVehicleUpgradeOnSlot(vehicle, 1) getVehicleUpgradeOnSlot(vehicle, 2) getVehicleUpgradeOnSlot(vehicle, 3) getVehicleUpgradeOnSlot(vehicle, 4) getVehicleUpgradeOnSlot(vehicle, 5) getVehicleUpgradeOnSlot(vehicle, 6) getVehicleUpgradeOnSlot(vehicle, 7) getVehicleUpgradeOnSlot(vehicle, 8) getVehicleUpgradeOnSlot(vehicle, 10) getVehicleUpgradeOnSlot(vehicle, 11) getVehicleUpgradeOnSlot(vehicle, 12) getVehicleUpgradeOnSlot(vehicle,13) getVehicleUpgradeOnSlot(vehicle, 14) getVehicleUpgradeOnSlot(vehicle, 15) getVehicleUpgradeOnSlot(vehicle, 16) outputChatBox(col1) if col1 then setVehicleColor(vehicle, tonumber(col1), tonumber(col2), tonumber(col3), tonumber(col4), tonumber(col5), tonumber(col6)) end else outputChatBox("No has comprado un vehículo en esta ranura.",client) end end end else outputChatBox("Primero sal del coche",client) end else outputChatBox("¡Loguéate!",client) end end) 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