Hi,
it was my old plugin:
Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
const int Slot_Primary = 0; // Primary weapon slot (weapon_smg, weapon_pumpshotgun, weapon_autoshotgun, weapon_rifle, weapon_hunting_rifle)
const int Slot_Secondary = 1; // Secondary weapon slot (weapon_pistol)
const int Slot_Melee = 2; // Melee (knife) weapon slot (weapon_first_aid_kit)
const int Slot_Projectile = 3; // Projectile weapon slot (weapon_molotov, weapon_pipe_bomb)
const int Slot_Explosive = 4; // Explosive (c4) weapon slot (weapon_pain_pills)
bool g_MapEnd = false;
Handle hWeaponTimer = INVALID_HANDLE;
public Plugin myinfo =
{
name = "WeaponOnSpawn",
author = "Dragokas",
description = "Give pistol, pain pills and basic weapon to player on spawn",
version = PLUGIN_VERSION,
url = "https://github.com/dragokas"
}
public OnPluginStart()
{
HookEvent("survivor_rescued", Event_Survivor_Rescued, EventHookMode_Post);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
public void OnPluginEnd()
{
UnhookEvent("survivor_rescued", Event_Survivor_Rescued);
UnhookEvent("player_spawn", Event_PlayerSpawn);
hWeaponTimer = INVALID_HANDLE;
}
public void OnMapEnd()
{
g_MapEnd = true;
hWeaponTimer = INVALID_HANDLE;
}
public void OnMapStart()
{
g_MapEnd = false;
}
void GiveItem(int Client, char Item[22])
{
int flags = GetCommandFlags("give");
SetCommandFlags("give", flags & ~FCVAR_CHEAT);
FakeClientCommand(Client, "give %s", Item);
SetCommandFlags("give", flags|FCVAR_CHEAT);
}
public Action Event_Survivor_Rescued( Event event, const char[] name, bool dontBroadcast )
{
int client = GetClientOfUserId( GetEventInt(event, "victim") );
if ( (0 < client <= MaxClients) && IsClientInGame(client))
{
WeaponSetTimer(client, true);
}
return Plugin_Continue;
}
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int clientid = GetEventInt(event,"userid");
int client = GetClientOfUserId(clientid);
if ((0 < client <= MaxClients) && IsClientInGame(client) && (GetClientTeam(client) == 2) )
{
WeaponSetTimer(client, false);
}
return Plugin_Continue;
}
void WeaponSetTimer(int client, bool DoGivePills)
{
DataPack pack = new DataPack();
hWeaponTimer = CreateDataTimer(2.0, Timer_GiveWeapon, pack, TIMER_FLAG_NO_MAPCHANGE);
pack.WriteCell(client);
pack.WriteCell(view_as<int>(DoGivePills));
}
public Action Timer_GiveWeapon(Handle timer, Handle pack)
{
int client;
int DoGivePills;
ResetPack(pack);
client = ReadPackCell(pack);
DoGivePills = ReadPackCell(pack);
if (IsClientInGame(client) && (GetClientTeam(client) == 2) && IsPlayerAlive(client) )
{
GivePrimaryWeapon(client, view_as<bool>(DoGivePills));
}
}
void GivePrimaryWeapon(int client, bool DoGivePills)
{
if (g_MapEnd)
return;
int EntWeapon;
if (DoGivePills)
{
EntWeapon = GetPlayerWeaponSlot(client, Slot_Explosive);
if (EntWeapon == -1)
{
GiveItem(client, "pain_pills");
}
}
EntWeapon = GetPlayerWeaponSlot(client, Slot_Secondary);
if (EntWeapon == -1)
{
GiveItem(client, "pistol");
}
EntWeapon = GetPlayerWeaponSlot(client, Slot_Primary);
if (EntWeapon == -1)
{
if (GetRandomInt(0, 1) == 0) {
GiveItem(client, "pumpshotgun");
} else {
GiveItem(client, "smg");
}
}
}
and easily can be rewritten without DataPack.
Anyway, I noticed that sm_dump_handles show me ~ 50 lines of:
Quote:
0x2a9c0583 WeaponOnSpawn.smx DataPack 16
|
Why?
AFAIK, timer is responsible for erasing passed DataPack.
__________________