View Single Post
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-15-2018 , 07:25   Re: [Help] Giving players healthshots
Reply With Quote #5

Quote:
Originally Posted by LenHard View Post
PHP Code:
#include <sourcemod>
#include <sdktools_functions>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post);
}

public 
void Event_PlayerSpawn(Event hEvent, const char[] sEventNamebool bDontBroadcast)
{
    
int iUser hEvent.GetInt("userid");

    if (
IsClientInGame(GetClientOfUserId(iUser))) {
        
CreateTimer(0.7Timer_DelayiUser); // Delay to be safe
    
}
}

public 
Action Timer_Delay(Handle hTimerint 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_PlayerSpawnEventHookMode_Post);
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int iUser GetClientOfUserId(event.GetInt("userid"));
    if (
IsClientInGame(iUser))
    {
        
CreateTimer(0.7Timer_DelayiUser); // Delay to be safe
    
}
}

public 
Action Timer_Delay(Handle timerany client)
{
    if (
IsClientInGame(client))
    {
        
GivePlayerItem(client"weapon_healthshot");
    }

__________________
Psyk0tik is offline