Home   Help Search Login Register  

Author Topic: How do I do a Deathcount?  (Read 1553 times)

0 Members and 1 Guest are viewing this topic.

Olle Stolpe

  • Guest
How do I do a Deathcount?
« on: 26 Feb 2005, 13:15:56 »
Hey guys. I moved this thead here...

I'm trying to make a dynamic mission (similar to LoJack).
I want to put a number in a variable every time a player is killed and then
have different messages at the end according to the amount of deaths.

Like this:

IF <a player is killed> THEN publicdeathvar = publicdeathvar + 1

at the end:

IF publicdeathvar = 0 THEN END#1
IF publicdeathvar < 3 THEN END#2
IF publicdeathvar > 3 THEN END#3

Excuse my quasisyntax, but I think you get the idea..
The mission is MP and has 4 slots (names of player Units is p1,p2,p3,p4)
HELP PLEASE!!!!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:How do I do a Deathcount?
« Reply #1 on: 27 Feb 2005, 22:21:27 »
do the following

1) addeventhandler killed to the player
2) have the eventhandler run a script
3) have the script update a global variable
4) when you want the mission to end, run an outro.sqs
5) have the outro script run your messages
6) have the outro script initiate a boolean which will activate your end trigger

INIT.sqs
Quote
player addEventHandler ["killed", {_this exec "myrespawn.sqs"}]
tx_deaths = 0

myrespawn.sqs
Quote
player removeAllEventHandlers "Killed"
tx_deaths = tx_deaths + 1

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

Outro.sqs
Quote
? (tx_deaths >3): goto "BAD"
? (tx_deaths >0): goto "GOOD"

#EXCELLENT
;; add your titletext message here
goto "END"

#GOOD
;; add your titletext message here

goto "END"

#BAD
;; add your titletext message here
goto "END"

#END
;; have your endmission trigger wait on condition "tx_endmission"
tx_endmission = true
exit
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Olle Stolpe

  • Guest
Re:How do I do a Deathcount?
« Reply #2 on: 27 Feb 2005, 23:58:01 »
Wow, thanks alot mate! Amazing.

But will this work for MP?
Won't I need to use Public variables.
It seems to me, who is a complete newbie on this, that this will only
execute itself on the local machine.

Would it be enough to do this?

Code: [Select]
player removeAllEventHandlers "Killed"
tx_deaths = tx_deaths + 1
PublicVariable "tx_deaths"

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


Am I out of line?

Thank you so much again, for your help.
« Last Edit: 28 Feb 2005, 00:01:28 by Olle Stolpe »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:How do I do a Deathcount?
« Reply #3 on: 02 Mar 2005, 01:29:33 »
Wow, thanks alot mate! Amazing.

But will this work for MP?
Won't I need to use Public variables.
It seems to me, who is a complete newbie on this, that this will only
execute itself on the local machine.

Would it be enough to do this?

Code: [Select]
player removeAllEventHandlers "Killed"
tx_deaths = tx_deaths + 1
PublicVariable "tx_deaths"

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


Am I out of line?

Thank you so much again, for your help.


if you public variable tx_deaths, then all computers will have the same value for tx_deaths.

I took it that you wanted the number of times a player was killed to be incremented, so that each player would get different messages.


In your system if:

Player A dies 3 times. tx_deaths = 3

However if Player B is the last player to die, but he only dies once, then tx_deaths = 1
Public variable this value and it overwrites all previous values for this variable


thew only think you would need to PV is perhaps a boolean in a script that you would use to run the outro.sqs


*********************************************************
Variables

_myvariable
This is a local variable, which means it is only used by a script when the script is running. When the script exits, this variable is deleted from memory

myvariable
This is a global variable. It is always resident in memory and can be called for by any script at any time. The value for this variable is only known on the computer that is using it

myvariable; Publicvariable "myvariable"
This is a public variable.
What it actually is, is a global variable, who's value you want to transmit to all other computers, which will overwrite their stored value


The questions you need to ask when scripting are

1) Does i want to use this value outside this script
answer = NO, use a local variable
answer = YES, use a global variable

2) Having decided that i need to call on a variable from more than one script and therefore i need a global variable:
Do other computers need to know this value
answer = No, stick with global
answer = yes, transmit the global variable, using the publicvariable command, when other machines need to know it.


I hope i didnt go over the top with my explanation
« Last Edit: 02 Mar 2005, 01:38:53 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123