Jump to content
Sign in to follow this  
Op4 BuhBye

Public, Global, Local!!!

Recommended Posts

I am  banghead.gif  with this. I had it all figured out in OFP but ArmA is killin me!

I have a local script for spawn killing and TKing that checks fir hit and shooter and I have tried 10 differant ways to make this thing work right.

All 10 ways work perfect locally but on a DS it works sometimes or not at all.

Am I fighting a  Public, Global, Local bug here or did the rules change?

Thanx guyz.

PS I used the same script in OFP but its not working in ArmA.

Share this post


Link to post
Share on other sites

You're going to have to post the script before you can get any help with it.

Share this post


Link to post
Share on other sites

Here it is...

"violation.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(firstin == 1) : goto "check"

spawnfire = 0

friendlyfire = 0

firstin = 1

#check

_hit = _this select 0

?(count _this) > 1 : _violatorff = _this select 1

?(count _this) > 2 : _violatorsf = _this select 2

?(count _this) > 3 : _damage = _this select 3

?(count _this) > 3 : goto "who"

_hit addeventhandler ["hit",{_this exec "violation.sqs"}]

exit

#who

?(_violatorff == _hit) : exit

?(_violatorsf == _hit) : exit

?(side _hit == west && side _violatorff == west) : _hitff = ffwest

?(side _hit == east && side _violatorff == east) : _hitff = ffeast

?(side _violatorff == west && side _hit == west ) : _shotff = ffwest

?(side _violatorff == east && side _hit == east ) : _shotff = ffeast

?(_violatorff in list _shotff) : _mesg = format["%1 will be dealt with for shooting team mate %2.",name _violatorff,name _hitff]; goto "punish"

?(_hit in list _hitff) : _mesg = format["%1 will be dealt with for shooting team mate %2.",name _violatorff,name _hitff]; goto "punish"

?(side _hit == west) : _hitsf = sfwest

?(side _hit == east) : _hitsf = sfeast

?(side _violatorsf == west) : _shotsf = sfwest

?(side _violatorsf == east) : _shotsf = sfeast

?(_violatorsf in list _shotsf) : _mesg = format["%1 will be dealt with for shooting %2 from spawn.",name _violatorsf,name _hitsf]; goto "punish"

?(_hit in list _hitsf) : _mesg = format["%1 will be dealt with for shooting %2 in spawn.",name _violatorsf,name _hitsf]; goto "punish"

Exit

#punish

_name = name _violatorff

_name = name _violatorsf

_violatorff addscore -10

_violatorsf addscore -10

?(_violatorff == player) : friendlyfire = friendlyfire + 1

?(_violatorsf == player) : spawnfire = spawnfire + 1

hint _mesg

?(_violatorff == player) && friendlyfire == 3 : goto "loop1"

?(_violatorsf == player) && spawnfire == 3 : goto "loop2"

?(_violatorsf or _violatorff == player) && spawnfire + friendlyfire == 3 : goto "loop3"

[_shooterff] exec "punishment.sqs"

[_shootersf] exec "punishment.sqs"

~1

exit

#loop1

~5

(_violatorff && _violatorsf) = _noob

titletext ["You have shot a Team Mate 3 times.\nYour game is over!","plain",1]

removeallweapons _noob

_noob setposasl [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1),1000]

goto "loop1"

#loop2

~5

(_violatorff && _violatorsf) = _noob

titletext ["You have shot someone in, or from spawn 3 times.\nYour game is over!","plain",1]

removeallweapons _noob

_noob setposasl [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1),1000]

goto "loop2"

#loop3

~5

(_violatorff && _violatorsf) = _noob

titletext ["You have violated the engagement rules 3 times.\nYour game is over!","plain",1]

removeallweapons _noob

_noob setposasl [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1),1000]

goto "loop3"

Triggers...

"sfwest" covers west spawn

"sfeast" covers east spawn

"ffwest" covers neutral zone

"ffeast" covers neutral zone

"punishment.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?! local player : exit

~.01

titletext ["You have violated the engagement rules.","plain",1]

~.01

removeallweapons player

~.01

player setpos [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1)]

~3

player setvelocity [0, 0, 1000]

~5

titleText ["And here is your spanking!","plain",1]

~1

exit

If there are any type-Os its from me screwing around with it. As of the last try (probably not this ver. Lost track now) I had no script errors.

Share this post


Link to post
Share on other sites

This script has a few issues, from being unoptimized

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(side _hit == west && side _violatorff == west) : _hitff = ffwest

?(side _hit == east && side _violatorff == east) : _hitff = ffeast

?(side _violatorff == west && side _hit == west ) : _shotff = ffwest

?(side _violatorff == east && side _hit == east ) : _shotff = ffeast

to a potential calling itself several times per hit, after the player was hit several times (shrapnel etc.)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_hit addeventhandler ["hit",{_this exec "violation.sqs"}]

This makes it rather hard to read and you also did not describe what exactly did not work..

Was the punishment script not called? Was the whole script not running?

What did you try to debug?

Edit:

Actually I wonder that your code ever worked

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(count _this) > 1 : _violatorff = _this select 1

?(count _this) > 2 : _violatorsf = _this select 2

?(count _this) > 3 : _damage = _this select 3

?(count _this) > 3 : goto "who"

_this only contains [victim,shooter,damage]

so actually _violatorsf would be "damage" and _damage would be outside of the array

Share this post


Link to post
Share on other sites

The first part I thought was redundant. We at least the second check but I wasnt sure.

?(side _hit == west && side _violatorff == west) : _hitff = ffwest

?(side _hit == east && side _violatorff == east) : _hitff = ffeast

?(side _violatorff == west && side _hit == west ) : _shotff = ffwest

?(side _violatorff == east && side _hit == east ) : _shotff = ffeast

But I dont understand what you mean about

Quote[/b] ]_this only contains [victim,shooter,damage]

so actually _violatorsf would be "damage" and _damage would be outside of the array

I want to check and devide the friendly fire and the spwan fire why doesnt this do that? Im guessing there is a set order I dont know about. And adding...

?(count _this) > 2 : _violatorsf = _this select 2 violated that?

If this is the case how would I check and devide the offences?

_hit1 = _this select 0

?(count _this) > 1 : _violatorff = _this select 1

?(count _this) > 2 : _damageff = _this select 2

?(count _this) > 2 : goto "who"

_hit2 = _this select 0

?(count _this) > 1 : _violatorsf = _this select 1

?(count _this) > 2 : _damagesf = _this select 2

?(count _this) > 2 : goto "who"

Is this what I need to do?

As for debugging. Everything works perfect locally, when I put it on the sever..

Some times you can shoot someone one and nothing happens and if you do it again the script runs. Other times it never runs. I think with this ver the victim was getting punished not the violator.

I had the "punishment.sqs" code in this script but it wasnt removing the weapons on a server.

I am still in a learning curve for scripts this complex so any help or explaination is appeciated.

Share this post


Link to post
Share on other sites

He means your _this array is one item short. The hit eventhandler only passes on the following information:

victim: the person who was hit

shooter: the person who hit them (objNull if none), it can only be 1 person

damage: the damage the victim recieves

It's passed on in an array in the form of [victim,shooter,damage]. It does not contain different shooters for friendly fire or enemy fire, just the one shooter who has to be decided in the script itself if they're enemy or friendly. You're trying to access something that does not exist. But Rastavovich is correct, this script is pretty poorly designed. There's no need to have 2 different shooters (or "violators") anyway, since it will always only be one person who hit you (two or more people can't share the same gun). So rather than defining 2 different variables for the same guy, use one and check if the guy is hostile or friendly.

Share this post


Link to post
Share on other sites

Thanx guyz, I have changed this so many times trying to get it to work that I have lost track of what did and didnt work. The ver above does not (as you knew) so with the new info (thanx Kyle) Im going to start over and at least get it to a point where I can say "this isnt working" and go from there.

Ive gotten to the point where its 5 miles long and over complicated trying to make it work. "click!, deleted!"

WOW my tail is fast, Ive been chasing it for days crazy_o.gif

Share this post


Link to post
Share on other sites

Ok.......... yay.gif  Ive got everything working locally. I will multi test it tomarrow but this is it.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(firsttime == 1) : goto "count"

spawnkill = 0

friendlyfire = 0

firsttime = 1

#count

_hit = _this select 0

?(count _this) > 1 : _shooter = _this select 1

?(count _this) > 2 : _damage = _this select 2

?(count _this) > 2 : goto "who"

_hit addeventhandler ["hit",{_this exec "dick.sqs"}]

exit

#who

~.001

?(_shooter == _hit) : exit

;friendlyfire////////////////////////////////////////////////////////////////////

?(side _shooter == west && side _hit == west ) : _shooterff = ffzone

?(side _hit == west && side _shooter == west) : _hitff = ffzone

?(side _shooter == east && side _hit == east ) : _shooterff = ffzone

?(side _hit == east && side _shooter == east) : _hitff = ffzone

?(_shooter in list _shooterff) : _mesg = format["%1 will be dealt with for shooting Team Mate %2.",name _shooter,name _hit]; goto "punishmentff"

?(_hit in list _hitff) : _mesg = format["%1 will be dealt with for shooting Team Mate %2.",name _shooter,name _hit]; goto "remove"

;spawnfire///////////////////////////////////////////////////////////////////////

?(side _shooter == west) : _shootersf = sfwest

?(side _shooter == east) : _shootersf = sfeast

?(side _shooter == west) : _shooterff = ffzone

?(side _shooter == east) : _shooterff = ffzone

?(side _hit == west) : _hitsf = sfwest

?(side _hit == east) : _hitsf = sfeast

?(side _hit == west) : _hitff = ffzone

?(side _hit == east) : _hitff = ffzone

?(_shooter in list sfwest) : _mesg = format["%1 will be dealt with for shooting %2 from spawn.",name _shooter,name _hit]; goto "punishmentsf"

?(_shooter in list sfeast) : _mesg = format["%1 will be dealt with for shooting %2 from spawn.",name _shooter,name _hit]; goto "punishmentsf"

?(_shooter in list ffzone) : _mesg = format["%1 will be dealt with for shooting %2 in spawn.",name _shooter,name _hit]; goto "punishmentsf"

?(_hit in list sfwest) : _mesg = format["%1 will be dealt with for shooting %2 in spawn.",name _shooter,name _hit]; goto "remove"

?(_hit in list sfeast) : _mesg = format["%1 will be dealt with for shooting %2 in spawn.",name _shooter,name _hit]; goto "remove"

?(_hit in list ffzone) : _mesg = format["%1 will be dealt with for shooting %2 from spawn.",name _shooter,name _hit]; goto "remove"

goto "who"

#remove

_name = name _hit

hint _mesg

exit

#punishmentff

~.1

?(_shooter == Player) : friendlyfire = friendlyfire + 1

~.5

?(_shooter == player) && friendlyfire == 3 : goto "loop1"

?(_shooter == player) && spawnkill + friendlyfire == 3 : goto "loop3"

_name = name _shooter

hint _mesg

_shooter Addscore -10

[_shooter] exec "punishment.sqs"

~1

exit

#punishmentsf

~.1

?(_shooter == Player) : spawnkill = spawnkill + 1

~.5

?(_shooter == player) && spawnkill == 3 : goto "loop2"

?(_shooter == player) && spawnkill + friendlyfire == 3 : goto "loop3"

_name = name _shooter

hint _mesg

_shooter Addscore -10

[_shooter] exec "punishment.sqs"

~1

exit

#loop1

~.5

titletext ["You have shot a Team Mate 3 times.\nYour game is over!","plain",1]

removeallweapons _shooter

_shooter setposasl [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1),1000]

~5

goto "loop1"

#loop2

~.5

titletext ["You have shot someone in, or from spawn 3 times.\nYour game is over!","plain",1]

removeallweapons _shooter

_shooter setposasl [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1),1000]

~5

goto "loop2"

#loop3

~.5

titletext ["You have violated the engagement rules 3 times.\nYour game is over!","plain",1]

removeallweapons _shooter

_shooter setposasl [(getmarkerPos "die" select 0),(getmarkerPos "die" select 1),1000]

~5

goto "loop3"

Share this post


Link to post
Share on other sites

I need some help in this script. I have 2 holes in it that need to be filled and I have no idea how to do it....

1- I need to check for each violation when a player is in a vehicle (armed). IE You shoot someone from a HMMWV MK-19.

The checks dont work if you are in a vehicle.

2- I never understood the FF thing built into the game IE (you crash a chopper and you FF yourself). Anyway with the FF check I have, if you hit something while driving you get punished for it. How do I get around this?

I have this in it ...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(_shooter == _hit) : exit

but it only works if you're not in a vehicle.

I tried...

?(vehicle _shooter == _hit) : exit

and

?(vehicle player == _shooter) && (_shooter == _hit) : exit

Neither one worked.

Share this post


Link to post
Share on other sites

I MP tested the script and not one thing works???

Anyone know why.

Share this post


Link to post
Share on other sites

First, this script is called from an eventhandler correct? So, where is this EH added (init field, script)? That would effect the locality. Also, the eventhandler itself may have only local effects.

Share this post


Link to post
Share on other sites

Every player execs the script in a trigger grouped to them set to vehicle present. I have got this basic format to work on the DS but this ver doesnt at all, not 1 thing runs.

I never changed the funtionality of the code just the order. Thus far if it didnt work on my PC it didnt work on the DS. But this ver works rerfect on my PC.

Really everything should be local. the hit, shooter and messages are all local. Even the punishment script is local. But the clients on a DS dont run it. I dont know why.

The only thing Im not sure of is the removeeventhandler command. Should I have that in there?

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
Sign in to follow this  

×