OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: shameless 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 :)
-
You want to add an event handler to each player.
In each player's init field put:
ndeath = 0 ; this addEventHandler ["KILLED", {[] execVM "onedeath.sqf"}]
Then onedeath.sqf
ndeath = ndeath + 1;
exit;
Then place a trigger on the map with the following condition:
ndeath > 4and on activation:
bigloser = player; publicVariable "bigloser"
One last trigger, condition:
not isNull bigloserIn the on activation put whatever you want to happen when the game ends.
-
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.
-
You might also want to read this old thread (http://www.ofpec.com/forum/index.php?topic=25591.0) on team DM scoring. It was for OFP but it is still valid for ArmA.
-
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:
-
It was the first to achieve 5 kills or the first to die 5 times?
-
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:
-
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.
-
No problems mate :)
The link you gave me is what i went from...
http://www.ofpec.com/forum/index.php?topic=25591.0 (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
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
_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
_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
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
(param1<10000 and ((time >= param1) or (TimeEnd >= param1))) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2)))
the on activation you put
TimeEnd=time; publicVariable "TimeEnd"; player exec "Outro.sqs"
The next trigger is named End
Type is End1
in the condition field you put TrueEnd and in the on activation field you put 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?
-
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
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.
-
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...
TimeEnd=time; publicVariable "TimeEnd"; player exec "Outro.sqs"
Where as it should be ...
TimeEnd=True; publicVariable "TimeEnd"; player exec "Outro.sqs"
And i also have both players named W1 and E1 ;)
-
Okay, so I am presuming the score is displayed correctly in the hint I added, but the game is not ending properly.
Change:
(param1<10000 and ((time >= param1) or (TimeEnd >= param1))) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2))) to
(param1<10000 and time >= param1) or (param2<10000 and ((tx_W1score >=param2) or (tx_E1score >=param2)))and
TimeEnd=time; publicVariable "TimeEnd"; player exec "Outro.sqs"to
PlayOutro=TRUE; publicVariable "PlayOutro"
Add another trigger with condition:
PlayOutroand on activation:
player exec "Outro.sqs"
Leave the END1 trigger as is.
-
Sorted ;)
The problem was the condition on the trigger which triggers once u have reached the score.
(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...
(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: