• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help OnPlayerSpawned()
#1
How to make a pause 2 seconds, not using Thread ??
  Reply
#2
Use OnAddonFrame.
[Image: azuw.jpg]
  Reply
#3
(09-11-2012, 12:31)zxz0O0 Wrote: Use OnAddonFrame.
No. I need OnPlayerSpawned()
  Reply
#4
POC:
CSHARP Code
  1. //ClientNum, AddonFrame cycles
  2. Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>();
  3. public override void OnPlayerSpawned(ServerClient Client)
  4. {
  5. ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval);
  6. }
  7.  
  8. public override void OnAddonFrame()
  9. {
  10. List<int> PSKeys = new List<int>(ProcessSpawn.Keys);
  11. foreach (int key in PSKeys)
  12. {
  13. ProcessSpawn[key]--;
  14. if (ProcessSpawn[key] == 0)
  15. {
  16. ServerClient spawnedPlayer = GetClient(key);
  17. //do stuff
  18. ProcessSpawn.Remove(key);
  19. }
  20. }
  21. }
[Image: azuw.jpg]
  Reply
#5
I am pretty sure that isn't what he wanted to but instead he wanted to wait 2 seconds before respawn
  Reply
#6
(09-11-2012, 16:49)archit Wrote: I am pretty sure that isn't what he wanted to but instead he wanted to wait 2 seconds before respawn

I think it is what he needs.

I had problems too if i wanted to do something with a freshly spawned Player.
[Image: compiling.png][Image: aLKA8og_460sa.gif]
  Reply
#7
(09-11-2012, 14:37)zxz0O0 Wrote: POC:

Thank you very much! This is exactly what I need!!!
  Reply
#8
This code work fine, but every time when the Zombies Spawn, health increase.

How make to health has increased only one time?

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. public override void OnPlayerSpawned(ServerClient Client)
  14. {
  15. ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval);
  16. }
  17.  
  18. Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>();
  19.  
  20. public override void OnAddonFrame()
  21.  
  22. {
  23. List<int> PSKeys = new List<int>(ProcessSpawn.Keys);
  24. foreach (int key in PSKeys)
  25. {
  26. ProcessSpawn[key]--;
  27. if (ProcessSpawn[key] == 0)
  28. {
  29. ServerClient spawnedPlayer = GetClient(key);
  30. foreach (ServerClient Client in GetClients())
  31. {
  32.  
  33. if (Client.XUID == "0110000xxxxxxxx")
  34. {
  35. if (Client.Team == Teams.Allies)
  36. {
  37.  
  38. Client.Other.Health += 560;
  39.  
  40. }
  41. }
  42.  
  43. }
  44. ProcessSpawn.Remove(key);
  45. }
  46. }
  47. }
  48.  
  49. }
  50. }
  Reply
#9
Code:
using Addon;
using System;
using System.Collections;
using System.Threading;
using System.Collections.Generic;


namespace premium2
{
    public class premium2 : CPlugin
    {
    
        List<String> GotHealth=new List<String>();
        public override void OnServerLoad()
        {
            ServerPrint("vip&arsenal plugin loaded!");
        }
        public override void OnPlayerSpawned(ServerClient Client)
        {
            if(!GotHealth.Contains(Client.XUID))
            {
                ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval);
                GotHealth.Add(Client.XUID);
            }
        }

        Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>();

        public override void OnMapChange()
        {
            GotHealth.clear();
        }
        
        public override void OnFastRestart()
        {
            OnMapChange();
        }
        
        public override void OnAddonFrame()

        {
            List<int> PSKeys = new List<int>(ProcessSpawn.Keys);
            foreach (int key in PSKeys)
           {
                ProcessSpawn[key]--;
                if (ProcessSpawn[key] == 0)
                {
                    ServerClient spawnedPlayer = GetClient(key);
                   foreach (ServerClient Client in GetClients())
                    {

                        if (Client.XUID == "0110000xxxxxxxx")
                        {
                            if (Client.Team == Teams.Allies)
                            {

                                Client.Other.Health += 560;

                            }
                        }

                    }  
                             ProcessSpawn.Remove(key);
                }
            }
        }

        }    
}
[Image: compiling.png][Image: aLKA8og_460sa.gif]
  Reply
#10
(09-12-2012, 12:30)Ich1994 Wrote:
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))
  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. }

Ok. and if so?

I added:Axis

Code:
if (Client.Team == Teams.Axis)
                            {

                                Client.Other.Health += 260;

                            }
  Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)