Jump to content
  • 0

Limited Fuel


Incar

Question

Just curious if anyone has ever come across a script for a limited fuel feature. I'm talking like fuel tanks or gas stations around the map only have so many liters each, making it where you may occasionally come across empty fueling points. This whole unlimited fuel thing just bugs me, so before I get to trying to figure out how to do it myself, seeing if I can find an easy route to this goal, lol.

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

you could set a variable within the object with current time and check if enough time has passed, before allowing refueling again by that object

 

I came across an idea similar to that, basically adding a variable that would create a random up to 6, so each tank would be capable of being siphoned 0-6 times, and would reset after a server restart. It confused me a bit though and I dropped the idea because he said.

 

So what is it doing: The idea is to just assign a "Variable" using setVariable with a random number of available jerry cans to fill. Since you can only use setVariable on vehicles, I create a vehicle - which in this case is just a Land_Fire_Barrel (I spawn it the same as a Fire pit, but under ground.)

 

The whole "can only use setVariable on vehicles" part confused me, and didn't understand how a fire barrel could count as one then. I gave it a shot anyway but failed miserably trying to get it to function.

 

Link below if you're interested in seeing it.

http://opendayz.net/threads/request-toolbelt-items-having-charges-fuel-tanks-have-limited-fuel.8849/page-2

 

Edit: I'm assuming the script example he gives within is something that would need to be done to the jerry_fill.sqf correct?

Edit 2: Yah, pretty sure it should be done in jerry_fill.sqf, not how I did before so likely the cause of my issues. This looks like it was made for vanilla dayz though, so I'll be using it as a reference to figure out how to do this. Won't ask any more questions for now.

Link to comment
Share on other sites

  • 0

The problem is that map fuel tanks are not persistent db objects but are map objects. These objects have no fields / variables in which to store things like full capacity AFAIK.

I am working on a better refuelling script (see my sig for the link) and was looking around the same thing as you are wanting maybe with a refuelling convoy refilling the fuel tanks in a cycle or at request after paying.

Link to comment
Share on other sites

  • 0

The problem is that map fuel tanks are not persistent db objects but are map objects. These objects have no fields / variables in which to store things like full capacity AFAIK.

I am working on a better refuelling script (see my sig for the link) and was looking around the same thing as you are wanting maybe with a refuelling convoy refilling the fuel tanks in a cycle or at request after paying.

I got the script I was looking at in post from link working. Will experiment with it further in a few days once I got other stuff out of the way. Might end up removing all fuel tanks off the map and inserting them through the DB so I can attach the script directly to them as appose to a different object, but I need to learn this map editing first ><

Link to comment
Share on other sites

  • 0

I got the script I was looking at in post from link working. Will experiment with it further in a few days once I got other stuff out of the way. Might end up removing all fuel tanks off the map and inserting them through the DB so I can attach the script directly to them as appose to a different object, but I need to learn this map editing first ><

 

That would probably be the best way to go to do it properly but will involve a lot of work finding all the fuel tanks, removing them and putting persistant DB objects in their place.  You could then track fuel amount as you would any other vehicle but would have to set a starting capacity (usually set in the vehicle class files).  If these were in place then the fuel tanks could be used just like fuel trucks (non-movable of course).

 

Would love to add the amended map to my Better Refuelling mod if you ever get round to doing it and are willing to share (with full credits to you of course).

Link to comment
Share on other sites

  • 0

a variable set within an object does not require the object to be in the database ... what would you do in regular arma, where no database is used?

_fuel = (random 200)+50;
_obj setVariable ["fuelleft",_fuel,true];

this would set a variable within the object with a capacity, then you could just remove the amount that was taken when a player refueld there then deduct that from current number and if number goes below zero, you denie any more refuleing.

this could be done globally to any fuelstation on the map.

 

what you are talking about will be more work than what it is worth in the end ... imho this would be best best way to do it.

alternatively you could just disable the fuelstation completly for the rest of that restart, when and if someone has refueled once at that refueling point

Link to comment
Share on other sites

  • 0

Interesting for non-persistent objects.

 

How would you suggest setting the starting fuel levels for all map based fuel containers ?.  Is there an easy way to do it ?.

 

If the fuel levels are not persistent, is there any point setting fuel levels on restart for all map based fuel containers if the server is restarted every 4 hours or less ?.

 

To my mind the only point in setting and tracking map based fuel containers is if they have a chance of getting fully emptied and need manual refilling (i.e. a fuel convoy) which then brings in other mission possibilities.

 

I don't program for the original ARMA.  I program for ARMA II so do not need to worry about not having a persistent database backend and have to try and fake persistence or program without it.

Link to comment
Share on other sites

  • 0

https://community.bistudio.com/wiki/nearestObjects

 

again this is way more work than what it is worth, but you could make some custom hive calls and and then save all these objects fuel capacity aswell (alltho it most likely will slow down your server boot speed considerably), but imho its not worth the efford (for this game anyways, you should really move to a newer engine and do this).

 

when i say arma, i dont mean arma 1, i mean arma as in whole unit of most bi games combined ... the code is rarely very diffrent and unless specified for a custom mod or utilizing new commands/functions, is in most cases both forward and backward compatible.

Link to comment
Share on other sites

  • 0

https://community.bistudio.com/wiki/nearestObjects

 

again this is way more work than what it is worth, but you could make some custom hive calls and and then save all these objects fuel capacity aswell (alltho it most likely will slow down your server boot speed considerably), but imho its not worth the efford (for this game anyways, you should really move to a newer engine and do this).

 

when i say arma, i dont mean arma 1, i mean arma as in whole unit of most bi games combined ... the code is rarely very diffrent and unless specified for a custom mod or utilizing new commands/functions, is in most cases both forward and backward compatible.

 

Ok, so you need to search the entire map for all the classes of fuel tank on server boot and set the fuel variable.

 

Sure you have said you do not believe it is not, in your opinion, worth the effort although I do not really agree with it especially, as you clearly note, the commands used tend to be transferable between engines in the ARMA series so the hope would be that it could be modified quite easily and therefore easily usable in Epoch for ARMA 3.

 

Not sure that writing custom hive calls would be easier than turning map fuel tanks to Epoch objects.

 

Anyway...

 

So there are a couple of options available.

Reference the map objects as non-persistent objects and set fuel capacity which is fine but would reset on server reboot.

Convert the map fuel storage tanks to actual persistent DB objects where Epoch will track the fuel using existing methods.

Link to comment
Share on other sites

  • 0

It is possible to get the object id I believe, every time a station / fuel tank is used add it's id to a public variable array. Then count the number of times it appears in the pubvar next time it's used?

 

This would then populate the array with used fuel tanks and leave unused ones as they are which may be more efficent than setting everyone of them with the findnearest on server start.

 

This would not get around the lack of persistance across server restarts but would, along with the original suggestion from Halvhjearne for being able to set vars on non-persistant objects, provide a workable compromise. 

 

Personally it still fills like a bit of a kludge due to lack of persistance  :) .

 

Another alternative would be to use a holder object as storage in the DB where you could dump the array of current fuel capacities on server restart.  An object that would not have an inventory could have its inventory field used for alternative purposes like this.  Put it somewhere out of the way on the map and make sure it is not out of place and it should be fine.  make it invisible for extra security.  You then have persistant fuel supplies for all on map fuel tanks with no map editing, a small code change and one extra object.

 

I will probably go this way with my own refueling mod although I probably would not have thought of it for map defined objects without this thread and bo your and Halvhjearnes input.

 

Thanks guys.

Link to comment
Share on other sites

  • 0

It is possible to get the object id I believe, every time a station / fuel tank is used add it's id to a public variable array. Then count the number of times it appears in the pubvar next time it's used?

 

your theory could be right, but personally i think all object real ids are generated randomly each restart, i could be wrong tho.

 

however i think doing a nearobjects search might actually fetch the objects in nearly the same order each time you do the search, required that the search was for exact same classnames/baseclasses, searching the exact same position and that the map did not change with added/removed fuelstatins inbetween the searches.

(thats how nearroads work anyway, i could imagine it was the same, again i could be wrong on that)

 

@RimBlock

either way, i dont feel its worth it adding custom hive calls to control players fuel consumption when you can just set a low random amount to each station on restart.

if you want limited fuel for the players, you could just let it set most stations to a very low amount or 0 fuel and only a few stations full of fuel.

 

i can understand you want it to be persistant and i do admit it could be cool, but i dont think its worth the efford as most of this will change for arma 3, you could possibly use arma2net or inidb to avoid having to change much of your code, but but imho thats a poor sollution to this not to mention you will need to load even more mods into the server to utilize that.

Link to comment
Share on other sites

  • 0

I myself will avoid persistent, in the end eventually tanks will need to be refueled, nobody is going to play on a server once it's completely out of fuel. Plus even if you do have everything refuel regularly enough, depending on time zones, some people might get utterly screwed in comparison to others. Personally I like it working on every restart with very limited fuel set at random levels. With 6 hour restarts, it's quite possible a few players will end up stranded once a server has a decent amount of activity.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...