Home   Help Search Login Register  

Author Topic: Got me stumped, HELP!!! MP spawn protection/punishment  (Read 3366 times)

0 Members and 1 Guest are viewing this topic.

Offline BuhBye

  • Members
  • *
  • I'm a llama!
I have made and re-made this script 20 times, 20 different ways and I cant get this thing to work. The issue is local, global. At this point every single thing works perfect on my PC. When I upload it to the server the version below doesn't work at all. None of it!?

I can not figure out what is going on here. I know its not a that it wont work cause Ive had it working with some bugs.

How it works.....

The player units have a trigger grouped to them set to vehicle present and OnActivation they exec this script.

"ffzone" is a trigger in the mission covering the neutral zone.
"sfwest" is a trigger in the mission covering W spwan.
"sfeast" is a trigger in the mission covering E spawn.

The script is called "noob.sqs"
Code: [Select]
?(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 "noob.sqs"}]

exit

#who
~.001

?(_shooter == _hit) : exit
?(vehicle player == _shooter) && (_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"



And this is "punishment.sqs"
Code: [Select]
?! 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]
~30
titleText ["And here comes your spanking!","plain",1]

~1
exit




I have had this up on the BIS forum for weeks and noone seems to know. Can someone PLEASE! tell me why this doesn't work on a server?
« Last Edit: 09 Jun 2007, 20:16:44 by Mr.Peanut »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Got me stumped, HELP!!!
« Reply #1 on: 09 Jun 2007, 20:13:41 »
It does not work because the "HIT" eventhandler only goes off on the machine of the person who got hit. Take a look at the vehicle protection script I wrote on the Multiplayer board. When the eventhandler fires you have to communicate the player hit and shooter information to the other computers, then check if the person hit is in the spawn area. You do this by using "publicVariable". Take a look at the vehicle protection script and then ask again.

Your script looks like it should work in every respect except the messages which will only be displayed for the person hit.
« Last Edit: 11 Jun 2007, 21:52:23 by Mr.Peanut »
urp!

Offline BuhBye

  • Members
  • *
  • I'm a llama!
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #2 on: 10 Jun 2007, 00:52:49 »
Thanx Mr Peanut,

The link you put up to your script isnt there so I cant look at it.

Why shouldn't the event handler work localy? All the punishments are local. And it doesnt only check the person hit. If you look at the beginning of the post I have everyone launch the script when the map starts. Once the event handler detects someone was hit they exec it again for that instance. So the people who are hit are really running the script twice at the same time. This very script (unchanged) worked perfect in OFP on a deticated server. But it doesn't in ArmA.

Thanx for the response. I didnt even get on on BIS. :good:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #3 on: 10 Jun 2007, 04:13:56 »
This line:
Code: [Select]
[_shooter] exec "punishment.sqs" is only executed on the machine of the victim. And upon second glance, your punishment never uses _shooter.

The thread I was talking about is just at the bottom of the first page of the MP board here.

Basically, without using publicVariable you can not implement this. You place a trigger to detect the PV change which then implements your punishment script on every client.

We will iron this out tomorrow... it's bedtime. :goodnight:
« Last Edit: 10 Jun 2007, 04:26:40 by Mr.Peanut »
urp!

Offline BuhBye

  • Members
  • *
  • I'm a llama!
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #4 on: 12 Jun 2007, 02:29:13 »
Ok Mr Peanut,
Ive been busy and couldn't deal with this. If you dont mind I would like to discuss this so I know exactly why it doesn't work instead of just fixing it and learning nothing.

First question: This very script worked perfect in OFP. Why not in ArmA? This local, global rules are the same, are they not?

Number 2: Why cant the punishments be local? There are certain perameters in a local array (a unit) that are always global. The position, ammo count and weapons etc. The punishment directly affects those perameters that are public. So why wont it work?

Third: Everyone in the mission launches this script when it starts. So all are looping it until the eventhandler sets an array for "hit"

The "hit" array contains [damage,hit,shooter] right? So if all are running it and the "hit" array is created one player becomes _shooter and the other _hit. They are both in the script, so the _hit player execs the script again because he will exit it once its complete. Then the _shooter goes to punish after the message and _hit goes to remove. All of it makes sense to me so please help me understand. I know I could use publicvariable but I dont see why this doesn't work and I would like to learn why.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #5 on: 12 Jun 2007, 03:36:02 »
So close to bedtime again, but I'll try to squeeze a few quick answers in.

1)First thing is you pass _shooter to your punishment script but you have no _this select 0 at the beginning of your punishment script. Why is it passed if it is not used?

If the script worked in OFP it should work in ArmA.

2)I never said it would not work, all I said is that the titletext and globalchat will only be seen on the machine of the victim. The criminal will get partially punished since setPos is a global command, but he will not lose his weapons because removeAllWepons is local.

3)Might be worth reading Terox' MP tutorial on the beta board. The  script is running on all machines, but the "HIT" (and "KILLED") event handlers are local, they only fire on the machine of the unit that got hit. That means that only on the victim's machine is the punishment script run. There are some commands which when run on just one machine have a global effect. When you setDamage any unit on any one machine, it is broadcast to all machines. Some commands, however, such as removeAllWeapons only work when they are run on the machine to which a unit is local. If you fix the error I mentioned in 1) then only the victim will see the messages, the guilty will get moved to the marker location and might or might not die from the setVelocity command.
urp!

Offline BuhBye

  • Members
  • *
  • I'm a llama!
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #6 on: 12 Jun 2007, 18:27:13 »
After reading your last I started looking at the script and noticed I have several lines of code with 2 colins. As you may have noticed I have it up on BIS as well. Anyway I started thinking that, that might be why its not working. Im gunna mod it a little and test it.

Offline Relentless

  • Members
  • *
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #7 on: 03 Aug 2007, 14:52:05 »
This may be a little late but i have a working  respawn punishment script if you need it  just pm me  :)

Offline Nixer6

  • Members
  • *
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #8 on: 05 Aug 2007, 23:04:15 »
Might be worth reading Terox' MP tutorial on the beta board

Can someone find this for me me, I can't.

Mr Peanut ???????
Why do I have to be a Rocket Scientist to make a good mission?

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #9 on: 07 Aug 2007, 05:04:37 »
Did you mean to make a new thread?

Anyhow, is this it?
http://www.ofpec.com/forum/index.php?topic=28815.0

Offline Nixer6

  • Members
  • *
Re: Got me stumped, HELP!!! MP spawn protection/punishment
« Reply #10 on: 07 Aug 2007, 20:20:08 »
Thanks M8  :clap:
Why do I have to be a Rocket Scientist to make a good mission?