PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
public void OnClientPutInServer(int clientIndex)
{
SDKHook(clientIndex, SDKHook_SpawnPost, OnPlayerSpawnPost);
}
public void OnPlayerSpawnPost(int playerIndex)
{
if (IsPlayerAlive(playerIndex))
{
// Will be launched 2 times at the first player spawn - don't care for this test
CreateTimer(5.0, OnPlayerSpawnPost5Seconds, GetClientSerial(playerIndex));
}
}
public Action OnPlayerSpawnPost5Seconds(Handle timer, int playerSerial)
{
int playerIndex = GetClientFromSerial(playerSerial);
// Could be more secure - don't care for this test
if (1 <= playerIndex <= MaxClients)
{
GivePlayerItem(playerIndex, "weapon_healthshot");
}
return Plugin_Continue;
}
It works as expected, no crash (15 respawns done, with some time between them).
Server command: +game_type 0 +game_mode 0
If it doesn't work for you, there's maybe another plugin interfering with the one giving healthshots (Or the same one, depends of what it does more).
__________________