Home   Help Search Login Register  

Author Topic: Scoring system?  (Read 3205 times)

0 Members and 1 Guest are viewing this topic.

Offline shameless

  • Members
  • *
Scoring system?
« on: 04 May 2007, 01:35:34 »
Hi guys :)

Im trying to make a 1on1 sniper DM, but i need a scoring system of some sort. Unlike other DM's where you can set a time limit, I want to set a score limit to end the game, so it means the player wining at the time cant run and hide/camp.

I want to make it best to 5 kills, so once a player reaches 5 kills the game ends. What is the best way of setting this up?

Thanks :)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scoring system?
« Reply #1 on: 04 May 2007, 03:00:49 »
You want to add an event handler to each player.
In each player's init field put:
Code: [Select]
ndeath = 0 ; this addEventHandler ["KILLED", {[] execVM "onedeath.sqf"}]
Then onedeath.sqf
Code: [Select]
ndeath = ndeath + 1;
exit;

Then place a trigger on the map with the following condition:
Code: [Select]
ndeath > 4and on activation:
Code: [Select]
bigloser = player; publicVariable "bigloser"
One last trigger, condition:
Code: [Select]
not isNull bigloserIn the on activation put whatever you want to happen when the game ends.
urp!

Offline shameless

  • Members
  • *
Re: Scoring system?
« Reply #2 on: 04 May 2007, 03:18:15 »
Thank you very much  :good:

I was pulling my hair out with try to work out how all the other maps do it, and you way seems ALOT easier lol.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scoring system?
« Reply #3 on: 04 May 2007, 03:55:56 »
You might also want to read this old thread on team DM scoring. It was for OFP but it is still valid for ArmA.
urp!

Offline shameless

  • Members
  • *
Re: Scoring system?
« Reply #4 on: 04 May 2007, 05:56:09 »
Ah yes that is much better :)

I did try searching for a scoring system but nothing came up  ???

Thanks for your help Mr Peanut  :clap:

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Scoring system?
« Reply #5 on: 04 May 2007, 10:16:11 »
It was the first to achieve 5 kills or the first to die 5 times?

Offline shameless

  • Members
  • *
Re: Scoring system?
« Reply #6 on: 04 May 2007, 15:26:50 »
Well it is a 1on1 so first to 5 kills. But with the last post from Mr Peanut i managed to chop and change it around a little bit :) Because now i can use this scoring system as a template for other Deathmatches i make :clap:

With the first post from Mr Peanut, im not sure if i was doing something wrong but it wasn't working  :scratch:
« Last Edit: 04 May 2007, 15:29:23 by shameless »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scoring system?
« Reply #7 on: 04 May 2007, 17:33:50 »
The reason I counted deaths instead of kills is because the killed event handler fires on the machine of the person killed, and I wanted the simplest implementation possible for pedagogic reasons. I did not take suicide or traffic accidents into account. I wish a dual processor so I could test MP issues myself.

If you have something that now works, please post it here so others can also benefit, especially if the code I posted is wrong. Thanks.
« Last Edit: 04 May 2007, 17:37:45 by Mr.Peanut »
urp!

Offline shameless

  • Members
  • *
Re: Scoring system?
« Reply #8 on: 04 May 2007, 18:13:48 »
No problems mate :)

The link you gave me is what i went from...

http://www.ofpec.com/forum/index.php?topic=25591.0

Although i did what you just said you wanted to do, by testing in Mp with 2 ArmA's running...

Last night it worked for some reason but now its not im stuck :(

This is how ive set my scoring system up... Although i cant see where my problems lie's :( do i need to make anymore triggers? or add anymore code?

Init.sqs
Code: [Select]
tx_Wkills = 0
tx_Ekills = 0

tx_W1score = 0
tx_E1score = 0

TimeEnd=0

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

playerkilled.sqs
Code: [Select]
_victim = _this select 0
_killer = _this select 1
_side = side _killer
player removeEventhandler ["killed",tx_kill]
if(side _victim == _side)then{hint "teamkill occurred";exit}
goto (format ["%1", _side])


#EAST
if (name _killer == name E1)then {tx_E1score = tx_E1score + 1;tx_Ekills = tx_Ekills + 1; {Publicvariable _x}foreach ["tx_E1score","tx_Ekills"]}
goto "END"

#WEST
if (name _killer == name W1)then {tx_W1score = tx_W1score + 1;tx_Wkills = tx_Wkills + 1; {Publicvariable _x}foreach ["tx_W1score","tx_Wkills"]}
goto "END"

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

Outro.sqs
Code: [Select]
_Winner = 0
_message = ""
if(tx_Wkills > tx_Ekills)then{_winner = 1}else{_winner = 2}
if(tx_Wkills == tx_Ekills)then{_winner = 0}

?(_winner == 0): goto "DRAW"
?(_winner == 1): goto "WWins"
?(_winner == 2): goto "EWins"

#DRAW

~7

TrueEnd=true
exit

#WWins

hint formaT [ "___ FINAL OUTCOME ___\n\n%1",_message]

_W1 = format ["\n%1 had %2 kills",name W1,tx_W1score]
_E1 = format ["\n%1 had %2 kills",name E1,tx_E1score]

hint formaT [ "___ INDIVIDUAL SCORES ___\n%1%2%3%4",_W1,_E1]

~7

TrueEnd=true
exit

#EWins

hint formaT [ "___ FINAL OUTCOME ___\n\n%1",_message]
_W1 = format ["\n%1 had %2 kills",name W1,tx_W1score]
_E1 = format ["\n%1 had %2 kills",name E1,tx_E1score]


hint formaT [ "___ INDIVIDUAL SCORES ___\n%1%2%3%4",_W1,_E1]
~7

TrueEnd=true
exit

Description.ext
Code: [Select]
titleParam1 = "Time:";
valuesParam1[] = {10000, 300, 600, 900, 1200, 1500, 1800, 2700, 3600, 7200};
defValueParam1 = 1800;
textsParam1[] = {"Unlimited", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min", "45 min", "1 hour", "2 hours"};

titleParam2 = "Score to win:";
valuesParam2[] = {10000, 5, 7, 10, 15, 20, 25, 30};
defValueParam2 = 5;
textsParam2[] = {"Unlimited", 5, 7, 10, 15, 20, 25, 30};

You also need to create some triggers for your map

first one is called Scorelimit which when the score that is set at the start of the mission is reached then this is called and ends the DM

In the condition filed you put
Code: [Select]
(param1<10000 and ((time >= param1) or (TimeEnd >= param1))) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2)))
the on activation you put
Code: [Select]
TimeEnd=time; publicVariable "TimeEnd"; player exec "Outro.sqs"
The next trigger is named End

Type is End1
in the condition field you put
Code: [Select]
TrueEnd and in the on activation field you put
Code: [Select]
ForceEnd

Any ideas?

Btw does it make a difference if i have blank lines in the init.sqs? or should i put ; in the blank lines?
« Last Edit: 04 May 2007, 18:22:20 by shameless »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scoring system?
« Reply #9 on: 04 May 2007, 21:46:51 »
Blank lines are fine.

It would help if you could elaborate on what is not working. Is the score wrong? Does the game not end?

Put the following in the playerkilled script between the #END and the @alive player
Code: [Select]
hint format ["East: %1,%2\nWest: %3,%4",tx_E1score,tx_Ekills,tx_W1score,tx_Wkills]
This will help to debug. When a player gets killed he should see the new scores.

And don't forget,  your two players must be named E1 and W1 for your code to work.
« Last Edit: 04 May 2007, 21:55:18 by Mr.Peanut »
urp!

Offline shameless

  • Members
  • *
Re: Scoring system?
« Reply #10 on: 04 May 2007, 22:40:23 »
Sorry mate i thought i did  :-[

Well nothing happens when you reach the score.

Although i have spoken to another guy and he said the line i put in the condition of the trigger has an error...

Code: [Select]
TimeEnd=time; publicVariable "TimeEnd"; player exec "Outro.sqs"
Where as it should be ...


Code: [Select]
TimeEnd=True; publicVariable "TimeEnd"; player exec "Outro.sqs"
And i also have both players named W1 and E1 ;)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scoring system?
« Reply #11 on: 05 May 2007, 21:31:07 »
Okay, so I am presuming the score is displayed correctly in the hint I added, but the game is not ending properly.
Change:
Code: [Select]
(param1<10000 and ((time >= param1) or (TimeEnd >= param1))) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2))) to
Code: [Select]
(param1<10000 and time >= param1) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2)))and
Code: [Select]
TimeEnd=time; publicVariable "TimeEnd"; player exec "Outro.sqs"to
Code: [Select]
PlayOutro=TRUE; publicVariable "PlayOutro"
Add another trigger with condition:
Code: [Select]
PlayOutroand on activation:
Code: [Select]
player exec "Outro.sqs"

Leave the END1 trigger as is.

« Last Edit: 05 May 2007, 21:36:29 by Mr.Peanut »
urp!

Offline shameless

  • Members
  • *
Re: Scoring system?
« Reply #12 on: 06 May 2007, 17:43:59 »
Sorted ;)

The problem was the condition on the trigger which triggers once u have reached the score.

Code: [Select]
(param1<10000 and ((time >= param1) or (TimeEnd >= param1))) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2)))
I changed it to what you put Mr Peanut...

Code: [Select]
(param1<10000 and time >= param1) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2)))
Tested and it fixed the error :)

Thanks again  :good: