Home   Help Search Login Register  

Author Topic: Event Handlers and MP: Killshooter script  (Read 6308 times)

0 Members and 1 Guest are viewing this topic.

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Event Handlers and MP: Killshooter script
« on: 15 Oct 2002, 04:55:09 »
just an example of what you can do with an event handler.
Here's a script to kill a TK'er:

init.sqs line:
Code: [Select]
teamkill = player addeventhandler [{Killed}, {_this exec {Killshooter.sqs}]

then this little script

Code: [Select]
_killer = _this select 1
?side _killer == side player:_killer setdammage 1
exit
cool, huh?


(edit: removed little bug: brackets around _this)
« Last Edit: 16 Oct 2002, 19:46:32 by Dinger »
Dinger/Cfit

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
Re:Event Handlers and MP: Killshooter script
« Reply #1 on: 15 Oct 2002, 21:54:41 »
Thanks dinger, exactly what i needed!
The Captain

walker

  • Guest
Re:Event Handlers and MP: Killshooter script
« Reply #2 on: 15 Oct 2002, 23:13:24 »
Hi dinger

Within 4 hours of me posting the thought you come up with the script. Man you are a God.

The OFP multi-player community should sing your praises to the heavens.

Die Die Die you Cheater Strike Wusses (walker wonders off ranting and raving)

Regards Walker

Hamdinger

  • Guest
Re:Event Handlers and MP: Killshooter script
« Reply #3 on: 16 Oct 2002, 00:25:30 »
As another alternative to killing the offending player, you could take away their weapons and cripple them.

Code: [Select]
_killer = _this select 1
?side _killer == side player: removeAllWeapons _killer; _killer setdammage .8
exit

I have no idea if .8 is the right value to force a person to crawl.  Also, I don't know if removeAllWeapons gets rid of grenades, satchel charges, etc.  But you get the idea.

BTW, Dinger, sorry about the similarity in names.  This is a name I've used for a while and I registered it before I saw yours.  If it's any consolation, I'm also excited about being able to use braces instead of quotes.  :)

_54th_Yoshi

  • Guest
Re:Event Handlers and MP: Killshooter script
« Reply #4 on: 16 Oct 2002, 00:42:53 »
*To Hamdinger* I think it's .9 to cripple someone.

*To Dinger* Great job Dinger! You solved to holy grail of dealing with the 7 year-old punks that can't kill the other team, so they have to kill their own. Cheers!  :cheers:

Offline SafetyCatch

  • Members
  • *
  • War...it's fantastic!
Re:Event Handlers and MP: Killshooter script
« Reply #5 on: 16 Oct 2002, 00:50:58 »
the thing is there are a lot of players out there setting out to piss people off intentionally
they normally disconnect as soon as they'e killed some1 and that is the most frustrating thing because u cant punish them, or ban them because they change their name and recirculate into the sad world of TKers
thanks
i just thought i might make that comment to make more people aware of the fact that TKers suck

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Event Handlers and MP: Killshooter script
« Reply #6 on: 16 Oct 2002, 02:17:15 »
I didn't do anything other than point out what BIS did.
Heh, Ham, I don't have a lock on the name.
One other thing, youshould probably first check:
?_killer == player:exit

another killshooter variation is to give the shooter the damage the player received, so if I hit a buddy with a stray bullet, he's okay, and I take the bullet (and nobody dies).  That's done this way:
teamkill = player addeventhandler [{Hit}, {_this exec {killshooter.sqs}}]

;Killshooter.sqs
;dinger@raf303.org
_killer = _this select 1
_damage = _this select 2
?_killer == player:exit
?side _killer != side player: exit
player setdammage ((getdammage player) - _damage)
_killer  setdammage ((getdammage player) + _damage)
exit
Dinger/Cfit

HK

  • Guest
Re:Event Handlers and MP: Killshooter script
« Reply #7 on: 20 Dec 2002, 19:46:56 »
@ Dinger thanks for your help man. OK i tried this and there seems to be a problem occuring after respawn, it works ok initially BUT after respawn the problems begin, it seems that your soldier respawns and his name comes up red instead of green thus indicating enemy status. Is there any way to reset this after or during the respawn process to be Friendly again?

Offline CapMorgan

  • Members
  • *
  • OFP fan
    • Cazadores de monte
Re:Event Handlers and MP: Killshooter script
« Reply #8 on: 28 Dec 2002, 18:59:05 »
@ Dinger thanks for your help man. OK i tried this and there seems to be a problem occuring after respawn, it works ok initially BUT after respawn the problems begin, it seems that your soldier respawns and his name comes up red instead of green thus indicating enemy status. Is there any way to reset this after or during the respawn process to be Friendly again?

Im making a script to kill the respawn killers, and had the same problem.
I belive it's because when unit is dead, it's rating is 0 untill it respawn, so when the eventhandler "checks" the side, the result is "CIV".
I solved it putting a name to the group and not using side command.
I still have the problem of inserting again the eventhandler to the dead guy. I can do that by making a trigger with the condition !alive unit, but there must be a better way. i dont want to make a trigger for each unit in the map.
Also, i don't know if this will work in MP because the "killed" eventhandler is local ... :-\  
Any hook will be apreciated


My script so far goes like this

_muerto = _this select 0
_matador = _this select 1

? _muerto in units grpOeste  && _matador in units grpOeste: goto "fin"
? _muerto in units grpEste && _matador in units grpEste: goto "fin"

_linea = "Don't kill in the respwn zone"
? _muerto in units grpOeste  && _muerto in list listaRespOeste: _matador setdammage 1; hint _linea; goto "fin"
? _muerto in units grpEste && _muerto in list listaRespEste: _matador setdammage 1; hint _linea; goto "fin"

#fin
exit

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Event Handlers and MP: Killshooter script
« Reply #9 on: 28 Dec 2002, 22:39:30 »
Ahh, true.
What you need to do is set a variable like PlayerSide = Side player when you load the EH, and use that as your check.
Second, when the player respawns, you need to respawn the EH too.
Third, all EHs are local events. You need to load an EH on each client (for the player).  If you want messages ("you are a bad boy"), you need to have a publicvariable broadcast/monitor system.
I'll see what I can do when I get home in a cupola weeks.
Dinger/Cfit

Offline CapMorgan

  • Members
  • *
  • OFP fan
    • Cazadores de monte
Re:Event Handlers and MP: Killshooter script
« Reply #10 on: 30 Dec 2002, 06:18:38 »
well, here's a new one. I can't add handlers to a respawned unit. Not by script or trigger.
Here's what i have. Works fine first time, but when unit respwns no handler is added. Any hook?

init.sqs
ArrayGlobal = units grpEste + units grpOeste
eventos = true

trigger:
condition: Eventos
on activation:"""_X removeAllEventHandlers {killed}"" foreach ArrayGlobal; ""_x addeventhandler [{killed}, {_this exec {Camper.sqs}}]"" forEach ArrayGlobal; eventos = false;publicVariable ""eventos"""

;script Camper.sqs
_muerto = _this select 0
_matador = _this select 1

? _muerto in units grpOeste  && _matador in units grpOeste: goto "fin"
? _muerto in units grpEste && _matador in units grpEste: goto "fin"

_linea = "Dont kill in respawn"
? _muerto in units grpOeste  && _muerto in list listaRespOeste: _matador setdammage 1; hint _linea; goto "fin"
? _muerto in units grpEste && _muerto in list listaRespEste: _matador setdammage 1; hint _linea; goto "fin"
#fin
Eventos =  true
Publicvariable "eventos"
exit


Nedal

  • Guest
Re:Event Handlers and MP: Killshooter script
« Reply #11 on: 10 Jan 2003, 11:59:06 »
I am not sure, but perhaps the problem is in the Init.Sqs
init.sqs:          ArrayGlobal = units grpEste + units grpOeste
                      eventos = true


the init.sqs runns just one time, when the mission is startet. so everything you set in the init.sqs counts just for all units who are existing when the game starts.
As soon a unit gets respawned, all setings from init.sqs will be lost for this unit.

i think
 ArrayGlobal = units grpEste + units grpOeste
                      eventos = true  
should be in a seperate script (globarrays.sqs) , with a never ending loop, and you start this script in the init.sqs


could this be a solution?


best wishes Oberst Nedal

Offline CapMorgan

  • Members
  • *
  • OFP fan
    • Cazadores de monte
Re:Event Handlers and MP: Killshooter script
« Reply #12 on: 10 Jan 2003, 19:53:21 »
I am not sure, but perhaps the problem is in the Init.Sqs
init.sqs:          ArrayGlobal = units grpEste + units grpOeste
                      eventos = true


the init.sqs runns just one time, when the mission is startet. so everything you set in the init.sqs counts just for all units who are existing when the game starts.
As soon a unit gets respawned, all setings from init.sqs will be lost for this unit.

i think
 ArrayGlobal = units grpEste + units grpOeste
                      eventos = true  
should be in a seperate script (globarrays.sqs) , with a never ending loop, and you start this script in the init.sqs


could this be a solution?


best wishes Oberst Nedal


Thanx for the reply Nedal !!. That's correct, the problem was the array. I get the answer @ the official forum the past week. I solved the problem, but i still don't get why the respawned unit is not in the array if it's still in the gruop.

Nedal

  • Guest
Re:Event Handlers and MP: Killshooter script
« Reply #13 on: 14 Jan 2003, 18:32:05 »
I am working on another way to get this working
but i have to problem, that it is just working for the guy who starts the game (server) not for all the others
If he kills someone in savezone, his weapons will be removed. But if someone else is doing it nothing happens. I dont know why. there is no trigger gamelogic server.

if you want to see or try, you can download the pbo file at
http://www.bikeadventure.ch/ofp/respawnbeta1.Noe.pbo
« Last Edit: 14 Jan 2003, 21:03:57 by Nedal »

Offline CapMorgan

  • Members
  • *
  • OFP fan
    • Cazadores de monte
Re:Event Handlers and MP: Killshooter script
« Reply #14 on: 14 Jan 2003, 19:02:10 »
well, this is what i've done (tested on MP and woprking)

;init.sqs
eventos = true

2 triggers covering each respawn area (west example, you shoul change the act and name for EAST)
rad: your respawn zone
act:west/present
name: ListaRespOeste

1 big trigger covering the entire battlefield
rad: big
act:anyone/present/repet
countdown: 1 second higer than the respanwdelay you setted in de description.ext
condition:eventos
onactivation::"_X removeAllEventHandlers {killed}" foreach thislist; "_x addeventhandler [{killed}, {_this exec {Camper.sqs}}]" forEach thislist; eventos = false; publicVariable "eventos"

Now the script
;;camper.sqs
_muerto = _this select 0
_matador = _this select 1
? _muerto in units grpOeste && _matador in units grpOeste: goto "fin"
? _muerto in units grpEste && _matador in units grpEste: goto "fin"
_linea = "No mates en el Respawn"
? _muerto in units grpOeste && _muerto in list listaRespOeste: _matador setdammage 1; hint _linea; goto "fin"
? _muerto in units grpEste && _muerto in list listaRespEste: _matador setdammage 1; hint _linea; goto "fin"
#fin
Eventos = true
Publicvariable "eventos"
exit

Note: define the name of the groups (grpOeste for west and grpEste for east)