Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help OnPlayerSpawned()
#11
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.
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply

#12
His problem is:
When ANY player spawns, it makes foreach and gives 260 hp to choosen client.xuid...
He don't want that.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#13
(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?
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply

#14
You should tell us what you exactly want to do, your code above makes no sense.
[Image: azuw.jpg]
Reply

#15
deleted
Reply

#16
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?
[Image: azuw.jpg]
Reply

#17
(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
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#18
remove
Reply

#19
@zxz0O0 please, help!
Reply

#20
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?
[Image: azuw.jpg]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Error using OnPlayerSpawned JoSchaap 6 2,946 03-17-2012, 15:29
Last Post: JoSchaap

Forum Jump:


Users browsing this thread:
5 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.