Jump to content

MTA DayZ Code [HELP]


Recommended Posts

Hello! This is officially my first topic since I am new to MTA. The MTA DayZ currently being worked on by woovie and ffs sniper brought me to MTA from the "competitor" (I shall not mention the name as now it is dead to me)

Anyways. I purchased the script and am looking it over and am using it to learn Lua as I have never used it before. It is beginning to get a little easier to understand and have managed to add some vehicles that such as police cars and Ambulances that spawn with some loot like weapons/ammo in the police cars and medical supplies in the ambulances and random car parts towards getting the vehicle to running like Engine/Tires/Tank Parts.

One problem. The fuel works. It does spawn with 10 fuel like other vehicles already added to the server. However, upon entering the vehicles i added, the line at the top of your screen that shows "Fuel" does not appear and when the vehicle DOES run out of fuel, adding a Full Fuel Can does not work. It will not go in and there are no errors in the server log.

I'm asking if someone who is familiar with this code has had this problem and knows how to fix it or knows what I did wrong? I've searched every file and cannot seem to find what would cause this.

Any help would be appreciated and I hope I am not breaking rules. This seemed to be the logical place to post.

Link to comment
  
for i,veh in ipairs(lspdSpawns) do 
        local x,y,z = veh[1],veh[2],veh[3] 
        veh = createVehicle(596,x,y,z) 
        vehCol = createColSphere(x,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",38) 
        --Engine + Tires 
        local tires,engine,parts = 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)) 
        --vehicle_indentifikation 
        setElementData(vehCol,"spawn",{596,x,y,z}) 
        --others 
        setElementData(vehCol,"fuel",10) 
        for i,items in ipairs(lootItems["helicrashsides"]) do 
            local randomNumber = math.random(1,10) 
            if randomNumber == 5 then 
                setElementData(vehCol,items[1],1) 
            end 
        end 
    end 
  

That's just one of the codes I added. it spawns fine. Random car parts and loot. It matches the others just fine.

It runs out of gas, but the Fuel label does not show at the top and you cannot add full fuel cans to it.

Link to comment
Wanted to see the how you were showing the fuel on screen actually.

I deleted his post, on the count of it being closed source from the DayZ script. The fuel is rendered from data stored on the element, then uses dxDrawText. Nothing too crazy.

Link to comment
  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...