Page 1 of 2
Adding up Scores??
Posted: Wed Mar 07, 2007 2:07 am
by SniperWolf
Is it possible to gather the Scores for a certain range?? I have it so it prints the point values of different parts of the targets on screen. Is there some kind of variable to get it to print with the time I get on the range??
Right now when I finish a range it prints:
"I finish the Rifle Range in 15.000 Seconds"
What I would like to do is to get it to print this:
"I finished the Rifle Range in 15.000 Seconds with a score of 30"
One pass threw my Rifle Range has you shooting at 3 different targets to get a Score. Each target has 11 different areas that can be shot to get a score ranging from 10 pts to 2 pts.
How would I pull the info from all 3 targets & have it add them together for a total score?
So if I went threw the range & hit 2 targets in the head & 1 in the chest that would add to 28 pts
I would need the script to do this:
target 1 score + target 2 score + target 3 score = Overall Rifle Range Score
Is it at possible?
Posted: Wed Mar 07, 2007 3:14 am
by ViPER
Yes it can be done, I just don't know how to do it well. can track players scores but im not sure how to handle people coming and going from the server after its started.
I will post something I use from RicHard and maybe someone can help with the tracking business. Give me a day or two im trying to release my next set of maps.

Posted: Wed Mar 07, 2007 12:14 pm
by SniperWolf
Thanks Viper, take your time.
Posted: Wed Mar 07, 2007 8:52 pm
by ViPER
here goes (some help needed)
after main -
thread idplayer
Code: Select all
idplayer:
local.player = parm.other
local.id = waitthread trooperId local.player
end
trooperId local.player:
if ( $player == NULL )
{
end
}
for ( local.id = 1; local.id <= $player.size; local.id++ )
{
if ( $player[ local.id ] == local.player )
{
end local.id
}
}
end
above code
players coming and going from the server will change the order of score tracking. Maybe someone can help here ?
and below
not sure how your triggers to be added at local.stat
at the score event -
thread targetcount local.trooper
Code: Select all
targetcount local.trooper:
local.player = local.trooper
local.id = waitthread playerkingId local.player
if (level.targetscore$player[local.id] == NIL)
{
level.targetscore$player[local.id] = 0
}
level.targetscore$player[local.id] ++
local.stat = (level.target_trigger1 + level.target_trigger2 + level.target_trigger3) // not sure how your triggers can be added but do it here
if(level.targetscore$player[local.id] == 1)
{
local.player stufftext ("say " + "My first hit! " + " I have " + local.stat + " points")
}
else
{
local.player stufftext ("say " + " I got " + level.targetscore$player[local.id] + " hits!" + " totalling " + local.stat + " points")
}
end
local
Posted: Wed Mar 07, 2007 10:20 pm
by tltrude
Well, the first thing I see wrong is the idplayer thread will not know who "local.player" is. You need a trigger at the enterance of the target range with a setthread. A welcome message can comfirm the player's id.
By the way, I think players are automattically assigned id numbers when they enter a map. But, I don't remember how it works -- it is probably a cvar.
Posted: Wed Mar 07, 2007 10:35 pm
by ViPER
ah yes - idplayer is actually catching all players who enter the server but entrance trigger would be better and minimize potential tracking issues for those coming and going to the server.
so thread idplayer from new trigger setthread rather then after main.
health
Posted: Wed Mar 07, 2007 11:36 pm
by tltrude
Also, did you know you can read the health (damage) of a trigger_multiple? Here is an example from my "gotterdammerung" map script.
Code: Select all
missle_feedback:
local.originalhealth = $missle_ex_trigger.health
local.previoushealth = $missle_ex_trigger.health //initialize
while (1)
{
if !(isAlive $missle_ex_trigger)
{
end
}
if ($missle_ex_trigger.health < local.previoushealth)
{
local.misslefraction = ($missle_ex_trigger.health / local.originalhealth) * 100
local.misslefractioninteger = int local.misslefraction
local.previoushealth = $missle_ex_trigger.health
level.misslehealth = local.misslefractioninteger
}
wait .1
}
end
In that example, the trigger was given a Key/Value health/800. But you can set, and reset, health in the script too. The fraction stuff was used to continuously print a percentage of the missle's health (level.misslehealth).
Posted: Thu Mar 08, 2007 4:55 am
by SniperWolf
Well there is already at the Range Entrance, the Timer Trigger is there but I could always add another if need be. Also the 11 trigger_multiples for each target have different targetnames, example: ltarget_trigger1, ltarget_trigger2 ect. Though some of the triggers are worth the same point values.
I'll try anything once, even twice if need be
So just let me know what I need to try & I'll give it a shot. And it doesn't matter to me who helps out, any help is greatly appreciated.
Posted: Sat Mar 10, 2007 7:36 am
by ViPER
Not sure where you are at here? I think you just need to plug in the script i posted. thread it from a new trigger at the entrance like tom said and define the local.stat value of all the triggers.
Posted: Sat Mar 10, 2007 1:13 pm
by SniperWolf
How & where would I define all local.stat values of all the triggers?
Posted: Sat Mar 10, 2007 6:34 pm
by ViPER
you said three targets? - for each trigger you need to add a line. Make a var for each target - thats three i think and you said 11? triggers for each target?
init them when the start trigger is activated -
Code: Select all
level.target_trigger1 = 0
level.target_trigger2 = 0
level.target_trigger2 = 0
in each trigger put a line like - (I think this is what Tom was talking about )
Code: Select all
level.target_trigger1 = level.target_trigger1 +5
or whatever the point value is. use the same line for all 11 triggers changing the point value accordingly.
then this line will work i think -
Code: Select all
local.stat = (level.target_trigger1 + level.target_trigger2 + level.target_trigger3) // not sure how your triggers can be added but do it here
i think lol.
Posted: Sun Mar 11, 2007 12:36 am
by SniperWolf
Viper, do you mean like this to init all the triggers like this?? And if this is right, where do I put it?? Main map script??
Code: Select all
//*** Left Rifle Target
level.ltarget_trigger1 = 0
level.ltarget_trigger2 = 0
level.ltarget_trigger3 = 0
level.ltarget_trigger4 = 0
level.ltarget_trigger5 = 0
level.ltarget_trigger6 = 0
level.ltarget_trigger7 = 0
level.ltarget_trigger8 = 0
level.ltarget_trigger9 = 0
level.ltarget_trigger10 = 0
level.ltarget_trigger11 = 0
I mapped in the new trigger at the Rifle Range Entrance & added the following code to my map script.
Code: Select all
idplayer:
local.player = parm.other
local.id = waitthread trooperId local.player
end
trooperId local.player:
if ( $player == NULL )
{
end
}
for ( local.id = 1; local.id <= $player.size; local.id++ )
{
if ( $player[ local.id ] == local.player )
{
end local.id
}
}
end
I'm a little confused on where this part is to go:
Code: Select all
targetcount local.trooper:
local.player = local.trooper
local.id = waitthread playerkingId local.player
if (level.targetscore$player[local.id] == NIL)
{
level.targetscore$player[local.id] = 0
}
level.targetscore$player[local.id] ++
local.stat = (level.target_trigger1 + level.target_trigger2 + level.target_trigger3) // not sure how your triggers can be added but do it here
if(level.targetscore$player[local.id] == 1)
{
local.player stufftext ("say " + "My first hit! " + " I have " + local.stat + " points")
}
else
{
local.player stufftext ("say " + " I got " + level.targetscore$player[local.id] + " hits!" + " totalling " + local.stat + " points")
}
end
And where exactly do you mean when you say to add this line to the triggers?? Key/Value it in or something different.
Code: Select all
level.target_trigger1 = level.target_trigger1 +5
Posted: Sun Mar 11, 2007 4:05 am
by ViPER
SniperWolf wrote:Viper, do you mean like this to init all the triggers like this?? And if this is right, where do I put it?? Main map script??
Code: Select all
//*** Left Rifle Target
level.ltarget_trigger1 = 0
level.ltarget_trigger2 = 0
level.ltarget_trigger3 = 0
level.ltarget_trigger4 = 0
level.ltarget_trigger5 = 0
level.ltarget_trigger6 = 0
level.ltarget_trigger7 = 0
level.ltarget_trigger8 = 0
level.ltarget_trigger9 = 0
level.ltarget_trigger10 = 0
level.ltarget_trigger11 = 0
No, i think you just need one var for each 11 triggers - they total 33 right?
put this line in each of the 11 trigers for each of 3 targets -
level.target_trigger1 = level.target_trigger1 +5 //or whatever pointvalue
then this one in each trigger for target 2
level.target_trigger2 = level.target_trigger2 +5 //or whatever pointvalue
then this one in each trigger for target 3
level.target_trigger3 = level.target_trigger3 +5 //or whatever pointvalue
I mapped in the new trigger at the Rifle Range Entrance & added the following code to my map script.
Code: Select all
idplayer:
local.player = parm.other
local.id = waitthread trooperId local.player
end
trooperId local.player:
if ( $player == NULL )
{
end
}
for ( local.id = 1; local.id <= $player.size; local.id++ )
{
if ( $player[ local.id ] == local.player )
{
end local.id
}
}
end
I'm a little confused on where this part is to go:
after main endCode: Select all
targetcount local.trooper:
local.player = local.trooper
local.id = waitthread playerkingId local.player
if (level.targetscore$player[local.id] == NIL)
{
level.targetscore$player[local.id] = 0
}
level.targetscore$player[local.id] ++
local.stat = (level.target_trigger1 + level.target_trigger2 + level.target_trigger3) // not sure how your triggers can be added but do it here
if(level.targetscore$player[local.id] == 1)
{
local.player stufftext ("say " + "My first hit! " + " I have " + local.stat + " points")
}
else
{
local.player stufftext ("say " + " I got " + level.targetscore$player[local.id] + " hits!" + " totalling " + local.stat + " points")
}
end
And where exactly do you mean when you say to add this line to the triggers?? Key/Value it in or something different.
Code: Select all
level.target_trigger1 = level.target_trigger1 +5
answered above
Posted: Sun Mar 11, 2007 4:17 am
by SniperWolf
Like This:
Code: Select all
//*** Rifle Range Targets
//*** Left Target
thread ltarget1_triggered
ltarget1_triggered:
level.target_trigger1 = 0 // added this line
level.target_trigger1 = level.target_trigger1 +10 // added this line
local.player = parm.other
local.player stufftext "say I Scored 10 Points On The Left Target."
$ltarget1 hide
for (local.i = 1; local.i <= 11; local.i++)
$("ltarget_trigger" + local.i) nottriggerable
wait 10
$ltarget1 show
for (local.i = 1; local.i <= 11; local.i++)
$("ltarget_trigger" + local.i) triggerable
end
thread ltarget2_triggered
ltarget2_triggered:
level.target_trigger2 = 0 // added this line
level.target_trigger2 = level.target_trigger2 +10 //or whatever pointvalue
local.player = parm.other
local.player stufftext "say I Scored 10 Points On The Left Target."
$ltarget2 hide
for (local.i = 1; local.i <= 11; local.i++)
$("ltarget_trigger" + local.i) nottriggerable
wait 10
$ltarget2 show
for (local.i = 1; local.i <= 11; local.i++)
$("ltarget_trigger" + local.i) triggerable
end
And like the for after main end??
// Clan ?{T?F}? Boot Camp
// ARCHITECTURE: ?{T?F}??niperWolf
// SCRIPTING: ?{T?F}??niperWolf ( Minor Scripting)
// SCRIPTING: <TWL> Viper (Timer Scripts)
main:
//*** set scoreboard messages
setcvar "g_obj_alliedtext1" " Clan ?{T?F}?"
setcvar "g_obj_alliedtext2" " Boot Camp "
setcvar "g_obj_alliedtext3" " By "
setcvar "g_obj_axistext1" " ?{T?F}??niperWolf"
setcvar "g_obj_axistext2" " Timer Scripts"
setcvar "g_obj_axistext3" " By <TWL> Viper"
setcvar "g_scoreboardpic" "none"
targetcount local.trooper:
local.player = local.trooper
local.id = waitthread playerkingId local.player
if (level.targetscore$player[local.id] == NIL)
{
level.targetscore$player[local.id] = 0
}
level.targetscore$player[local.id] ++
local.stat = (level.target_trigger1 + level.target_trigger2 + level.target_trigger3) // not sure how your triggers can be added but do it here
if(level.targetscore$player[local.id] == 1)
{
local.player stufftext ("say " + "My first hit! " + " I have " + local.stat + " points")
}
else
{
local.player stufftext ("say " + " I got " + level.targetscore$player[local.id] + " hits!" + " totalling " + local.stat + " points")
}
end
level waitTill prespawn
//***Buzzer Sound
local.master = spawn ScriptMaster
local.master aliascache m6l3c_alarm sound/mechanics/Mec_Alarm_05.wav soundparms 1.0 0.0 1.0 0.0 160 1200 auto loaded maps "m dm moh obj train"
no
Posted: Sun Mar 11, 2007 6:53 am
by tltrude
Nope, you just stuck one thread inside another. Take those lines back out and put them at the very bottom of the page.
A thread starts with a name and a colon (main:) and stops with the word "end". If you stick another end line in it, it will stop there.
main:
all the stuff
end // <--this is the end of the thread named main.