DanAK47 1 Posted May 3, 2004 I'm trying to make a script to detect when a weapon or magazine has been dropped and replace it with another type of weapon/magazine. In other words, the player drops weapon A, it magically replaces it with weapon B. I can get the script to detect when something is dropped using nearestObject [_soldier,"WeaponHolder"] and assign a name to it but I can't get it to detect what type of weapon or magazine is in cargo.. There seems to be no command to do this, I'm hoping I'm wrong. Anyone have anything that could help? Share this post Link to post Share on other sites
MrZig 0 Posted May 3, 2004 Maybe typeof would work with the var? like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> hint format ["%1",typeof _name] But I don't know.. Share this post Link to post Share on other sites
DanAK47 1 Posted May 3, 2004 Trigger wouldn't work, it has to be in a script. Hopefully there is a way to return what types of magazines are in an object's cargo. Share this post Link to post Share on other sites
MrZig 0 Posted May 3, 2004 I didn't say it was in a trigger. Put that in your script, to see if it works. Share this post Link to post Share on other sites
DanAK47 1 Posted May 4, 2004 Sorry. Dunno where I got "trigger" from. typeOf seems to return the class name of the ammo box. What I need is like an event handler, so I think I am screwwed. Share this post Link to post Share on other sites
noundo 0 Posted May 4, 2004 weapons vehicle Operand types:   vehicle: Object Type of returned value:   Array Compatibility:   Version 1.75 required. Description:   Returns array of names of all vehicle's weapons.. Example:   weapons player ========================================== secondaryWeapon vehicle Operand types:   vehicle: Object Type of returned value:   String Compatibility:   Version 1.75 required. Description:   Returns name of vehicle's secondary weapon (empty string if none). Example:   secondaryWeapon player ========================================== magazines vehicle Operand types:   vehicle: Object Type of returned value:   Array Compatibility:   Version 1.75 required. Description:   Returns array of types names of all vehicle's magazines. Example:   magazines player ======================================== unit hasWeapon weaponName Operand types:   unit: Object   weaponName: String Type of returned value:   Boolean Description:   Check if unit has given weapon. Example:   player hasWeapon "M16" Share this post Link to post Share on other sites
DanAK47 1 Posted May 4, 2004 That does not return the weapons in cargo, only the weapons the vehicle has/can use.. Share this post Link to post Share on other sites
General Barron 0 Posted May 13, 2004 Try using the nearestObject [x,y,z] command, which will return the nearest object of ANY type closest to the passed position. Make one trigger to record the player's position. (on activation: POSITION = getpos player) Make another trigger that does the nearestObject command at that position. In the on activation of that trigger, put: hint format["TypeOf= %1", nearestObject POSITION] Run the mission, radio the first trigger, then drop a magazine. Now move about 10 meters away, and hit the second trigger. If it IS possible to detect magazines, this should return the classname of the magazine/object you just dropped. If it ISN"T possible, this should return the player, assuming it was done on desert island so there are no other objects nearby. --------------------------------- WAIT! On second reading of your post, I see you can already get the magazine with the nearestobject command. So I guess my method above will always return "weaponholder". Never mind :P. I don't think there is any way to detect what weapons/ammo are in cargo, so I'm afraid this likely won't work the way you're doing it. Try my method above anyway, and maybe it will return something different for each magazine dropped... Another way to go about this might be to make a continuous loop that always checks what magazines/weapons the player has. When that array changes, you know that either (a) the player reloaded, (b) he dropped a magazine, or © he swapped his magazine with one from a dead body. I'm not sure how to deal with ©, because bodies can have more than one magazine, but dealing with (b) should be easy enough; just check to see if there is a new "weaponholder" close to the player. If so, you know he dropped somehting; and you know what he dropped because you know what changed in his magazines, since you are constantly checking it. Let me know if that works! Share this post Link to post Share on other sites