YES when the player dies, remove the eventhandler,
Player removealleventhandlers "killed"
@ alive player
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
however your system has a flaw.
A killed event is a local based event, meaning that the playerkilled.sqs only runs on the machine of the player that got killed, so the camcreate bomb, will only appear on that machine.
Therefore, the only commands that will work on _killer are global commands such as setpos or setdammage etc
if you want to run local commands on the _killer, then you have to do it on the _killer's machine and to do this, the _killer must be told it's him
to do this, we change a variable that is objnull to the _killer object and then publicvariable it
eg
DESCRIPTION.EXT
respawndelay = 0.1
INIT.SQS
;; set the following variable to the respawn delay you want
;; eg in this case 30 seconds
tx_respawntime = 30
;; set the following variable to the respawn delay you want for the spawnkiller
;; eg in this example 120 seconds 92 minutes)
tx_prisontime = 120
tx_PunishMe = false
tx_Killer = objnull
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
?(local player): "" exec spawnkill.sqs
Playerkilled.sqs
#START
?!(local player):exit
_unit = _this select 0
_killer = _this select 1
_kilpos = getpos _unit
_kildir = getdir _unit
_wepArray = weapons _unit
_magArray = magazines _unit
_primary = primaryweapon _unit
_count = 0
cutText ["","Black out",0.001]
player removeAllEventHandlers "killed"
? (Tx_PunishMe) : goto "PUNISH"
;; << NB Protection for victim if in safezone and killed by enemy
? ((_unit in list ESafezone && side _killer == resistance) OR (_unit in list GSafezone && side _killer == EAST)):goto "FASTRESPAWN"
;; << NB Protection for victim if _killer safezone >>
? ((_killer in list ESafezone && side _unit == resistance) OR (_killer in list GSafezone && side _unit == EAST)):goto "FASTRESPAWN"
@ alive player
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
_respawntime = tx_respawntime
titletext[format["%1\nYou have been killed", name player],"PLAIN"]
goto "NORMALRESPAWN"
#FASTRESPAWN
tx_Killer == vehicle _Killer; Publicvariable "tx_Killer"
titletext[format["%1\nYou were illegally killed by \n%2", name player,name _killer],"PLAIN"]
;; << NB find out what weapons the victim had and where he was killed etc >>
removeAllWeapons _unit
@ alive player
removeAllWeapons _unit
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
;; << NB Following code places the illegally killed victim back to the place where he was killed and rearms him with the weapons he had when killed (additional code will be required if the unit was in a vehicle)
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _wepArray
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
player selectWeapon _primary
player setPos _kilpos
player setdir _kildir
cutText ["","Black in",0.001]
exit
#PUNISH
@ alive player
Tx_PunishMe = false
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
titletext[format["%1\nYou are being punished for an illegal kill", name player],"PLAIN"]
_respawntime = tx_prisontime
tx_killer = objnull
goto "NORMALRESPAWN"
#NORMALRESPAWN
_pos = getpos player
cutText ["","Black in",2]
showcinemaborder true
_cam = "camera" camCreate _pos
_cam cameraEffect ["internal", "back"]
_cam camSetTarget player
_cam camSetRelPos [1,1,1.25]
_cam camCommit 0
@camCommitted _cam
~2
#CAMLOOP
_now = _time
#SUBLOOP
?(_time > _respawntime):goto "END"
?(_time > (_now + 5)): titletext[format["Respawning in\n\n%1 secs", (_respawntime - _time)],"PLAIN"] ; goto "CAMLOOP"
goto "SUBLOOP"
#END
cutText ["","Black out",2]
player switchCamera "INTERNAL"
cutText ["","Black in",2]
player cameraeffect ["terminate","back"]
camDestroy _cam
showcinemaborder false
exit
spawnkill.sqs
#START
~0.5
? (player in crew tx_killer): goto "PUNISH"
goto "START"
#PUNISH
tx_killer = objnull
Tx_PunishMe = true
player SetDammage 1
@ alive player
~1
goto "START"
Ok brief rundown
Set your description.ext up, with a 0.1 respawndelay, this will allow the illegally killed victim, to respawn at the place he died at in 0.1 seconds and re-arm him with the weapons he was killed with
(In other words, he will hardly notice he was killed
, whereas the Murderer, will be placed in a cutscene (which acts as the respawn delay, for tx_prisontime
Legally killed units will pass into a cutscene for tx_respawntime
Respawning units will respawn at their respawnmarker as normal, , the victim will then be setpossed to his "killed" location
afaik, this system is the best type of anti spawnkill system i have seen to date
Utilisation of CoC Networks would create a better system
Additional code may have to be added, if the Victim could be a flag carrier or in a vehicle
code is untested, i wrote it on the fly, editing it from some previous code i have, so expect some minor errors
The ECL C&H, CTF, FLAGBALL templates all have a similar system