ItsMods

Full Version: Please add Event
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, can Devs add OnChangeTeam ?
(09-10-2012, 00:43)Nerus Wrote: [ -> ]Hi, can Devs add OnChangeTeam ?

example:

CSHARP Code
  1. if (Message.StartsWith("!allies"))
  2. {
  3. Client.Team = Teams.Allies;
  4. return ChatType.ChatNone;
  5. }
  6. if (Message.StartsWith("!axis"))
  7. {
  8. Client.Team = Teams.Axis;
  9. return ChatType.ChatNone;
  10. }
  11. if (Message.StartsWith("!spect"))
  12. {
  13. Client.Team = Teams.Spectator;
  14. return ChatType.ChatNone;
  15. }
@litgar i think he acctually mean the EVENT not on how to change team.

Please read the question before posting...

And im sure @zxz0O0 will take a look at this.

Thanks Barata...
the difficulties of translation....
You can manually check every ServerFrame if somebody changed team.
Which isn't very resource efficient.
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Addon;
  6.  
  7. namespace teamchange
  8. {
  9. public class Class1:CPlugin
  10. {
  11. Dictionary<int, Teams> Team = new Dictionary<int, Teams>();
  12. public void OnTeamChange(ServerClient Client)
  13. {
  14. }
  15. public override void OnPlayerDisconnect(ServerClient Client)
  16. {
  17. Team.Remove(Client.ClientNum);
  18. }
  19. public override void OnPlayerSpawned(ServerClient Client)
  20. {
  21. if (!Team.ContainsKey(Client.ClientNum))
  22. {
  23. Team.Add(Client.ClientNum, Client.Team);
  24. }
  25. else
  26. {
  27. if (Team[Client.ClientNum] != Client.Team)
  28. {
  29. OnTeamChange(Client);
  30. }
  31. Team[Client.ClientNum] = Client.Team;
  32. }
  33. }
  34. }
  35. }

OnTeamChange will get called every time someone changes team.TESTED
(09-10-2012, 11:26)archit Wrote: [ -> ]OnTeamChange will get called every time someone changes team.UNTESTED

Yep, this is it, I need this event to build plugin without create new thread for search "team changes", it will be helpful.