using System;
using System.Numerics;
using Plugify;
using s2sdk;
using static s2sdk.s2sdk;
public unsafe class Sample : Plugin
{
public void OnPluginStart()
{
OnEntitySpawned_Register(OnEntitySpawnedCallback);
}
public void OnPluginEnd()
{
OnEntitySpawned_Unregister(OnEntitySpawnedCallback);
}
private static void OnEntitySpawnedCallback(int entityHandle)
{
string className = GetEntityClassname(entityHandle);
if (className != "smokegrenade_projectile") return;
// Changes smoke grenade colour to a random colour each time.
QueueTaskForNextFrame(OnEntitySpawnedCallback_Post, [entityHandle]);
}
private static void OnEntitySpawnedCallback_Post(object[] data) {
int entityHandle = (int)data[0];
Vector3 smokeColor = new Vector3(
Random.Shared.NextSingle() * 255.0f,
Random.Shared.NextSingle() * 255.0f,
Random.Shared.NextSingle() * 255.0f
);
SetEntSchemaVector3D(entityHandle, "CSmokeGrenadeProjectile", "m_vSmokeColor", smokeColor, true, 0);
PrintToServer($"Smoke grenade spawned with color {smokeColor}\n");
}
}