So I have a variable called: Players[]
With 12 players, it has 12 arrays.
Heres my code, but not matter which slot I put myself into in the lobby, Im player 1.
General-Repeat(Actions)12timesActionsVariable-SetPlayerNumber=(PlayerNumber+1)Variable-SetPlayers[PlayerNumber]=(Playergroup(PlayerNumber))UI-Display("You are player: "+(Text(PlayerNumber)))forPlayers[PlayerNumber]toSubtitlearea
The UI is just for testing purposes. How doesnt this work?
I just want it so...
Player[1] = Player 1
Player[2] = Player 2
Etc.
I'm new at this too, but I think I have the code you want.
What you do is make a variable ("Selected player = 1 <interger[16]>")
Make it an array, 1 dimensions, with a size of 16 and an initial value of 1.
If you want to pick each player in order, (so they can by text-activated-trigger or button select each other) "Variable - modify selected player [(Owner of (Triggering Unit))]: +1 will select each player next in order.
by default player 0 is neutral and 15 is hostile. These are computer players that can be refereed to as player 0 and player 15 in the game.
When I make a player variable I make it 0-15. even if all of them are not used. This will make your coding simpler since you avoid most errors when looping through all the players.
As players enter the lobby they are assigned to open player slots.
Rollback Post to RevisionRollBack
Skype
KageNinpo = SN
My Libraries
DialogLeaderboard & TeamSort
My Projects
SPACEWAR Tribute
Infinite TD
So is it always based on when the player enters the lobby?
I have 3 teams of 4, and each team is already set into a variable. Can I use this player group variable to determine specific players?
Something like...
Set Player[1] = Player group (player 1 from group 1)
Set Player[2] = Player group (player 2 from group 1)
Set Player[3] = Player group (player 3 from group 1)
Set Player[4] = Player group (player 4 from group 1)
Set Player[5] = Player group (player 1 from group 2)
Set Player[6] = Player group (player 2 from group 2)
etc.
Yes that is correct, the first player in the lobby is player 1. You can then run a switch,loop,etc and compare with team the player is on and then add that player accordingly to the playergroup. While your repeat system works i think you may need to learn to use an interger loop properly so that you are not using set each player.
So I tried these, and still no luck.
I put myself on team 2 or team 3 and start the game. Im still player 1?
General-Repeat(Actions)12timesActionsVariable-SetPlayerNumber=(PlayerNumber+1)PlayerGroup-AddplayerPlayerNumbertoPlayers[PlayerNumber]UI-Display("You are player: "+(Text(PlayerNumber)))forPlayers[PlayerNumber]toSubtitlearea
And this..
General - For each integer PlayerNumber from 1 to 12 with increment 1, do (Actions)
Actions
Player Group - Add player PlayerNumber to Players[PlayerNumber]
Judging from what you have written, you will need to do something along the lines of:
First you need to identify the players.
Second you need to assign them to an array.
Third you need to verify the teams.
Fourth you need to assign them to a team array.
Each line above can basically be it's own function - may I suggest that you do the following:
Records are basically like folders, so instead of having 10 variables arrays relating to the player, you can have 1 record (an array) and inside it ten normal variables and it works the same way. It keeps it extremely organised and all it does is move the [Array] number from like Playernumber[15] to Player[15].Number,
It is better to rewrite your code now than later to include Records - trust me on this.
Create a Record called "Player Data", then create a Variable Type of Record [Array 15] and call it "Player" and point it to Player Data.
Inside that record you can create everything relating to the player. So create three integers, one called "position_number" the others called "team_number" and "team_position_number".
Next create a Record like we did before, this time calling it "Global Data" and a variable [No Array] pointing to it called "Global".
Create an integer array called "position" [Array 15], create another integer [No Array] call it "amountofplayers".
Create an integer [No Array] call it "amountofteams". Create an integer [No Array] call it "maxplayers" and set this to (15).
Next create another Record call it "Team Data and a variable [Array 4] called "Team"
Create an integer array called "position" [Array 15], create another integer [No Array] call it "amountofplayers".
Create a text variable and call it "name" (just so we can see the team's name).
Alrighty here we go ...
Foreword: Most of this (Like the general idea of how it works) is based off how Tofu does it, however, I use quite a few more records and set quite a more more variables, so I have kept it as simple as possible for OP to learn from.
First thing you are going to need is to Identify the teams, IE - Setup Teams.
Create an Action Definition, call it Setup Teams - Add this to Map Intialization (create new action definition, search for setup teams).
Secondly, you are going to need is to check players.
Create an Action Definition, call it Check Players. - Add this to Map Intialization or Game Start Trigger (anytime after Setup Teams).
CheckPlayersOptions:ActionReturnType:(None)ParametersGrammarText:CheckPlayers()HintText:(None)CustomScriptCodeLocalVariablesx=0<Integer>player=1<Integer>ActionsGeneral-While(Conditions)aretrue,do(Actions)Conditionsplayer<=Global.maxplayersActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Statusofplayerplayer)==Playing(Controllerofplayerplayer)==UserThenVariable-Modifyx:+1Variable-SetGlobal.position[x] = player
Variable - Set Player[player].position_number = x
Else
Variable - Modify player: + 1
Variable - Set Global.amountofplayers = x
So this has basically just identified our players as HUMAN, and assigned them to an array, skipping over any computers it may find. The array is "Global.Position" and the length of the array is "Global.Amountofplayers".
Next we want to set the teams - there are many different ways to do this and I would suggest making each way it's own Action Definition so that you can switch them later if you add in game mode options. Alternatively you may see a similarity between this and the check players function, this is because they are basically doing a different thing in the same way. You could add this to that function but you wouldn't be able to add in more game modes (like Random Teams) later on.
Add this after the Check Players function.
DefaultTeamsOptions:ActionReturnType:(None)ParametersGrammarText:DefaultTeams()HintText:(None)CustomScriptCodeLocalVariablesteam=1<Integer>ActionsGeneral-While(Conditions)aretrue,do(Actions)Conditionsteam<=Global.amountsofteamsActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Numberofplayersin(Playersonteamteam))>=1ThenPlayerGroup-Pickeachplayerin(Playersonteamteam)anddo(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Controllerofplayer(Pickedplayer))==User(Statusofplayer(Pickedplayer))==PlayingThenVariable-ModifyTeam[team].amountsofplayers: + 1
Variable - Set Team[team].position[Team[team].amountsofplayers] = (Picked player)
Variable - Set Player[(Pickedplayer)].team_number = team
Variable - Set Player[(Pickedplayer)].team_position_number = Team[team].amountsofplayers
Else
Else
Variable - Modify team: + 1
This would create an array of players for each team. If you wanted to create a Player Group then you would create one inside the Team Data record, and then EMPTY it as the first thing inside the Team Loop and then add each the player to it where it sets all the player's data.
If you wanted to create units at the center of a team's base you would create a variable inside the team data record of type region, set the region in Setup Team thing (under the name), and then you could do Create Unit for Team[loop_team].position[loop_player] at center of region Team[loop_team].region
Once set up like this, and you understand how it works, your possibilities are endless.
So I have a variable called: Players[]
With 12 players, it has 12 arrays.
Heres my code, but not matter which slot I put myself into in the lobby, Im player 1.
The UI is just for testing purposes. How doesnt this work?
I just want it so...
Player[1] = Player 1
Player[2] = Player 2
Etc.
Thanks!
I'm new at this too, but I think I have the code you want.
What you do is make a variable ("Selected player = 1 <interger[16]>") Make it an array, 1 dimensions, with a size of 16 and an initial value of 1.
If you want to pick each player in order, (so they can by text-activated-trigger or button select each other) "Variable - modify selected player [(Owner of (Triggering Unit))]: + 1 will select each player next in order.
(From Anteep's Empire Builder map)
@xHydrAx74: Go
players are 0-15 and are treated as integers
by default player 0 is neutral and 15 is hostile. These are computer players that can be refereed to as player 0 and player 15 in the game.
When I make a player variable I make it 0-15. even if all of them are not used. This will make your coding simpler since you avoid most errors when looping through all the players.
As players enter the lobby they are assigned to open player slots.
So is it always based on when the player enters the lobby?
I have 3 teams of 4, and each team is already set into a variable. Can I use this player group variable to determine specific players?
Something like...
Set Player[1] = Player group (player 1 from group 1)
Set Player[2] = Player group (player 2 from group 1)
Set Player[3] = Player group (player 3 from group 1)
Set Player[4] = Player group (player 4 from group 1)
Set Player[5] = Player group (player 1 from group 2)
Set Player[6] = Player group (player 2 from group 2)
etc.
@xHydrAx74: Go
Yes that is correct, the first player in the lobby is player 1. You can then run a switch,loop,etc and compare with team the player is on and then add that player accordingly to the playergroup. While your repeat system works i think you may need to learn to use an interger loop properly so that you are not using set each player.
I still have yet to figure this out.
Say the first player who joins the lobby wants to be on team 3, why is he still player 1?
I want slot 1 = player 1 from group 1
Slot 2 = player 2 from group 1
etc.
My last idea didnt work either (post #4)
So I tried these, and still no luck.
I put myself on team 2 or team 3 and start the game. Im still player 1?
And this..
General - For each integer PlayerNumber from 1 to 12 with increment 1, do (Actions)
Actions
Player Group - Add player PlayerNumber to Players[PlayerNumber]
Judging from what you have written, you will need to do something along the lines of:
First you need to identify the players.
Second you need to assign them to an array.
Third you need to verify the teams.
Fourth you need to assign them to a team array.
Each line above can basically be it's own function - may I suggest that you do the following:
Records are basically like folders, so instead of having 10 variables arrays relating to the player, you can have 1 record (an array) and inside it ten normal variables and it works the same way. It keeps it extremely organised and all it does is move the [Array] number from like Playernumber[15] to Player[15].Number,
It is better to rewrite your code now than later to include Records - trust me on this.
Create a Record called "Player Data", then create a Variable Type of Record [Array 15] and call it "Player" and point it to Player Data.
Inside that record you can create everything relating to the player. So create three integers, one called "position_number" the others called "team_number" and "team_position_number".
Next create a Record like we did before, this time calling it "Global Data" and a variable [No Array] pointing to it called "Global".
Create an integer array called "position" [Array 15], create another integer [No Array] call it "amountofplayers".
Create an integer [No Array] call it "amountofteams". Create an integer [No Array] call it "maxplayers" and set this to (15).
Next create another Record call it "Team Data and a variable [Array 4] called "Team"
Create an integer array called "position" [Array 15], create another integer [No Array] call it "amountofplayers".
Create a text variable and call it "name" (just so we can see the team's name).
Alrighty here we go ...
Foreword: Most of this (Like the general idea of how it works) is based off how Tofu does it, however, I use quite a few more records and set quite a more more variables, so I have kept it as simple as possible for OP to learn from.
First thing you are going to need is to Identify the teams, IE - Setup Teams.
Create an Action Definition, call it Setup Teams - Add this to Map Intialization (create new action definition, search for setup teams).
Secondly, you are going to need is to check players.
Create an Action Definition, call it Check Players. - Add this to Map Intialization or Game Start Trigger (anytime after Setup Teams).
So this has basically just identified our players as HUMAN, and assigned them to an array, skipping over any computers it may find. The array is "Global.Position" and the length of the array is "Global.Amountofplayers".
Next we want to set the teams - there are many different ways to do this and I would suggest making each way it's own Action Definition so that you can switch them later if you add in game mode options. Alternatively you may see a similarity between this and the check players function, this is because they are basically doing a different thing in the same way. You could add this to that function but you wouldn't be able to add in more game modes (like Random Teams) later on.
Add this after the Check Players function.
This would create an array of players for each team. If you wanted to create a Player Group then you would create one inside the Team Data record, and then EMPTY it as the first thing inside the Team Loop and then add each the player to it where it sets all the player's data.
You would call this through a LOOP.
Like:
If you wanted to create units at the center of a team's base you would create a variable inside the team data record of type region, set the region in Setup Team thing (under the name), and then you could do Create Unit for Team[loop_team].position[loop_player] at center of region Team[loop_team].region
Once set up like this, and you understand how it works, your possibilities are endless.