the event "Hit" triggers a script that is run locally on the "Victims" client
The event also automatically creates an array with two elements
these are
_this select 0 which is the _victim
_this select 1 which is the _shooter
In the system that i have running, I "_shooter setdammage 1" from the victims script, which obviously kills the _shooter
The shooter then enters a respawn phase, using a script on his machine.
My problem is, i need to let the _shooter know he is the _shooter, so that i can put him into a punishhment loop
here is the script that is run on the clients "_victim machine" when the "Hit" event is triggered
****************************************************************
;;spawnkill.sqs
;; the following 2 lines stops multiple events caused by splash damage from triggering the script again
?(hitdetectactive):exit
hitdetectactive = true
;;Hint "Debug:spawnkill.sqs activated"
_victim = _this select 0
_shooter = _this select 1
?(_shooter in list safezone_west OR _shooter in list safezone_east OR _victim in list safezone_west OR _victim in list safezone_east): goto "next"
;;following line allows victim to immediately respawn in "respawn.sqs"
fastrespawn = false
goto "End"
#next
Hint "Illegal kill detected"
fastrespawn = true
_shooter = shooter: Publicvariable "Shooter"
_shooter setDammage 1
;;_shooter setviewdistance 500
~0.2
?!alive _victim:goto "end"
_victim setDammage 0
fastrespawn = false
#end
hitdetectactive = false
exit
*****************************************************************
If the victim is only wounded he is repaired, if he is killed, he then enters into the respawn.sqs, the _shooter automatically enters into the "respawn.sqs" in the event of any hitdamage to the _victim
*****************************************************************
;;respawn.sqs
@time > 1
player addEventHandler ["hit", {_this exec "spawnkill.sqs"}]
player addrating 10000
;;Remove following weaponsarray when Pimm has Armoury selection done and add "removeallweapons player"
;;removeAllWeapons player
_weapArray = weapons player
_magArray = magazines player
_primary = primaryweapon player
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
#START
@!alive player
player removeAllEventHandlers "hit"
_kilpos = getpos player
_kildir = getdir player
_kilposweapArray = weapons player
_kilposmagArray = magazines player
_kilprimary = primaryweapon player
?(_kilprimary == "M16GrenadeLauncher"): _kilprimary = "M16Muzzle"
?(_kilprimary == "Ak74GrenadeLauncher"): _kilprimary = "AK74Muzzle"
?(_kilprimary == "Ak47GrenadeLauncher"): _kilprimary = "AK47Muzzle"
@alive player
hint "adding eventhandler"
player addEventHandler ["hit", {_this exec "spawnkill.sqs"}]
removeAllWeapons player
?(fastrespawn):goto "Fastrespawn"
#SLOWRESPAWN
_pos = getpos player
;; Remove all weapon statements when Pimm has armoury select working
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray
player selectWeapon _primary
showcinemaborder true
_camera = "camera" camCreate _pos
_camera cameraEffect ["external", "back"]
_camera camSetTarget player
_camera camSetRelPos [0,1,2]
_camera camCommit 0
@camCommitted _camera
_count = 0
#LOOP
~1
_count = _count + 1
;;The following line is where i want the client to check if he is the _shooter
;; ?(player == Killer):goto "Punish"
;; ?(setviewdistance== 500):goto "Punish"
?(_count >= respawntime): goto "KILLCAM"
goto "LOOP"
#PUNISH
;; Delays the _shooter (Killer) in the cutscene for a longer period
titletext[format["%1\nYou are being punished for an illegal Kill", name player],"PLAIN"]
~1
setviewdistance 700
_count = _count + 1
?(_count == (prisontime - 60)): titletext[format["%1\nYou will be freed in 1 minute", name player],"PLAIN DOWN"]
?(_count >= prisontime):hint "Play On War Criminal"; goto "KILLCAM"
goto "PUNISH"
#kILLCAM
;; Kills the cam freezing the player, allows him back into game
player cameraeffect ["terminate","back"]
camDestroy _camera
showcinemaborder false
goto "START"
#FASTRESPAWN
;; instant respawn if player is _victim of illegal kill
;; also rearms him with weapons he was killed with
{player addMagazine _x} forEach _kilposmagArray
{player addWeapon _x} forEach _kilposweapArray
player selectWeapon _kilprimary
player setPos _kilpos
player setdir _kildir
fastrespawn = false
goto "START"
******************************************************************
The description.ext
respawn = 3
respawndelay = 0.5
The respawn script holds a player in a freeze condition to create a type of respawn while they view a cutscene
This obviously requires a public variable being broadcast.
I tried
_Shooter = Shooter; Publicvariable "Shooter" in the spawnkill.sqs
and then had the server run the following script
?!(local server):exit
#start
@!isNull shooter
killer = shooter; publicvariable "killer"
shooter = objnull
goto "start"
and in the respawn.sqs i had the line
?(player == Killer):goto "punish"
but it didnt work.
I also thought that if the _victim client can setdammage 1 to the _shooter
Then why cant it also setviewdistance 500 to the _shooter, then this way i could run a
?(setviewdistance == 500) to pick it up, but this didnt work