Messiah 2 Posted January 23, 2005 ok - im trying to make a script that makes bullets in an ammo belt dissapear as the weapon is fired... now my scripting is novice at best, so please excuse my attempt... basically there are 33 rounds of this belt on show, and 17 'remaining' in the ammo box. So i've tried to set the script up to count to 17, and then on the 18th to start hiding the rounds, bullet by bullet. what happens at the moment though is that the reload part of the script (very end) is firing way too early, and none of the rounds dissapear at all - so im assuming something is going wrong - very wrong. I can guess there's a simpler way of writing what i have (most likely by adding 1 each time to the selection and to the whatnumber to look for) but i dont know how - oh, and my variable i've used _UKFHMGCount - will that actually work with more than one of these weapons placed? like i said, scripting isn't my forte... UKF_HMGCount == 0 is added to the eventhandler init <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehicle = _this select 0 _UKFHMGCount == _UKFHMGCount + 1 ?(_UKFHMGCount < 17) : exit ?(_UKFHMGCount == 18) : _vehicle setobjecttexture [11,""] : exit ?(_UKFHMGCount == 19) : _vehicle setobjecttexture [12,""] : exit ?(_UKFHMGCount == 20) : _vehicle setobjecttexture [13,""] : exit ?(_UKFHMGCount == 21) : _vehicle setobjecttexture [14,""] : exit ?(_UKFHMGCount == 22) : _vehicle setobjecttexture [15,""] : exit ?(_UKFHMGCount == 23) : _vehicle setobjecttexture [16,""] : exit ?(_UKFHMGCount == 24) : _vehicle setobjecttexture [17,""] : exit ?(_UKFHMGCount == 25) : _vehicle setobjecttexture [18,""] : exit ?(_UKFHMGCount == 26) : _vehicle setobjecttexture [19,""] : exit ?(_UKFHMGCount == 27) : _vehicle setobjecttexture [20,""] : exit ?(_UKFHMGCount == 28) : _vehicle setobjecttexture [21,""] : exit ?(_UKFHMGCount == 29) : _vehicle setobjecttexture [22,""] : exit ?(_UKFHMGCount == 30) : _vehicle setobjecttexture [23,""] : exit ?(_UKFHMGCount == 31) : _vehicle setobjecttexture [24,""] : exit ?(_UKFHMGCount == 32) : _vehicle setobjecttexture [25,""] : exit ?(_UKFHMGCount == 33) : _vehicle setobjecttexture [26,""] : exit ?(_UKFHMGCount == 34) : _vehicle setobjecttexture [27,""] : exit ?(_UKFHMGCount == 35) : _vehicle setobjecttexture [28,""] : exit ?(_UKFHMGCount == 36) : _vehicle setobjecttexture [29,""] : exit ?(_UKFHMGCount == 37) : _vehicle setobjecttexture [30,""] : exit ?(_UKFHMGCount == 38) : _vehicle setobjecttexture [31,""] : exit ?(_UKFHMGCount == 39) : _vehicle setobjecttexture [32,""] : exit ?(_UKFHMGCount == 40) : _vehicle setobjecttexture [33,""] : exit ?(_UKFHMGCount == 41) : _vehicle setobjecttexture [34,""] : exit ?(_UKFHMGCount == 42) : _vehicle setobjecttexture [35,""] : exit ?(_UKFHMGCount == 43) : _vehicle setobjecttexture [36,""] : exit ?(_UKFHMGCount == 44) : _vehicle setobjecttexture [37,""] : exit ?(_UKFHMGCount == 45) : _vehicle setobjecttexture [38,""] : exit ?(_UKFHMGCount == 46) : _vehicle setobjecttexture [39,""] : exit ?(_UKFHMGCount == 47) : _vehicle setobjecttexture [40,""] : exit ?(_UKFHMGCount == 48) : _vehicle setobjecttexture [41,""] : exit ?(_UKFHMGCount == 49) : _vehicle setobjecttexture [42,""] : exit ?(_UKFHMGCount == 50) : _vehicle setobjecttexture [43,""] ~3 _vehicle animate ["ani_flap", 1] @(_vehicle animationPhase "ani_flap" ) == 1 ~0.5 _vehicle animate ["ani_flap", 0] @(_vehicle animationPhase "ani_flap" ) == 0 _vehicle animate ["ani_flap", 1] @(_vehicle animationPhase "ani_flap" ) == 1 _vehicle setobjecttexture [11,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [12,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [13,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [14,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [15,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [16,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [17,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [18,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [19,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [20,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [21,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [22,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [23,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [24,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [25,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [26,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [27,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [28,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [29,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [30,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [31,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [32,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [33,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [34,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [35,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [36,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [37,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [38,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [39,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [40,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [41,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [42,"\UKF_HMG\50cal.paa"] _vehicle setobjecttexture [43,"\UKF_HMG\50cal.paa"] _vehicle animate ["ani_flap", 0] @(_vehicle animationPhase "ani_flap" ) == 0 ~0.5 _vehicle animate ["ani_cock1", 1] @(_vehicle animationPhase "ani_cock1" ) == 1 _vehicle setobjecttexture [7,""] _vehicle setobjecttexture [8,""] _vehicle setobjecttexture [9,"\UKF_HMG\handle.pac"] _vehicle setobjecttexture [10,"\UKF_HMG\strut.pac"] _vehicle animate ["ani_cock2", 1] @(_vehicle animationPhase "ani_cock2" ) == 1 _vehicle animate ["ani_cock2", 0] @(_vehicle animationPhase "ani_cock2" ) == 0 _vehicle setobjecttexture [9,""] _vehicle setobjecttexture [10,""] _vehicle setobjecttexture [7,"\UKF_HMG\handle.pac"] _vehicle setobjecttexture [8,"\UKF_HMG\strut.pac"] _vehicle animate ["ani_cock1", 0] @(_vehicle animationPhase "ani_cock1" ) == 0 exit cheers for any help Share this post Link to post Share on other sites
Unnamed_ 0 Posted January 24, 2005 Your script should use the global variable UKF_HMGCount not the local variable _UKFHMGCount. Quote[/b] ]will that actually work with more than one of these weapons placed If you drop the underscore and make them all global, then you cant have more than one in a mission. To do that you would have to use global arrays or dynamic global variables (like COC) or store the shot counter as part of the units rating. Assuming there is no OFP script command to get the number of rounds. There are no easy solutions, but I can point you to posts that cover all of the above. Share this post Link to post Share on other sites
Messiah 2 Posted January 24, 2005 ok... so i can check if my scripting is up to anything and get it working for one on its own... if u could point me to posts, that would be super Share this post Link to post Share on other sites
Footmunch 0 Posted January 24, 2005 You don't need the Count variables at all. In the config, use something like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="[_this] exec {\UKF_HMG\scr\fired.sqs}"; Then in fired.sqs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Init our local vars _array = _this select 0 _weapon = _array select 1 _unit = _array select 0 ; Count how much ammo we've got left _count = _unit ammo _weapon The variable _count will have the rounds _left_. Subtract this from 50 to get the rounds fired. Share this post Link to post Share on other sites
Messiah 2 Posted January 24, 2005 ok... so by replacin stuff to make it use the right weapon and ammo, i can get this to work... how would i go about checking the actually count? ?(_count == 50?) ? then i can do one for each round as it fires, and so hide it... [edit] just thought of another thing... if the player rearms from somewhere it would screw things up? Unless the script could check the ammo is -50 fromlast time or something.... aaaargh Share this post Link to post Share on other sites
Footmunch 0 Posted January 24, 2005 The _count is the number of rounds in the gun. What bits to draw in and out are up to you, based on the count. You can use variables in setobjecttexture, so you could do something like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit setobjecttexture[_count - 7, ""] If the player re-arms, the fired EH won't 'fire' until the first round of the new 'drum' is fired. You can get round this by having a 'monitor' script started by the init EH: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = this select 0 _newcount = _unit ammo "GunNameHere" #SlowLoop ?(!alive _unit) : exit _count = _newcount ~3 _newcount = _unit ammo "GunNameHere" ?(_newcount > _count) : goto "ReArmed" goto "SlowLoop" #ReArmed ;Stuff here goto "SlowLoop" So, every 3 seconds, the script checks to see if the ammo has increased - you don't need to worry about numbers, as the _only_ way for ammo to increase is if you re-arm. If it has, then you go to the ReArmed section and do your stuff. Share this post Link to post Share on other sites