Home   Help Search Login Register  

Author Topic: score in a deathmatch  (Read 1630 times)

0 Members and 1 Guest are viewing this topic.

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
score in a deathmatch
« on: 05 Mar 2004, 15:17:11 »
I would like to make my deathmatchs automatically end when someone reaches a certain kill score.  Apparently the game doesn't interpret a kill as a score tho.  How can I detect how many kills player"x" has, and end the mission when he has "x"number of kills?

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:score in a deathmatch
« Reply #1 on: 05 Mar 2004, 17:34:22 »
Each Player would need an event handler "Killed" attaching to them


When the event "killed" takes place, the victims client returns an array containing 2 elements

a) 1st element is the victim
b) 2nd element is the killer

The event handler also runs a script of your choice when the event occurs

eg
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]


The following script would then run on the victims client

Code: [Select]
;;Playerkilled.sqs
_victim = _this select 0
_Killer = _this select 1

?(_Killer == _victim): exit
Killer = _Killer; publicvariable "Killer"

The problem is, the "Killer" client doesnt know who he is yet, so we need some way of informing the client who he is.
This is done by issuing the Publicvariable "Killer"

All clients would then need a script that is waiting for "Killer" to be broadcast and a check system, to see if his client is the "Killer"

This is done with the following script

Code: [Select]
_Myscore = 0
_Winningscore = 20
Killer = objNull

#START
~0.5
? (player in crew Killer): goto "NEXT"
goto "START"

#NEXT
_MyScore = _Myscore +1
?(_Myscore >= _Winningscore): goto "END"
Killer = objNull
goto "START"

#END
Winnername = Name Player
Iamwinner = true
{PublicVariable _x;}foreach["Winnername","Iamwinner"]
exit

The "Killer" has now added a point to the variable "_Myscore"
If "_Myscore" was equal to or greater than the score for which a player must achieve to win (_Winningscore)
Then he will declare the Endmission Boolean "IAMWINNER" which you can have a trigger waiting for to become true and thus cause an additional script to run on all clients which will inform them that there is a winner and who has won before shutting the mission down

using a titletext message

eg

titletext[format["%1 \nIs the winner",Winnername],"PLAIN"]



You will need to have a respawning script that will add the "Killed" event handler to the player each time he respawns

You will need to change the value of
_Winningscore
to the amount of kills you need to win)


Think thats it, that should work for ya


« Last Edit: 05 Mar 2004, 17:36:18 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:score in a deathmatch
« Reply #2 on: 05 Mar 2004, 19:34:07 »
fantastic!  that's what I was looking for.  Gonna try it out

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:score in a deathmatch
« Reply #3 on: 06 Mar 2004, 00:36:47 »
ok we just playtested on a dedicated server and it doesn't work.  Here is what I did:

;;respawn.sqs
?(local server):exit
~0.5
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

#START
@!alive player
player removeAllEventHandlers "killed"

@alive player
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

goto "START"

;;init.sqs
[]exec "randomtime.sqs"
[]exec "timer.sqs"
[]exec "RandomWeather.sqs"
[]exec "build.sqs"
[]exec "ratings.sqs"
[]exec "purge.sqs"
? !(local server): [] exec "respawn.sqs"
~8
#End
Exit

----part of description.ext
titleParam1 = "Score to win:";
valuesParam1[] =
{10,20,30,40,50,60,70,80,90,100};
defValueParam1 = 50;
textsParam1[] = {"10","20","30","40","50","60","70","80","90","100"};

;;playerkilled.sqs
_victim = _this select 0
_killer = _this select 1

?(_killer == _victim): exit
killer = _killer; publicvariable "killer"

_myscore = 0
_winningscore = param1
killer = objnull

#start
~0.5
? (player in crew killer): goto "next"
goto "start"

#next
_myscore = _myscore + 1
?(_myscore >= _winningscore): goto "end"
killer = objnull
goto "start"

#end
winnername = name player
iamwinner = true
{publicvariable _x;}foreach["winnername","iamwinner"]
exit

and a trigger
type end#2
condition iamwinner
on activation forceend

Seems like it should work but alas......


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:score in a deathmatch
« Reply #4 on: 07 Mar 2004, 16:26:22 »
Myfault, i used local variables in the playerkilled.sqs, and restated the starting value which will never allow the _myscore to be greater than 1

to fix

ADD the blue text
REMOVE the red text


ok we just playtested on a dedicated server and it doesn't work.  Here is what I did:

;;respawn.sqs
?(local server):exit
~0.5
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

#START
@!alive player
player removeAllEventHandlers "killed"

@alive player
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

goto "START"

;;init.sqs
Myscore = 0
Winningscore = Param1

[]exec "randomtime.sqs"
[]exec "timer.sqs"
[]exec "RandomWeather.sqs"
[]exec "build.sqs"
[]exec "ratings.sqs"
[]exec "purge.sqs"
? !(local server): [] exec "respawn.sqs"
~8
#End
Exit

----part of description.ext
titleParam1 = "Score to win:";
valuesParam1[] =
{10,20,30,40,50,60,70,80,90,100};
defValueParam1 = 50;
textsParam1[] = {"10","20","30","40","50","60","70","80","90","100"};

;;playerkilled.sqs
_victim = _this select 0
_killer = _this select 1

?(_killer == _victim): exit
killer = _killer; publicvariable "killer"

_myscore = 0
_winningscore = param1

killer = objnull

#start
~0.5
? (player in crew killer): goto "next"
goto "start"

#next
_myscore = _myscore + 1
?(_myscore >= _winningscore): goto "end"

myscore = _myscore + 1
?(myscore >= winningscore): goto "end"

killer = objnull
goto "start"

#end
winnername = name player
iamwinner = true
{publicvariable _x;}foreach["winnername","iamwinner"]
exit

Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:score in a deathmatch
« Reply #5 on: 09 Mar 2004, 15:49:16 »
OK, that's an improvement, but it still doesn't count correctly.  1 game ended at 46, another at 52 and another at 56 when the winning score was set to 50, and at 14 when set to 10.  Could a doublekill be the cause of inaccurate counting?  I would send you my mission, but it is quite a bit larger than the 50K limit here! ;)
You are probably familiar with Tequila Sunset, and that is the "Base" of my work I am trying to modify.  If you are interested, you can go to the USI Matching Server 1.96 to get a copy of the mission I I have modded thus far, Tequila Sundown USI refit.
  Anyway, I do appreciate your assistance thus far, I am certain there is just 1 small something somewhere that will make this work, but it completely eludes me! ;D

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:score in a deathmatch
« Reply #6 on: 11 Mar 2004, 13:15:40 »
Another boob im my syntax, sorry



Quote
#next

myscore = _myscore + 1
myscore = myscore + 1
?(myscore >= winningscore): goto "end"
killer = objnull
goto "start"

replace red line with blue line.

_myscore  should have been myscore
« Last Edit: 11 Mar 2004, 13:16:33 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:score in a deathmatch
« Reply #7 on: 11 Mar 2004, 16:21:19 »
Actually, I caught that when I was typing the file, and entered it correctly.  I have found 2 potential "problems" tho:
;;respawn.sqs
?(local server):exit
~0.5
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

#START
@!alive player
player removeAllEventHandlers "killed"

@alive player
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

goto "START"

;________________________
;::::::::::::::::::::::::
;playerkilled.sqs
;keeps track of score in a dm
;author terox
;created 3/5/04 1:45:54 PM
;________________________
;::::::::::::::::::::::::

_victim = _this select 0
_killer = _this select 1

?(_killer == _victim): exit
killer = _killer; publicvariable "killer"

killer = objnull

#start
~0.5
? (player in crew killer): goto "next"
goto "start"

#next
myscore = myscore + 1
?(myscore >= winningscore): goto "end"
killer = objnull
goto "start"

#end
winnername = name player
iamwinner = true
{publicvariable _x;}foreach["winnername","iamwinner"]
exit

Could those ~0.5 delays cause an inaccurate count if the "killer" dies at the same time as the victim, or nearly so?  You know how dm's can be with a lot of doublekills.  The mission does end automatically, but the count is not accurate
« Last Edit: 11 Mar 2004, 16:23:52 by Zombie »