09-11-2012, 05:50
09-11-2012, 12:31
Use OnAddonFrame.
09-11-2012, 13:58
(09-11-2012, 12:31)zxz0O0 Wrote: [ -> ]Use OnAddonFrame.No. I need OnPlayerSpawned()
09-11-2012, 14:37
POC:
CSHARP Code
- //ClientNum, AddonFrame cycles
- public override void OnPlayerSpawned(ServerClient Client)
- {
- ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval);
- }
-
- public override void OnAddonFrame()
- {
- foreach (int key in PSKeys)
- {
- ProcessSpawn[key]--;
- if (ProcessSpawn[key] == 0)
- {
- ServerClient spawnedPlayer = GetClient(key);
- //do stuff
- ProcessSpawn.Remove(key);
- }
- }
- }
09-11-2012, 16:49
I am pretty sure that isn't what he wanted to but instead he wanted to wait 2 seconds before respawn
09-11-2012, 17:24
(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.
09-11-2012, 18:00
(09-11-2012, 14:37)zxz0O0 Wrote: [ -> ]POC:
Thank you very much! This is exactly what I need!!!
09-12-2012, 12:23
This code work fine, but every time when the Zombies Spawn, health increase.
How make to health has increased only one time?
How make to health has increased only one time?
CSHARP 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);
- }
-
-
- public override void OnAddonFrame()
-
- {
- 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);
- }
- }
- }
-
- }
- }
09-12-2012, 12:30
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);
}
}
}
}
}
09-12-2012, 12:45
(09-12-2012, 12:30)Ich1994 Wrote: [ -> ]CSHARP 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) { if(!GotHealth.Contains(Client.XUID)) { ProcessSpawn.Add(Client.ClientNum, 2/*seconds*/ * 1000 / AddonFrameInterval); GotHealth.Add(Client.XUID); } } public override void OnMapChange() { GotHealth.clear(); } public override void OnFastRestart() { OnMapChange(); } public override void OnAddonFrame() { 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;
}