Quote:
Originally Posted by LenHard
PHP Code:
#include <sourcemod>
#include <sdktools_functions>
#pragma semicolon 1
#pragma newdecls required
public void OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
public void Event_PlayerSpawn(Event hEvent, const char[] sEventName, bool bDontBroadcast)
{
int iUser = hEvent.GetInt("userid");
if (IsClientInGame(GetClientOfUserId(iUser))) {
CreateTimer(0.7, Timer_Delay, iUser); // Delay to be safe
}
}
public Action Timer_Delay(Handle hTimer, int iUser)
{
int client = GetClientOfUserId(iUser);
if (IsClientInGame(client)) {
GivePlayerItem(client, "weapon_healthshot");
}
}
Try this
|
Shorten the code up a bit like this:
PHP Code:
#include <sourcemod>
#include <sdktools_functions>
#pragma semicolon 1
#pragma newdecls required
public void OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int iUser = GetClientOfUserId(event.GetInt("userid"));
if (IsClientInGame(iUser))
{
CreateTimer(0.7, Timer_Delay, iUser); // Delay to be safe
}
}
public Action Timer_Delay(Handle timer, any client)
{
if (IsClientInGame(client))
{
GivePlayerItem(client, "weapon_healthshot");
}
}
__________________