JsK Posted July 20, 2019 Posted July 20, 2019 Hi guys , so i have made a external car spawning system for my server , but the only problem is that if i spawn the same cars (for example i spawn Infernus at X pos and spawn Another Infernus at Y spawn - different places) , when they boom , there will be 2 Infernus spawned on the SAME spot Here is the code about respawns of cars : function respawnDayZVehicle2(id,x,y,z,rx,ry,rz,veh,col,max_slots) local armorMax = getElementData(col,"armorPointsMax") destroyElement(veh) destroyElement(col) veh = createVehicle(id,x,y,z,rx,ry,rz) vehCol = createColSphere(x,y,z,4) attachElements ( vehCol, veh, 0, 0, 0 ) setElementData(vehCol,"parent",veh) setElementData(veh,"parent",vehCol) setElementData(vehCol,"vehicle",true) setElementData(vehCol,"MAX_Slots",max_slots) --Engine + Tires local tires,engine,parts,metal = getVehicleAddonInfos (getElementModel(veh)) setElementData(vehCol,"Tire_inVehicle",math.random(0,tires)) setElementData(vehCol,"Engine_inVehicle",math.random(0,engine)) setElementData(vehCol,"Parts_inVehicle",math.random(0,parts)) setElementData(vehCol,"Tire_inVehicle_HP",400) setElementData(vehCol,"Engine_inVehicle_HP",400) setElementData(vehCol,"Parts_inVehicle_HP",400) setElementData(vehCol,"armorPointsMax",armorMax) setElementData(vehCol,"armorPoints",0) setElementData(vehCol,"receiver",0) setElementData(vehCol,"vehicle:station",0) --vehicle_indentifikation setElementData(vehCol,"spawn",{id,x,y,z,rx,ry,rz}) --others setElementData(vehCol,"fuel",10) end and here is the code of the car spawn. function SpawnDayZVehicle2(id,typ) local x, y, z = getElementPosition(source) veh = createVehicle(id, x + 5, y, z) vehCol = createColSphere(x + 5, y, z, 2.5) attachElements(vehCol, veh, 0, 0, 0) setElementData(vehCol, "parent", veh) setElementData(veh, "parent", vehCol) setElementData(vehCol, "vehicle", true) setElementData(vehCol, "MAX_Slots", 0) -- количество слотов в тс local tires,engine,parts,metal = getVehicleAddonInfos(getElementModel(veh))---данные берём из vehicle_spawns setElementData(vehCol,"Tire_inVehicle",tires) setElementData(vehCol,"Engine_inVehicle",engine) setElementData(vehCol,"Parts_inVehicle",parts) setElementData(vehCol,"armorPoints",list) setElementData(vehCol,"Tire_inVehicle_HP",400) setElementData(vehCol,"Engine_inVehicle_HP",400) setElementData(vehCol,"Parts_inVehicle_HP",400) setElementData(vehCol,"armorPoints",15500) setElementData(vehCol,"receiver",0) setElementData(vehCol,"spawn",{id,x,y,z,rx,ry,rz}) if typ == "con" then --лут который будет спаунится в конвойном тс setElementData(vehCol,"GPS",1) setElementData(vehCol,"Toolbox",1) setElementData(vehCol,"Map",1) end setElementData(vehCol, "fuel", 20) setVehicleHeadLightColor(veh,math.random(0,255),math.random(0,255),math.random(0,255)) end addEvent("spawnVehAdmin",true) addEventHandler("spawnVehAdmin",getRootElement(),SpawnDayZVehicle2) The data "spawn" is the file of spawn of cars. Please HELP :v
HassoN Posted July 26, 2019 Posted July 26, 2019 This issue occurs because both vehicles use a shared variable "veh" in your case. Use a table instead. Something like vehicles[player] = createVehicle... So each vehicle has its own variable. * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
JsK Posted July 26, 2019 Author Posted July 26, 2019 On 20/07/2019 at 20:17, Jisko27ns said: But this is the same for every cars , i have about 34 cars and its all the same things , so what exactly i have to do in details ? if you can explain better
HassoN Posted July 26, 2019 Posted July 26, 2019 Show us the code when the vehicle explodes and you respawn it. * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
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