OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Sophion on 16 Nov 2005, 00:06:52

Title: Ranking system
Post by: Sophion on 16 Nov 2005, 00:06:52
I have ran into a little problem here. i'm tring to get a ranking system up off the dirt for a MP mission. the mission has three serperate teams and displays thier team color on thier arm. this is were i get "red", "blue" and "green".

anyways... this is what happends... after 4 kills the persons armband is supposed to have one stripe on it. but it doesn't happen. the script stays on the first loop for some reason. can anyone help me with this?

oh... heres the script (copied directly - FOR YOUR EYES ONLY

Code: [Select]
_unit = _this select 0
_side = _this select 1

#loop1
~1
?(score _unit > 600): goto "loop2"
?(score _unit > 1200): goto "loop3"
?(score _unit > 2000): goto "sgt"
?(_side == West): goto "setGreen"
?(_side == East): goto "setRed"
?(_side == Resistance): goto "setBlue"

#setGreen
_unit setobjecttexture [0, "Green.jpg"]
goto "loop1"

#setRed
_unit setobjecttexture [0, "Red.jpg"]
goto "loop1"

#setBlue
_unit setobjecttexture [0, "Blue.jpg"]
goto "loop1"

#loop2
~1
hint "loop 2 reached"
?(score _unit > 1200): goto "loop3"
?(score _unit > 2000): gtot "sgt"
?(_side == West): goto "Green"
?(_side == East): goto "Red"
?(_side == Resistance): goto "Blue"

goto "loop2"
#Green
_unit setobjecttexture [0, "Green_pvt.jpg"]
goto "loop1"

#Red
_unit setobjecttexture [0, "Red_pvt.jpg"]
goto "loop1"

#Blue
_unit setobjecttexture [0, "Blue_pvt.jpg"]
goto "loop1"

#loop3
~1
hint "loop 3 reached"
?(score _unit > 2000): goto "sgt"
?(_side == West): goto "Green1"
?(_side == East): goto "Red1"
?(_side == Resistance): goto "Blue1"

goto "loop2"
#Green1
_unit setobjecttexture [0, "Green_cor.jpg"]
goto "loop1"

#Red1
_unit setobjecttexture [0, "Red_cor.jpg"]
goto "loop1"

#Blue1
_unit setobjecttexture [0, "Blue_cor.jpg"]
goto "loop1"

#sgt
?(_side == West): goto "Green2"
?(_side == East): goto "Red2"
?(_side == Resistance): goto "Blue2"

#Green2
_unit setobjecttexture [0, "Green_sgt.jpg"]
goto "exit"

#Red2
_unit setobjecttexture [0, "Red_sgt.jpg"]
goto "exit"

#Blue2
_unit setobjecttexture [0, "Blue_sgt.jpg"]
goto "exit"

#exit
exit

is this imposible or did i do something wrong?
Title: Re:Ranking system
Post by: Planck on 16 Nov 2005, 01:00:49
I'm no scripting genius, but try this one, not tested.

I hope I understood what you were trying to do.

Code: [Select]
_unit = _this select 0
_side = _this select 1
_sideset = 0
_rank1 = 0
_rank2 = 0

#loop1
~1
?(score _unit >= 600): goto "loop2"
?(score _unit >= 1200): goto "loop3"
?(score _unit >= 2000): goto "sgt"
? _sideset = 1 : goto "loop1"
?(_side == West): goto "setGreen"
?(_side == East): goto "setRed"
?(_side == Resistance): goto "setBlue"

#setGreen
_unit setobjecttexture [0, "Green.jpg"]
_sideset = 1
goto "loop1"

#setRed
_unit setobjecttexture [0, "Red.jpg"]
_sideset = 1
goto "loop1"

#setBlue
_unit setobjecttexture [0, "Blue.jpg"]
_sideset = 1
goto "loop1"

#loop2
~1
hint "loop 2 reached"
?(score _unit >= 1200): goto "loop3"
?(score _unit >= 2000): gtot "sgt"
? _rank1 = 1 : goto "loop2"
?(_side == West): goto "Green"
?(_side == East): goto "Red"
?(_side == Resistance): goto "Blue"

#Green
_unit setobjecttexture [0, "Green_pvt.jpg"]
_rank1 = 1
goto "loop2"

#Red
_unit setobjecttexture [0, "Red_pvt.jpg"]
_rank1 = 1
goto "loop2"

#Blue
_unit setobjecttexture [0, "Blue_pvt.jpg"]
_rank1 = 1
goto "loop2"

#loop3
~1
hint "loop 3 reached"
?(score _unit >= 2000): goto "sgt"
? _rank2 = 1 : goto "loop3"
?(_side == West): goto "Green1"
?(_side == East): goto "Red1"
?(_side == Resistance): goto "Blue1"

#Green1
_unit setobjecttexture [0, "Green_cor.jpg"]
_rank2 = 1
goto "loop3"

#Red1
_unit setobjecttexture [0, "Red_cor.jpg"]
_rank2 = 1
goto "loop3"

#Blue1
_unit setobjecttexture [0, "Blue_cor.jpg"]
_rank2 = 1
goto "loop3"

#sgt
?(_side == West): goto "Green2"
?(_side == East): goto "Red2"
?(_side == Resistance): goto "Blue2"

#Green2
_unit setobjecttexture [0, "Green_sgt.jpg"]
exit

#Red2
_unit setobjecttexture [0, "Red_sgt.jpg"]
exit

#Blue2
_unit setobjecttexture [0, "Blue_sgt.jpg"]
exit


Planck
Title: Re:Ranking system
Post by: Sophion on 16 Nov 2005, 01:51:18
BINGO!!! IT WORKS!!!

haha, there is a differance between using it in Mission editor and multiplayer  :-[

but anyways... i'll advance the script even more to add "Take controll" actions for people who reach the "rank" of sergent.  they will be able to take controll of the squad (which is 5 men but i didn't type that  ;)). so i'll leave this topic open.

the problem now:

how can a man from within the squad take controll over it as the leader in mid-play?
Title: Re:Ranking system
Post by: Sophion on 16 Nov 2005, 23:34:07
OK... this is bad i have ran into another problem.

how to get the script to resume after a player is killed

i've tried event handlers, triggers and script chains. nothing works. any ideas out there? but of course what i'm doing might be wrong. so generaly how do you make a script resume after a player is killed?
Title: Re:Ranking system
Post by: Trapper on 17 Nov 2005, 10:09:19
I've always used a small script to recognize respawns in a MP mission:
Code: [Select]
#l1
@alive soldier1
[soldier1,west] exec "yourscript.sqs"
~0.1
goto "l1"
When the mission begins it will also initiate your color script for the unit.
Title: Re:Ranking system
Post by: Sophion on 17 Nov 2005, 21:43:24
huh?

hmm...

the respawn takes 10 sec. were do i put that in the script? and what do i list the script as? is it be part of the same script or is it completely new?
Title: Re:Ranking system
Post by: Trapper on 18 Nov 2005, 12:01:45
It's a completely new script. You start it once, when the mission begins, and then it loops on it's own until the mission ends.
Everytime it detects soldier1 becomes alive/respawns it executes yourscript.sqs with the values for unit and side.
A time value isn't needed, @ always waits until the units status changes from dead to alive, and then continues the script.
Title: Re:Ranking system
Post by: Sophion on 19 Nov 2005, 00:49:34
sweet... thanks for the help.  ;)

oh... solved!