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:
Code:
//ClientNum, AddonFrame cycles Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>(); public override void OnPlayerSpawned(ServerClient Client) { ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval); } 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); //do stuff ProcessSpawn.Remove(key); } } }
[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?

Code:
using Addon; using System; using System.Collections; using System.Threading; using System.Collections.Generic; namespace test { public class test : CPlugin { public override void OnPlayerSpawned(ServerClient Client) { ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval); } Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>(); 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); } } } } }
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:
Code:
]using Addon; using System; using System.Collections; using System.Threading; using System.Collections.Generic; namespace test { public class test : CPlugin { List<String> GotHealth=new List<String>(); 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; } if (Client.Team == Teams.Axis) { Client.Other.Health += 260; } } } ProcessSpawn.Remove(key); } } } } }

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 4,158 03-17-2012, 15:29
Last Post: JoSchaap

Forum Jump:


Users browsing this thread:
1 Guest(s)

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