Jump to content
HenPet

Taser script multiplayer

Recommended Posts

hey guys, im working on a multiplayer mission. i want to include a taser/ stun gun. i have found the following script, wich works in eden multiplayer but not on my dedicated server.
can someone help me fix this script so it works on a dedicated server. im new to scripting and dont realy understand the differences between scripting 4 dedicated servers and eden servers.

 

init.sqf

player addEventHandler ["Fired", {[_this select 0, cursorTarget] execVM "stun.sqf"}];

 

stun.sqf

_Shooter = (_this select 0); //Aquires name of shooter.
_Victim = (_this select 1); //Aquires name of the victim by "cursorTarget".
_Dist = _Shooter distance _Victim; //Returns the distance between the two.

if (!(side _Shooter == west) && (isNull _Victim) && _Dist > 50) exitWith {}; //This checks for the conditions you want.

_Victim allowDamage false; //Avoids the victim being shot by "Accident"..
_Victim switchMove "AinjPfalMstpSnonWnonDf_carried_fallwc"; //Initiates action.
sleep 7; //Animation length of victim falling to ground
_Victim switchMove ""; //Resets Action, do not change!
//_Victim switchMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Handcuffed.
_Victim allowDamage true; //No longer a god and now a normal civ, or, whatever.

[format ["%1 hat %2 getasert.", _Shooter, _Victim]] remoteExec ["systemChat"];

thx for help in advance

Share this post


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

hey guys, im working on a multiplayer mission. i want to include a taser/ stun gun. i have found the following script, wich works in eden multiplayer but not on my dedicated server.
can someone help me fix this script so it works on a dedicated server. im new to scripting and dont realy understand the differences between scripting 4 dedicated servers and eden servers.

 

init.sqf


player addEventHandler ["Fired", {[_this select 0, cursorTarget] execVM "stun.sqf"}];

 

stun.sqf


_Shooter = (_this select 0); //Aquires name of shooter.
_Victim = (_this select 1); //Aquires name of the victim by "cursorTarget".
_Dist = _Shooter distance _Victim; //Returns the distance between the two.

if (!(side _Shooter == west) && (isNull _Victim) && _Dist > 50) exitWith {}; //This checks for the conditions you want.

_Victim allowDamage false; //Avoids the victim being shot by "Accident"..
_Victim switchMove "AinjPfalMstpSnonWnonDf_carried_fallwc"; //Initiates action.
sleep 7; //Animation length of victim falling to ground
_Victim switchMove ""; //Resets Action, do not change!
//_Victim switchMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Handcuffed.
_Victim allowDamage true; //No longer a god and now a normal civ, or, whatever.

[format ["%1 hat %2 getasert.", _Shooter, _Victim]] remoteExec ["systemChat"];

thx for help in advance

 

I believe that your problem is that  "player" does not exists for Dedicated Servers.

player addEventHandler ["Fired", {[_this select 0, cursorTarget] execVM "stun.sqf"}];

 

This will probably work:

{
	_x addEventHandler ["Fired", {[_this select 0, cursorTarget] execVM "stun.sqf"}];
} forEach playableUnits;

But beware that the script doesn't seem dedicated friendly nor very good at all.

 

It will make all weapons stun weapons and if the victim is very close it might even kill it anyway as cursorTarget is not very reliable. Some guys here might provide you with better taser scripts.

Share this post


Link to post
Share on other sites
1 hour ago, LSValmont said:

 

I believe that your problem is that  "player" does not exists for Dedicated Servers.


player addEventHandler ["Fired", {[_this select 0, cursorTarget] execVM "stun.sqf"}];

 

This will probably work:


{
	_x addEventHandler ["Fired", {[_this select 0, cursorTarget] execVM "stun.sqf"}];
} forEach playableUnits;

But beware that the script doesn't seem dedicated friendly nor very good at all.

 

It will make all weapons stun weapons and if the victim is very close it might even kill it anyway as cursorTarget is not very reliable. Some guys here might provide you with better taser scripts.

Tanks for the reply. 

Its true that the script isnt very good.

As you said weapons are dealing damage on close ranges. But thats not realy a problem for my use. But do you know how to secify wich weapon becomes a taser? This would help a lot. i think it would be possible to check in the script of the envent handler wich weapon was used but as i am new to scripting i am not sure how to add this exactly.

I would be happy if you or anyone else could help me with this.

Share this post


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

Tanks for the reply. 

Its true that the script isnt very good.

As you said weapons are dealing damage on close ranges. But thats not realy a problem for my use. But do you know how to secify wich weapon becomes a taser? This would help a lot. i think it would be possible to check in the script of the envent handler wich weapon was used but as i am new to scripting i am not sure how to add this exactly.

I would be happy if you or anyone else could help me with this.

 

I suggest you look around for fully fledged taser scripts or even better a mod.

 

You are too new to Arma 3 scripting to do one from scratch and it will take you some time to do it right so if you don't want to wait that long look for scripts on Armaholic.com or a mod with a taser at the steam workshop.

Share this post


Link to post
Share on other sites
22 hours ago, HenPet said:

Tanks for the reply. 

Its true that the script isnt very good.

As you said weapons are dealing damage on close ranges. But thats not realy a problem for my use. But do you know how to secify wich weapon becomes a taser? This would help a lot. i think it would be possible to check in the script of the envent handler wich weapon was used but as i am new to scripting i am not sure how to add this exactly.

I would be happy if you or anyone else could help me with this.

 

I'm not a scripter, but something like this may work.

You would need to decide what weapon you want to be the taser, and find the classname for it. I would suggest that you use the starter pistol for the taser, it looks like a gun, but cannot do damage.

 

if (currentWeapon _shooter == "classname of taser here") then

 

 

 

Quote

_Shooter = (_this select 0); //Aquires name of shooter.

_Victim = (_this select 1); //Aquires name of the victim by "cursorTarget".

_Dist = _Shooter distance _Victim; //Returns the distance between the two.

 

if (!(side _Shooter == west) && (isNull _Victim) && _Dist > 50) exitWith {}; //This checks for the conditions you want.

 

if (currentWeapon _shooter == "classname of taser here") then  
{

_Victim allowDamage false; //Avoids the victim being shot by "Accident"..

_Victim switchMove "AinjPfalMstpSnonWnonDf_carried_fallwc"; //Initiates action. sleep 7; //Animation length of victim falling to ground

_Victim switchMove ""; //Resets Action, do not change! /

/_Victim switchMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Handcuffed.

_Victim allowDamage true; //No longer a god and now a normal civ, or, whatever. [format ["%1 hat %2 getasert.", _Shooter, _Victim]] remoteExec ["systemChat"];

};

 

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

×