NeMeSiS 11 Posted July 19, 2006 Ok i have the following script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">weaponH1 = "weaponholder" createVehicle getMarkerPos "WH" weaponH1 addMagazineCargo ["kozliceshell", 4] weaponH1 addWeaponCargo ["kozlice", 1] weaponH1 setPos getMarkerPos "WH" weaponH1 setDir 70 Which works fine if i put it in the init.sqs, but from a logic/trigger it doesnt work. It spawns the weapon, but you cant pick it up I tried a number of different scripts which i found on these and the OFPEC forums, but they all give the same effect. Am i doing something wrong or is it impossible to spawn a weapon from something else then the init.sqs? :/ Share this post Link to post Share on other sites
mandoble 1 Posted July 19, 2006 When you create a weaponholder and you add a weapon to it, you still need to wait few seconds before the weapon can be picked up by the player. OTOH, the weapon can be immediately picked up by AI. I think the problem is related to the addAction attached to the weaponholder, as when you add an action to any object, the action is not immediately available for the players. Share this post Link to post Share on other sites
NeMeSiS 11 Posted July 19, 2006 Damned, you are right. it took almost 25 seconds before it started working. Thank you! Share this post Link to post Share on other sites
DanAK47 1 Posted July 20, 2006 Reveal the weaponholder to the player and it should work instantly. Share this post Link to post Share on other sites
UNN 0 Posted July 20, 2006 Quote[/b] ]Reveal the weaponholder to the player and it should work instantly. I thought that would work myself. But it's doesn't. You can create just the WeaponHolder during your startup, even if it's has to be placed off the map somewhere. Then add your weapon as normal from the trigger, and movr it into position. That seemed to work just fine. Share this post Link to post Share on other sites
NeMeSiS 11 Posted July 20, 2006 In my case it doesnt really matter that you cant pick it up immediately, the player starts too far away from it anyway Anyway, a slightly related question: Is it possible to detect if a weapon has been picked up? I thought about checking if the weapon is still on its spawned location, and if it isnt that someone must have picked it up, but im not sure if thats possible with weaponholders. Â Share this post Link to post Share on other sites
mandoble 1 Posted July 20, 2006 If you load a single weapon per weaponholder, the weaponholder object itself is deleted when someone picks up the weapon, you may check ? isNull weaponholder: blah blah blah Share this post Link to post Share on other sites
NeMeSiS 11 Posted July 20, 2006 Well, right now i have this, which works, but i found one rather strange 'feature' of the flashpoint engine <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_table = _this select 0 #start _weaponArray = ["WGL_m16","CZ75","Kozlice","Kozlice","Revolver","Huntingrifle","WGL_M9","WGL_AK47"] _magArray = ["WGL_m16","CZ75Mag","Kozliceshell","Kozliceball","RevolverMag","HuntingrifleMag","WGL_M9mag","WGL_AK47mag"] _Ax = 1+ random 7 _weapon = _weaponArray select _Ax _mag = _magArray select _Ax weapon = "WeaponHolder" createVehicle [getpos _table select 0,getpos _table select 1,(getpos _table select 2)] weapon addweaponCargo [_weapon,1] weapon addMagazineCargo [_mag,1+random 2] weapon setpos [getpos _table select 0,getpos _table select 1,getpos _table select 2] weapon setdir random 360 #loop ? (weapon distance _table) > 2:goto "restart" ~1 goto "loop" #restart ~5 goto "start" It works fine, when a player picks up a weapon it spawns another one. But when the player already has a weapon of the same type (a handgun for example), it switches the the spawned weapon with the player weapon and it doesnt respawn a new one! So the player has to drop his gun on the ground before picking up a new weapon, which is rather strange.. Â EDIT: I also tried deleting the nearest weaponholder, but it wont delete the weapon the player had before if he switched the weapon, but it will delete it if he drops his weapon first and then grabs the spawned weapon. Im probably doing something very stupid, but i dont see it now, and im tired so ill continue tomorrow Share this post Link to post Share on other sites