Jump to content
kagenekosama

Activate a trigger when a weapon is shot?

Recommended Posts

Hey all, i'm starting to use to editor and learn a lot of things, but since there is a lot of tutorials around i can't find an answer to this question.

 

Basically i want a group of karts to move around certain waypoints when someone fires a weapon, what condition should i use?

 

Also if it could be made so it only works when a starter pistol is shot it would be nice.

 

Thanks! 

Share this post


Link to post
Share on other sites
3 hours ago, kagenekosama said:

Hey all, i'm starting to use to editor and learn a lot of things, but since there is a lot of tutorials around i can't find an answer to this question.

 

Basically i want a group of karts to move around certain waypoints when someone fires a weapon, what condition should i use?

 

Also if it could be made so it only works when a starter pistol is shot it would be nice.

 

Thanks! 

 
 

You can use an event handler that once that weapon is fired the trigger gets activated. Here is a link to a useful tutorial booklet that explains event handlers.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites
16 hours ago, kagenekosama said:

Hey all, i'm starting to use to editor and learn a lot of things, but since there is a lot of tutorials around i can't find an answer to this question.

 

Basically i want a group of karts to move around certain waypoints when someone fires a weapon, what condition should i use?

 

Also if it could be made so it only works when a starter pistol is shot it would be nice.

 

Thanks! 

player addEventHandler["Fired",{
_unit = (_this select 0);  //object
_weapon  = (_this select 1); //string
_muzzle = (_this select 2); //string
_mode = (_this select 3); //string
_ammo =  (_this select 4); //string
_magazine =  (_this select 5); //string
_projectile = (_this select 6); //object
_gunner = (_this select 7); //object

hint format["%1 %2 %3 %4 %5 %6 %7",_unit,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_gunner];
}];

a little example.

  • Like 2

Share this post


Link to post
Share on other sites

Remember, there is a difference between FiredMan and Fired. Fired will not trigger in a vehicle, and FiredMan will. 

  • Like 1

Share this post


Link to post
Share on other sites
On 5/4/2017 at 9:51 AM, Midnighters said:

player addEventHandler["Fired",{
_unit = (_this select 0);  //object
_weapon  = (_this select 1); //string
_muzzle = (_this select 2); //string
_mode = (_this select 3); //string
_ammo =  (_this select 4); //string
_magazine =  (_this select 5); //string
_projectile = (_this select 6); //object
_gunner = (_this select 7); //object

hint format["%1 %2 %3 %4 %5 %6 %7",_unit,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_gunner];
}];

a little example.

Those commands should go in the trigger ouput, or the condition?

Share this post


Link to post
Share on other sites
On 5.4.2017 at 4:51 PM, Midnighters said:

player addEventHandler["Fired",{
_unit = (_this select 0);  //object
_weapon  = (_this select 1); //string
_muzzle = (_this select 2); //string
_mode = (_this select 3); //string
_ammo =  (_this select 4); //string
_magazine =  (_this select 5); //string
_projectile = (_this select 6); //object
_gunner = (_this select 7); //object

hint format["%1 %2 %3 %4 %5 %6 %7",_unit,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_gunner];
}];

a little example.

 

Or:

player addEventHandler["Fired",{hint str _this}];

 

7 minutes ago, kagenekosama said:

Those commands should go in the trigger ouput, or the condition?

Neither of those make any sense.

Either read the booklet link above or try stuff out.

It's not like your PC is going to explode if you put a command into a condition.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
10 minutes ago, kagenekosama said:

Those commands should go in the trigger ouput, or the condition?

The reason I did not write the code for you myself is because I thought you wanted to learn, so I linked you the booklet instead. Just like Grumpy said mate try stuff out, it won't hurt to try out new things as a matter of fact you will learn better.

 

Cheers :)

Share this post


Link to post
Share on other sites

yep i want to learn, however even if i know programing i still have to learn about the editor that's why i'm asking. And i'm no caveman i know my editor wont crash if i do that, what worries me is if it would work.

Share this post


Link to post
Share on other sites
1 minute ago, kagenekosama said:

what worries me is if it would work.

 

Well, you can only find out if you try :)

 

And if you het stuck let us know we will help

Share this post


Link to post
Share on other sites
On 4/8/2017 at 10:17 AM, Grumpy Old Man said:

 

Or:


player addEventHandler["Fired",{hint str _this}];

 

Neither of those make any sense.

Either read the booklet link above or try stuff out.

It's not like your PC is going to explode if you put a command into a condition.

 

Cheers

I was just trying to show the different stuff returned by the event handler.

Share this post


Link to post
Share on other sites

Hey guys still haven't learned how to make this work so stand with me a little more while i'm using the guide BK gave me.

 

In the meantime, i trying to make a weapon fall from the sky, but it doesn't work, when i set its position to the air i just stays there floating, is it impossible to make it fall?

Share this post


Link to post
Share on other sites
11 hours ago, kagenekosama said:

Hey guys still haven't learned how to make this work so stand with me a little more while i'm using the guide BK gave me.

 

In the meantime, i trying to make a weapon fall from the sky, but it doesn't work, when i set its position to the air i just stays there floating, is it impossible to make it fall?

You need to spawn it inside a simulated weaponholder, which has physics enabled. Regular groundWeaponHolder doesn't.

 

Cheers

Share this post


Link to post
Share on other sites
6 hours ago, Grumpy Old Man said:

You need to spawn it inside a simulated weaponholder, which has physics enabled. Regular groundWeaponHolder doesn't.

 

Cheers

Is there any option in the editor to do it, or can only be done via scripts? 
Edit: nvm found about it on the internetz

 

Share this post


Link to post
Share on other sites

Not working, even if i spawn it on the air around 50 units above player, the game forces it to spawn on the ground (happens with actual vehicles too)

Share this post


Link to post
Share on other sites

Did you try:
 

_pos = getposatl _weaponHolder;

_pos set [2,50];

_weaponHolder setposATL _pos;

 

Cheers

Share this post


Link to post
Share on other sites

Just use weaponHolderSimulated instead of groundWeaponHolder. Something like:

_weaponholder = createVehicle ["WeaponHolderSimulated", _pos, [], 0, "CAN_COLLIDE"];

Here _pos is what ever position you want, "CAN_COLLIDE" is for spawning inside the building, at the exact defined positions (needed for my own script).

  • Like 2

Share this post


Link to post
Share on other sites

Come on!  You guys are experts at this, I get that but quit torturing the fellow with trying to be his 'teacher'. Just simply answer his questions or go away.

  • Confused 1

Share this post


Link to post
Share on other sites
3 hours ago, ROGER_BALL said:

Come on!  You guys are experts at this, I get that but quit torturing the fellow with trying to be his 'teacher'. Just simply answer his questions or go away.

 

Roger, this topic is almost five years old and these guys are leading members of this community. Relax.

  • Like 3

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

×