gabrielmass Posted May 11, 2016 Share Posted May 11, 2016 Olá galera, meu problema é o seguinte, estou criando um servidor de dayz mta, e para o spawn de veiculo para os vip's, estou usando a addon_VSC, porem quando vc spawna um veiculo, e dps spawna outro igual, ela nao destroi o antigo OBS: A RESOUCER VSC NORMAL ESTOU USANDO SO PRA ADM, PARA OS VIP EU CRIEI UMA OUTRA RESOUCER, ADICIONEI A RESOUCER PARA O GRUPO DO VIP NA ACL, E ESTOU USANDO A .LUA DE SPAWN DO VEICULO Q EU QUERONO CASO A SANCHEZ SEI QUE E POSSIVEL PELO MENOS COLOCAR UM LIMITE DE QUANTOS VEICULOS PODE SPAWNAR, POIS JOGO EM UM SERVIDOR DE DAYZ E ELES USAM A VSC PARA VEICULO DE CLA, OU SEJA O CLA COMPRA VIP DE VEICULO POREM TEM UM LIMITE DE SÓ SPAWNAR 5 VEICULOS NO MAXIMO, OU SEJA SE 5 MEMBROS JA TIVEREM SPAWNADO O VEICULO, NGM MAIS CONSEGUE SPAWNAR, SÓ SE ALGUEM MORRER OU RECONECTAR / SAIR ESTOU USANDO ASSIM O SCRIPT function SpawnDayZSanchez(thePlayer) local x, y, z = getElementPosition(thePlayer) veh = createVehicle(468, x + 5, y, z) vehCol = createColSphere(x + 5, 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", 6) local tires, engine, parts = getVehicleAddonInfos(getElementModel(veh)) setElementData(vehCol, "Tire_inVehicle", 2) setElementData(vehCol, "Engine_inVehicle", 1) setElementData(vehCol, "Parts_inVehicle", 1) setElementData(vehCol, "spawn", { 468, x, y, z }) setElementData(vehCol, "fuel", 30) end addCommandHandler("sanchez", SpawnDayZSanchez) vehicleAddonsInfo = { { 468, 2, 1, 1 } } function getVehicleAddonInfos(id) for i, veh in ipairs(vehicleAddonsInfo) do if veh[1] == id then return veh[2], veh[3], veh[4] end end end vehicleFuelInfo = { {468, 0.1} } function getVehicleAddonInfos(id) for i, veh in ipairs(vehicleAddonsInfo) do if veh[1] == id then return veh[2], veh[3], veh[4] end end end vehicleFuelTable = { {468, 80} } function getVehicleMaxFuel(loot) local modelID = getElementModel(getElementData(loot, "parent")) for i, vehicle in ipairs(vehicleFuelTable) do if modelID == vehicle[1] then return vehicle[2] end end return false end function onPlayerEnterDayzVehicle(veh, seat) local col = getElementData(dayZVeh, "parent") local id = getElementModel(dayZVeh) if not seat == 1 then return end local tires, engine, parts = getVehicleAddonInfos(id) setVehicleEngineState(dayZVeh, false) setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) setElementData(dayZVeh, "needtires", tires) setElementData(dayZVeh, "needengines", engine) setElementData(dayZVeh, "needparts", parts) if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then setVehicleEngineState(dayZVeh, false) return end if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then setVehicleEngineState(dayZVeh, false) return end if not getElementData(col, "Parts_inVehicle") then setElementData(col, "Parts_inVehicle", math.random(0, parts)) end if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) setVehicleEngineState(dayZVehBob, false) return end end SE ALGUEM SOUBER UMA OUTRA FORMA EM QUE EU POSSA COLCOAR SPAWN DE VEICULO PARA VIP POR COMANDO EM QUE TENHA LIMITE DE VEICULOS SPAWNADOS OU QUE DESTRUA O VEICULO ANTERIOR PF ME FALEM PRECISO MT DISSO Link to comment
gabrielmass Posted May 13, 2016 Author Share Posted May 13, 2016 destroyElement poderia aplicar o destroyElement pra mim nesse script? eu ja tentei usar ele mas msm assim nao funciona, pode me mandar esse msm script que esta ai soq com o destroyElement adicionado? Link to comment
MrDante Posted June 1, 2016 Share Posted June 1, 2016 Tente isso function SpawnDayZSanchez(thePlayer) if veh and isElement(veh) then -- Se o veiculo existir, em seguida destroyElement(veh) -- vai destruir o elemento veiculo end local x, y, z = getElementPosition(thePlayer) veh = createVehicle(468, x + 5, y, z) vehCol = createColSphere(x + 5, 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", 6) local tires, engine, parts = getVehicleAddonInfos(getElementModel(veh)) setElementData(vehCol, "Tire_inVehicle", 2) setElementData(vehCol, "Engine_inVehicle", 1) setElementData(vehCol, "Parts_inVehicle", 1) setElementData(vehCol, "spawn", { 468, x, y, z }) setElementData(vehCol, "fuel", 30) end addCommandHandler("sanchez", SpawnDayZSanchez) vehicleAddonsInfo = { { 468, 2, 1, 1 } } function getVehicleAddonInfos(id) for i, veh in ipairs(vehicleAddonsInfo) do if veh[1] == id then return veh[2], veh[3], veh[4] end end end vehicleFuelInfo = { {468, 0.1} } function getVehicleAddonInfos(id) for i, veh in ipairs(vehicleAddonsInfo) do if veh[1] == id then return veh[2], veh[3], veh[4] end end end vehicleFuelTable = { {468, 80} } function getVehicleMaxFuel(loot) local modelID = getElementModel(getElementData(loot, "parent")) for i, vehicle in ipairs(vehicleFuelTable) do if modelID == vehicle[1] then return vehicle[2] end end return false end function onPlayerEnterDayzVehicle(veh, seat) local col = getElementData(dayZVeh, "parent") local id = getElementModel(dayZVeh) if not seat == 1 then return end local tires, engine, parts = getVehicleAddonInfos(id) setVehicleEngineState(dayZVeh, false) setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) setElementData(dayZVeh, "needtires", tires) setElementData(dayZVeh, "needengines", engine) setElementData(dayZVeh, "needparts", parts) if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then setVehicleEngineState(dayZVeh, false) return end if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then setVehicleEngineState(dayZVeh, false) return end if not getElementData(col, "Parts_inVehicle") then setElementData(col, "Parts_inVehicle", math.random(0, parts)) end if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) setVehicleEngineState(dayZVehBob, false) return 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