Does anyone have a code for a game that utilizes/tracks who is in first place or last place on the scoreboard? I’ve tried to code this myself but to no avail. I need to see the code to grasp it I guess.
Why don’t you respond in your other thread to the same topic? Player that is currently winning question
yeah I guess I could have done that… sorry
I’m surprised this isn’t built in automatically (highest score/lowest score). I want to be able to buff the player in last place, and nerf the player in first.
Here is how I calculate top 3 players in my 4738Z game mod:
Code
rule("Calculate top players")
{
event
{
Ongoing - Global;
}
conditions
{
Global.StartFlag == 3;
Global.FinishFlag == False;
}
actions
{
Global.Top1 = First Of(Sorted Array(All Players(All Teams), Distance Between(Current Array Element, Global.BaseFinishLocation)));
If(Entity Exists(Global.Top1) == False);
Global.Top1 = Custom String("free slot");
Global.Top2 = Custom String("free slot");
Global.Top3 = Custom String("free slot");
Else;
Global.Top2 = First Of(Sorted Array(Remove From Array(All Players(All Teams), Global.Top1), Distance Between(Current Array Element,
Global.BaseFinishLocation)));
If(Entity Exists(Global.Top2) == False);
Global.Top2 = Custom String("free slot");
Global.Top3 = Custom String("free slot");
Else;
Global.Top3 = First Of(Sorted Array(Remove From Array(Remove From Array(All Players(All Teams), Global.Top1), Global.Top2),
Distance Between(Current Array Element, Global.BaseFinishLocation)));
If(Entity Exists(Global.Top3) == False);
Global.Top3 = Custom String("free slot");
End;
End;
End;
Wait(1, Ignore Condition);
If(Entity Exists(Global.Top1) == True && Global.LastTop1 != Global.Top1);
Global.LastTop1 = Global.Top1;
Big Message(All Players(All Teams), Custom String("{0} leads the race!", Global.LastTop1));
End;
Loop If Condition Is True;
}
}
More info about me and my game mods you can find here.
Feel free to comment my ideas.