Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1

    My first BC2 plugin : Auto-balance by clan TAG

    Hello,

    I'm starting my first plugin with a "BF3 plugin template" from PapaCharlie9 but on a BC2 server.
    I'd like to balance player by clan tag.

    Current state : I'm able to show a debug message with soldiername when he join... and this is a first step !!

    Can somebody tell me how to catch the "clan tag" also ?
    Last edited by unisev; 11-02-2016 at 22:07.

  2. #2
    Some hours later... I think my plugin should work now...

    There is 3 parameters :
    - Leader Name
    - Leader clan Tag
    - Challenger clan Tag

    The plugin firstly search for the leader to be online, if it found it, it get his teamID.

    If the Leader is online :
    - every "list user" will balance every soldier (except the leader itself), in the right team
    - every "join user" will balance the joining soldier in the right team

    But there is still one point... how can I get the clanTag in this :
    Code:
    public override void OnPlayerTeamChange(string soldierName, int teamId, int squadId) { 
    }
    Last edited by unisev; 11-02-2016 at 23:51.

  3. #3
    Community Contributor
    Join Date
    Nov 2011
    Posts
    3,026
    This is where the Procon core program handles player info (including clan tag):
    https://github.com/Myrcon/Procon-1/b...CPlayerInfo.cs

    Perhaps that will help you.

    Snip:
    Code:
    public CPlayerInfo(string strSoldierName, string strClanTag, int iTeamId, int iSquadId) {
    	this.SoldierName = strSoldierName;
    	this.ClanTag = strClanTag;
    	
    	this.TeamID = iTeamId;
    	this.SquadID = iSquadId;
    }
    
    public CPlayerInfo(string strSoldierName, string strClanTag, int iTeamId, int iSquadId, int iJoinTime, int iSessionTime) {
    	this.SoldierName = strSoldierName;
    	this.ClanTag = strClanTag;
    
    	this.TeamID = iTeamId;
    	this.SquadID = iSquadId;
    
    	this.JoinTime = iJoinTime;
    	this.SessionTime = iSessionTime;
    }
    
    public string ClanTag { get; set; }
    
    public string SoldierName { get; set; }
    
    public string GUID { get; set; }
    
    public int TeamID { get; set; }
    
    public int SquadID { get; set; }
    
    public int Score { get; set; }
    
    public int Kills { get; set; }
    
    public int Deaths { get; set; }
    
    public int Ping { get; set; }
    
    public int Rank { get; set; }
    
    public int Type { get; set; }
    
    public float Kdr { get; set; }
    
    public int JoinTime { get; set; }
    
    public int SessionTime { get; set; }
    
    //  Player list is needed in OnPlayerList, OnPlayerLeave and server.onRoundOverPlayers
    public static List<CPlayerInfo> GetPlayerList(List<string> lstWords) {
    	List<CPlayerInfo> lstReturnList = new List<CPlayerInfo>();
    
    	int iCurrentOffset = 0;
    	int iParameters = 0;
    	int iPlayers = 0;
    
    	if (lstWords.Count > 0 && int.TryParse(lstWords[iCurrentOffset++], out iParameters) == true) {
    		List<string> lstParameters = lstWords.GetRange(1, iParameters);
    		iCurrentOffset += iParameters;
    
    		if (lstWords.Count > iCurrentOffset && int.TryParse(lstWords[iCurrentOffset++], out iPlayers) == true) {
    			for (int i = 0; i < iPlayers; i++) {
    				if (lstWords.Count > iCurrentOffset + (i * iParameters)) {
    					lstReturnList.Add(new CPlayerInfo(lstParameters, lstWords.GetRange(iCurrentOffset + i * iParameters, iParameters)));
    				}
    			}
    		}
    	}
    
    	return lstReturnList;
    }
    Warning! I do not know hardly anything about Procon plugin development OR C# in general.

    But, for whatever it is worth, this is a snip of how XpKiller's ChatGUIDandStatsLogger plugin handles this sort of thing.
    Code:
    public override void OnListPlayers(List<CPlayerInfo> lstPlayers, CPlayerSubset cpsSubset)
    {
    	try
    	{
    		foreach (CPlayerInfo cpiPlayer in lstPlayers)
    		{
    			if (this.m_dicPlayers.ContainsKey(cpiPlayer.SoldierName) == true)
    			{
    				this.m_dicPlayers[cpiPlayer.SoldierName] = cpiPlayer;
    			}
    			else
    			{
    				this.m_dicPlayers.Add(cpiPlayer.SoldierName, cpiPlayer);
    			}
    		}
    	}
    	catch (Exception c)
    	{
    		this.ExecuteCommand("procon.protected.pluginconsole.write", "^1Error in OnListPlayers: " + c);
    	}
    }

  4. #4

    Arrow

    Thank you again for your answers.

    In your example, a personnal dictionnary is builded in order to keep several player's informations inculding the ClanTAG, but ClanTAG are catched in the "OnListPlayers" event.

    I'd like to catch it in the "OnPlayerTeamChange" event.

    Another point : I don't really understand what is triggering the "OnListPlayers" event...
    Last edited by unisev; 12-02-2016 at 08:12.

  5. #5
    The one and only Bassyboy
    Join Date
    Jul 2010
    Location
    Netherlands
    Posts
    3,261
    Quote Originally Posted by unisev View Post

    Another point : I don't really understand what is triggering the "OnListPlayers" event...
    I believe it's an internal task by Procon that's being run with 30 secs interval.
    Look at the bottom BFBC2.def file:

    procon.protected.tasks.clear
    procon.protected.tasks.add "procon" 0 30 -1 procon.protected.send serverInfo
    procon.protected.tasks.add "procon" 0 30 -1 procon.protected.send admin.listPlayers all
    procon.protected.tasks.add "procon" 0 60 -1 procon.protected.send mapList.nextLevelIndex
    procon.protected.tasks.add "procon" 0 90 -1 procon.protected.send punkBuster.pb_sv_command pb_sv_plist
    I won't do support via PM: if you need help, make a topic on the public forums.

  6. #6
    Thank you, we've got one regular trigger every 30s (I noticed it on a low activity server), but sometime the "OnListPlayers" event is triggered more than once per 30 secs, maybe another event like "OnPlayerJoin" or "OnPlayerTeamChange" is also triggering "OnListPlayers"...

    If this supposition is true ("OnPlayerTeamChange" always followed by "OnListPlayers"), maybe balance player on "OnListPlayers" event is enough.... have to check.

  7. #7
    The one and only Bassyboy
    Join Date
    Jul 2010
    Location
    Netherlands
    Posts
    3,261
    Quote Originally Posted by unisev View Post
    Thank you, we've got one regular trigger every 30s (I noticed it on a low activity server), but sometime the "OnListPlayers" event is triggered more than once per 30 secs, maybe another event like "OnPlayerJoin" or "OnPlayerTeamChange" is also triggering "OnListPlayers"...

    If this supposition is true ("OnPlayerTeamChange" always followed by "OnListPlayers"), maybe balance player on "OnListPlayers" event is enough.... have to check.
    OnListPlayers is probably triggered by other plugins as well, causing it to be more frequently than 30 secs.
    I won't do support via PM: if you need help, make a topic on the public forums.

  8. #8
    I'm only using those plugins :
    • MixedGameMode
    • InGameAdmin


    I don't find good reason for those plugin to trigger a "OnListPlayers"...

    Another Idea : The ProCon GUI itself should do some additional requests (for example to update the "player tab"...)

  9. #9
    Community Contributor
    Join Date
    Nov 2011
    Posts
    3,026
    The player tab in procon uses the 30 second player list update which is already available to it, I believe. The additional player list requests are probably caused by one of your plugins asking for an update onspawn or something similar to receive the most current information. You may likewise want to consider doing an onspawn request for your plugin as well since the player clan tag may not be available right away after they join the server if you rely only on the 30 second player list update. Maybe not every onspawn due to excessive requests, but maybe do a check onspawn to see if that player is in your dictionary and do a playerlist update if not in your dictionary.
    Last edited by ty_ger07; 12-02-2016 at 19:30.

  10. #10
    The onSpawn comes like this :

    Code:
    public override void OnPlayerSpawned(string soldierName, Inventory spawnedInventory) { }
    So there is still no clanTag

    Also, the onSpawn seems too late for me, I'd like to balance player BEFORE they spawn, in order to avoid killing them for swap.

    Still thinking the best way is to get clanTag in the "OnPlayerJoin" or the "OnPlayerTeamChange" that come just after.
    Last edited by unisev; 12-02-2016 at 20:19.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •