Jump to content
Sign in to follow this  

Recommended Posts

Gday all,

just wondering if any 1 knows how i can reset ammo count on a static weapon every 5 mins

i.e

i have a m119 artillry gun at base and wish to have the ammo reset to full amount every 5 mins so a player can use it then run out of ammo but in 5 mins time it will have ammo again.

any help will be great

cheers

=Mason=

Share this post


Link to post
Share on other sites

nul = [this] execVM "reload.sqf";

_gun = _this select 0;

while {alive _gun} do {
_mags = _gun magazinesTurret [0];
_mag = _mags select 0;
//for M119 it's "30Rnd_105mmHE_M119"
_gun removeMagazinesTurret [_mag,[0]];
_gun addMagazineTurret [_mag,[0]];
player sidechat format ["M119 reloaded :%1",_mag];
sleep 300;
};

Edited by PELHAM

Share this post


Link to post
Share on other sites

Thank you PELHAM again you have been a god send ;) 1 question ill tak it the sleep 300 is the time before the script runs next to reload the m119

Share this post


Link to post
Share on other sites
Thank you PELHAM again you have been a god send ;) 1 question ill tak it the sleep 300 is the time before the script runs next to reload the m119

Yep 60 x 5 = 300 seconds

Changed it a bit so it will give weapon type on reload. It should work on other static things like mortars, TOWs, M2s and Mk19s:

nul = [this] execVM "reload.sqf";

_gun = _this select 0;
while {alive _gun} do {
_mags = _gun magazinesTurret [0];
_mag = _mags select 0;
_gun removeMagazinesTurret [_mag,[0]];
_gun addMagazineTurret [_mag,[0]];
player sidechat format ["%1 reloaded :%2",typeOf _gun,_mag];
sleep 300;
};

Edited by PELHAM

Share this post


Link to post
Share on other sites

awsome thanks mate really appreciated trying this now on a morter

---------- Post added at 19:50 ---------- Previous post was at 19:20 ----------

Works perfect thank you ;)

---------- Post added at 19:59 ---------- Previous post was at 19:50 ----------

Pelham just while ive got you here would you now the solution to this mate.

i have this script to place a marker on the map with players name it works fine but when a player leaves the server its marker stays in the last poition of the player on the map so after a while we have heaps of markers on the map

script

marker.sqf

waituntil {(alive player)};

_unit = player;
_nameP = name _unit;

_markerobjp = createMarker [_namep,[0,0]];
_markerobjp setMarkerShape "ICON";
_markerobjp setMarkerType "mil_dot";
_markerobjp setMarkerColor "ColorGreen";
_markerobjp setMarkerText _nameP;
_markerobjp setMarkerSize [1,1];


while {alive _unit} do {
_markerobjp setmarkerdir (getdir _unit);
_markerobjp setMarkerPos (getPos _unit);
_markerobjp setMarkerText _nameP;
sleep 1;
};

deleteMarker _markerobjp;
[] execVM "HOG scripts\marker.sqf";
exit;

called by

[] execVM "HOG scripts\marker.sqf";

in the main init.sqf

would you know how to make it delete the players marker when they disconect.

cheers,

Share this post


Link to post
Share on other sites

Alas it is very difficult to get them to delete - if you look at norins revive - it leaves markers of players that disconnected, and so too does a few other scripts. Once the player disconnects, the marker appears not to exist. Even if you had a script to delete marker "hogmason" after you have left - doesn't seem to delete that marker. Same for changing - while {alive _unit} do - to - while {!isnull_unit} do - doesn't deletemarker. Ive used the players UID as a means to creating the marker - and tried deleting that - again no joy. In the end ive just left it and when you leave and disconnect it goes. best i can offer sorry.

So if you find a solution please update! :)

hope this helps and saves you some time.

Share this post


Link to post
Share on other sites

would you know how to make it delete the players marker when they disconect.

cheers,

What Mikie says is correct, one way to get around it is not to create and delete markers at all. Have the same number of markers as playableUnits and use setMarkerAlphaLocal / setMarkerAlpha and setMarkerText to make them visible / invisible & change the text to player name forEach playableUnits. Some of the MP games use that - have a look through and you will find examples.

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  

×