Jump to content
  • 0

Code to block players on PVE servers from shooting each other


_Lance_

Question

A long time ago on a PVE server somewhere in Russia, I remember a server where players couldn't shoot each other. If your cursor was on a player and you tried to pull the trigger nothing would happen until your cursor was off their body's silhouette. I'd like to setup something like this for my pve players to prevent "incidents". If it's possible I'm thinking it will be something in fn_selfActions (maybe) like:

 

//Block firing weapon at other players on PVE server

if cursorTarget = isPlayer then (code that won't let you shoot goes here!)

 

Haha that's about the extent of my code-from-scratch knowledge. Anyone want to take a swing at this? Any help is greatly appreciated.

Link to comment
Share on other sites

Recommended Posts

  • 0
On 8/29/2017 at 6:43 AM, _Lance_ said:

A long time ago on a PVE server somewhere in Russia, I remember a server where players couldn't shoot each other. If your cursor was on a player and you tried to pull the trigger nothing would happen until your cursor was off their body's silhouette. I'd like to setup something like this for my pve players to prevent "incidents". If it's possible I'm thinking it will be something in fn_selfActions (maybe) like:

 

//Block firing weapon at other players on PVE server

if cursorTarget = isPlayer then (code that won't let you shoot goes here!)

 

Haha that's about the extent of my code-from-scratch knowledge. Anyone want to take a swing at this? Any help is greatly appreciated.

You could do it in the damage handler around here: https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/compile/fn_damageHandler.sqf#L82

if (_isPlayer && !_falling) exitWith {};

You need to make sure it's AFTER this line:

_isPlayer = (isPlayer _source);

 

Link to comment
Share on other sites

  • 0
2 hours ago, _Lance_ said:

Exit like it kicks the player or exit like it stops the firing action?

I'll take a look through this when I get to the house in a couple hours, didn't think I'd get a response that quick, thanks!!

No, it will just not process damage for the unit taking damage if the source is a player

In hindsight it needs to be a few lines down after the _isPlayer = line

Link to comment
Share on other sites

  • 0
7 hours ago, salival said:

No, it will just not process damage for the unit taking damage if the source is a player

In hindsight it needs to be a few lines down after the _isPlayer = line

Tried that out and no luck yet, here's how I placed it:

//End Simple hack for damage ***until 2.0***

dayz_lastDamageSourceNull = false;
_isPZombie = _model isKindOf "PZombie_VB";
_isMan = _sourceType isKindOf "CAManBase";
_isPlayer = (isPlayer _source);
if (_isPlayer) exitWith {};

Link to comment
Share on other sites

  • 0

Found this old mod and I'm going to try and update the code and see what I can learn from it, I don't like that it lets the player go instead of kicking them/killing them/banning them but it's a start. Last night it was out of hand, my pve server has gone from low-med pop to med-high pop in a week. Had 30 players on at the end of us peak time and when that many players are on a pve server at once, shootings tend to happen lol.

 

 

Found this as well in another thread, I have a lot of studying to do...

 

Use a custom fn_damageHandler.

 

Find this line:

_unitIsPlayer = _unit == player;

and add this under it:

if ((isPlayer _unit) AND (!(_source == _unit)) AND ((side _unit) == WEST) AND (_source isKindOf "Man") AND (isPlayer _source)) exitWith {};
if ((isPlayer _unit) AND (!(_source == _unit)) AND ((side _unit) == WEST) AND (_source isKindOf "Car" OR _source isKindOf "Ship" OR _source isKindOf "Air") AND (isPlayer ((crew _source) select 0))) exitWith {};

It should block most PVP damage. If you're players are finding a way around it, then turn on the DZE_Debug_Damage in the script to find out what the source is, replicate it, and I can write a new line to block it.

Link to comment
Share on other sites

  • 0

Man I had zero luck with the pvp jail script. Spent a couple hours last night working at it and never could get all of it to work with 1061a. The jail would show up, remote messages worked, just the actual script itself as far recognizing that you killed a player and teleporting you to the jail is what isn't working - It's got to be an incompatiability with what gets added to the bottom of server_playerDied. I checked for variables that have changed since 1051 and couldn't find any any old ones, I think it's got something to do with the _killer variable perhabs, might just need to update it to "isKiller" or something like that - I tried a lot of things and couldn't get that part working so tonight I'm going to focus on the snippet of code I posted after that and see if I can get a working result out of that. I believe the person who posted it got it from here: 

Team kill punish with jail cell - Armaholics

Link to comment
Share on other sites

  • 0

For anyone following this or that tries to do this in the future, has the same issue and finds this thread:

I was doing everything right (once I moved the fn_damageHandler to my mission folder) but one of my mods is locking my damagehanlder and forcing it, so the code to exit script doesn't work. My server is heavily modded so to find out which mod is causing the issue I'm going to setup a from scratch overpoch server tonight, set the damagehandler exit first thing and make sure that works and then I'll add my mods back in one at a time and test function until I identify which mod is the culprit, and I'll report back here with my findings. 

Many thanks to Salival and Jason not only for their help on this bug but for all the work they do for the mod, admins, and players which helps keep the a2 epoch community rolling along. Much appreciated guys!

I'll post up either late tonight or early saturday and report how things went.

Link to comment
Share on other sites

  • 0

Watching this with interest. I'm helping someone with a pve server as he has no coding knowledge, so I'm doing it all for him. Pretty sure this is something he would like, so once you figure it out, I'd be interested on hearing it. 

I could try testing it myself, but don't have live test server, only a LAN one on my laptop and no one else to try it out with. :biggrin:

Link to comment
Share on other sites

  • 0
7 hours ago, _Lance_ said:

For anyone following this or that tries to do this in the future, has the same issue and finds this thread:

I was doing everything right (once I moved the fn_damageHandler to my mission folder) but one of my mods is locking my damagehanlder and forcing it, so the code to exit script doesn't work. My server is heavily modded so to find out which mod is causing the issue I'm going to setup a from scratch overpoch server tonight, set the damagehandler exit first thing and make sure that works and then I'll add my mods back in one at a time and test function until I identify which mod is the culprit, and I'll report back here with my findings. 

Many thanks to Salival and Jason not only for their help on this bug but for all the work they do for the mod, admins, and players which helps keep the a2 epoch community rolling along. Much appreciated guys!

I'll post up either late tonight or early saturday and report how things went.

Well there's only a few mods that will influence the damage handler, infistar (admins only in godmode which your player wasnt) safezone script

So, I think it could have been your safezone:

custom/TraderSafezones/16_safezone.sqf:213:            fnc_usec_damageHandler = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\fn_damageHandler.sqf';

Still references the original fn_damageHandler.sqf in epoch

Link to comment
Share on other sites

  • 0
4 hours ago, salival said:

Well there's only a few mods that will influence the damage handler, infistar (admins only in godmode which your player wasnt) safezone script

So, I think it could have been your safezone:

custom/TraderSafezones/16_safezone.sqf:213:            fnc_usec_damageHandler = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\fn_damageHandler.sqf';

Still references the original fn_damageHandler.sqf in epoch

Yep I think this was even mentioned in discussion last night as the probable suspect, you guys nailed it. I'll update the path and test it out to verify, thanks!

EDIT: The damagehandler is working now but two issues 1. God mode safe zones stopped working and you can also fire in the safe zone now so something early in the script isn't working, and 2. You can't kill a player but you can trigger an infistar knockout so to curb trolling I'm going to find that part of the infistar code and see if I can comment it out or something. I'm going to peek at the god-mode-trader script and see what I've missed first. - oh and interaction with zombies and AI is completely normal from both directions, I can kill them still, they can kill me still so that's working like I want it to so far.

EDIT: The god mode trader script not working was just me rushing and forgetting a semi-colon. I'm on a roll this week! Now to disable infistar knockouts and it'll be perfect..

Link to comment
Share on other sites

  • 0
1 hour ago, salival said:

try this:


if (_isPlayer && !_falling) exitWith {};

 

Well I couldn't sleep wondering if that edit was going to fix it so I got back up and tested - Salival, you nailed it. So now if players use guns or explosives on another player they'll survive. If they shoot AI they die, and vice versa, same for zombies and if zombies attack the player takes damage, and now tested fall damage after re-verifying everything - Case closed! Thanks a ton for the help, this will seriously cut down on the "Bobby shot Tommy over a mission" notifications I have to see each day.

Link to comment
Share on other sites

  • 0
21 minutes ago, _Lance_ said:

Well I couldn't sleep wondering if that edit was going to fix it so I got back up and tested - Salival, you nailed it. So now if players use guns or explosives on another player they'll survive. If they shoot AI they die, and vice versa, same for zombies and if zombies attack the player takes damage, and now tested fall damage after re-verifying everything - Case closed! Thanks a ton for the help, this will seriously cut down on the "Bobby shot Tommy over a mission" notifications I have to see each day.

No problem, glad it worked out

Link to comment
Share on other sites

  • 0
9 hours ago, salival said:

No problem, glad it worked out

Welp, after much testing and laughing my ass off, I found one more item I need to adjust -  I noticed if a player shoots another player with a rocket launcher they can sometimes still die by falling damage because they'll fly 200 feet in the air. I'm going through the code looking for what makes explosions apply force to players so I can disable it, everything else working great. So If any of you know what file I'm looking for please let me know, might save me some time. I'm currently going through dayz_code.pbo/compiles checking player action scripts

Link to comment
Share on other sites

  • 0

I found a few files that looked like they may be the right ones to edit but there's quite a few that reference what happens when a player fires or is near an explosion and I'm not confident enough with arma code to start making any changes without having some info to reference - in the meantime we didn't have a single player death (caused by another player) on the PVE server over the three day weekend so I'm in a much better position than I was before starting working on this. Also fixed quite a few bugs in the process of working on this and trying to get the old 1051 evac chopper mod working again, so there's that at least. Baby steps!

Link to comment
Share on other sites

  • 0
On 2/9/2017 at 6:24 AM, salival said:

try this:


if (_isPlayer && !_falling) exitWith {};

 

I pasted this line into the fn_damagehandle file... , I need to take this file on my mpmission\dayz_code folder, I should call it in the compile file and... that should be enough, right?

Link to comment
Share on other sites

  • 0
9 hours ago, LadyVal said:

I pasted this line into the fn_damagehandle file... , I need to take this file on my mpmission\dayz_code folder, I should call it in the compile file and... that should be enough, right?

Hi,

It needs to be replicated like the epoch example here: https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/init/compiles.sqf#L631

Link to comment
Share on other sites

  • 0
6 hours ago, LadyVal said:

Thanks Legend, I will give it a try.

So, adding that line into the compile file outside the dayz_code.pbo

I should  have elaborated on my first post more

You need to put that in your custom compiles down the bottom in your mission file, i.e mission pbo\dayz_code\init\compiles.sqf if you are running any of my mods

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...