ItsMods

Full Version: OnPlayerSpawned()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
yes <5 char >

CSHARP Code
  1. ]using Addon;
  2. using System;
  3. using System.Collections;
  4. using System.Threading;
  5. using System.Collections.Generic;
  6.  
  7.  
  8. namespace test
  9. {
  10. public class test : CPlugin
  11. {
  12.  
  13. List<String> GotHealth=new List<String>();
  14.  
  15. public override void OnPlayerSpawned(ServerClient Client)
  16. {
  17. if(!GotHealth.Contains(Client.XUID) || Client.Team == Teams.Axis)
  18. {
  19. ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval);
  20. GotHealth.Add(Client.XUID);
  21. }
  22. }
  23.  
  24. Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>();
  25.  
  26. public override void OnMapChange()
  27. {
  28. GotHealth.clear();
  29. }
  30.  
  31. public override void OnFastRestart()
  32. {
  33. OnMapChange();
  34. }
  35.  
  36. public override void OnAddonFrame()
  37.  
  38. {
  39. List<int> PSKeys = new List<int>(ProcessSpawn.Keys);
  40. foreach (int key in PSKeys)
  41. {
  42. ProcessSpawn[key]--;
  43. if (ProcessSpawn[key] == 0)
  44. {
  45. ServerClient spawnedPlayer = GetClient(key);
  46. foreach (ServerClient Client in GetClients())
  47. {
  48.  
  49. if (Client.XUID == "0110000xxxxxxxx")
  50. {
  51. if (Client.Team == Teams.Allies)
  52. {
  53.  
  54. Client.Other.Health += 560;
  55.  
  56. }
  57. if (Client.Team == Teams.Axis)
  58. {
  59.  
  60. Client.Other.Health += 260;
  61.  
  62. }
  63.  
  64. }
  65.  
  66. }
  67. ProcessSpawn.Remove(key);
  68. }
  69. }
  70. }
  71.  
  72. }
  73. }


Use this if you want Axis to get Health more then one time.
His problem is:
When ANY player spawns, it makes foreach and gives 260 hp to choosen client.xuid...
He don't want that.
(09-12-2012, 12:53)JayDi Wrote: [ -> ]His problem is:
When ANY player spawns, it makes foreach and gives 260 hp to choosen client.xuid...
He don't want that.

What?
You should tell us what you exactly want to do, your code above makes no sense.
deleted
And why do you want that? That would mean if someone from the Axis team dies 10 times the people from the allies team have 5700 health?

What has this to do with waiting 2seconds after spawn?
(09-12-2012, 15:14)zxz0O0 Wrote: [ -> ]And why do you want that? That would mean if someone from the Axis team dies 10 times the people from the allies team have 5700 health?

What has this to do with waiting 2seconds after spawn?

when any player spawns it gives points AGAIN
remove
@zxz0O0 please, help!
I can't help when I don't understand what you want. Do you want to give the player who spawned additional health after spawn?
Pages: 1 2 3