Jump to content
Sign in to follow this  
Rileyiri

Need some help with resupplying vehicles on a timer

Recommended Posts

Quick run down of what I need this for. I want to make a Helicopter or Jet Team Deathmatch to play with my friends, I don't want people to run out of ammo while flying and have to return to base to restock or refuel like I've seen in Domination gamemodes and such. I'd like everyone to stay airborne as long as possible so we can enjoy ourselves. I know it's not 'realistic' but it's what we'd prefer.

I don't want people to have unlimited ammo because they would just spam anti air missiles. I do however want them to restock and refuel the vehicles while they are using them, perhaps every minute or half a minute.

I'm relatively new to this and I've found a command while searching for this problem which was called: setVehicleAmmo.

So I was thinking can I use this command something along the lines of this:

Loop1;
// remove all vehicle ammo
setvehicleammo 0;
// add all vehicle ammo
setvehicleammo 1;
// wait 30 seconds
sleep 30;
goto Loop1

;

Now I don't know how I would write that out. And I do not know if I need to have a script in a separate file or if I can just put that into the vehicles init.

Some help here would be required, and I'll need any suggestions to be explained fully so I can learn something.

Share this post


Link to post
Share on other sites

I would put this in the vehicle's init:

0 = this spawn {
   while {true} do {
       sleep 30;
       _this setVehicleAmmo 1;
   };
};

This is tested and working in the editor. You do not need to set the ammo to 0 first. You cannot use the 'sleep' command in an object's init, so you must spawn a separate thread for the loop. If you want to learn sqf, these pages deal with those concepts:

http://community.bistudio.com/wiki/Control_Structures

http://community.bistudio.com/wiki/spawn

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×