View Single Post
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 07-31-2018 , 13:00   Re: [CS:GO] give player X health every X seconds
Reply With Quote #3

Quote:
Originally Posted by mug1wara View Post
First, something that annoys me. You include sdkhooks, but don't even use it.

Line 15, replace "INVALID_HANDLE" with "_".

Line 22, that basically tells me: get userid from nothing. You could get the userid and pass it as third param on line 15, but that means you have to GetClientOfUserid aswell in callback.

Line 23, there's nothing really wrong here, just want to point out that the int "health" is EXACTLY the same as "GetEntProp(client, Prop_Send, "m_iHealth");"

Line 24, here comes a problem: we first have to get the client's health with GetEntProp, then we have to set it with SetEntProp, or SetEntityHealth (both of which works as good as eachother).

If you're too lazy to read plain english, here's what it should look like.

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
}

public 
Action Event_RoundStart(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
CreateTimer(30.0Timer_Health_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
    
    return 
Plugin_Continue;
}

public 
Action Timer_Health(Handle hTimer)
{
    for (
int i 1<= MaxClientsi++)
    {
        
int iHealth GetClientHealth(i) + 10;
        
        
SetEntityHealth(iiHealth);
    }
    
    return 
Plugin_Continue;

thank you, working.
iskenderkebab33 is offline