Raised This Month: $180 Target: $400
 45% 

[Help] Giving players healthshots


Post New Thread Reply   
 
Thread Tools Display Modes
LenHard
Junior Member
Join Date: Jan 2016
Old 05-15-2018 , 18:50   Re: [Help] Giving players healthshots
Reply With Quote #11

Quote:
Originally Posted by Crasher_3637 View Post
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");
    }

Your way is unsafe, you need to pass the userid of the client through intervals and check if the client's index still valid.
__________________
Currently accepting private work
Contact
LenHard is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:35.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode