View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-23-2024 , 19:48   Re: Plugin not compile [ZPS]
Reply With Quote #12

I made this. And tested.

*updated 24.01.2024 13:44 GMT +03:00
PHP Code:

#include <sdktools>


// settings for m_takedamage
#define    DAMAGE_NO                0
#define DAMAGE_EVENTS_ONLY        1        // Call damage functions, but don't modify health
#define    DAMAGE_YES                2
#define    DAMAGE_AIM                3


Handle timers[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
HookEventEx("player_activate"player_activate);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
        {
            
DataPack pack;

            
timers[i] = CreateDataTimer(0.8player_timerpackTIMER_REPEAT);
            
pack.WriteCell(i);
            
pack.WriteCell(GetClientUserId(i));
            
pack.Reset();
        }
    }
}

public 
void player_activate(Event event, const char[] namebool dontBroadcast)
{
    
int userid event.GetInt("userid"0);
    
int client GetClientOfUserId(userid);

    if(
client 0)
    {
        if(
timers[client] != null)
        {
            
delete timers[client];
        }

        
DataPack pack;

        
timers[client] = CreateDataTimer(0.8player_timerpackTIMER_REPEAT);
        
pack.WriteCell(client);
        
pack.WriteCell(userid);
        
pack.Reset();
    }
}

public 
Action player_timer(Handle timerDataPack pack)
{
    static 
bool hint[MAXPLAYERS+1];

    
int client pack.ReadCell();
    
int userid pack.ReadCell();
    
pack.Reset();

    if(
timers[client] == null)
        return 
Plugin_Stop;

    if(
timers[client] != timer)
        return 
Plugin_Stop;

    if(!
IsClientConnected(client))
    {
        
timers[client] = null;
        
hint[client] = false;
        return 
Plugin_Stop;
    }

    if(!
IsClientInGame(client))
    {
        
hint[client] = false;
        return 
Plugin_Continue;
    }

    if(
IsFakeClient(client))
    {
        
timers[client] = null;
        
hint[client] = false;
        return 
Plugin_Stop;
    }

    
int newuserid GetClientUserId(client);

    
// timer match but not userid ? Something went wrong
    
if(userid != newuserid)
    {
        
timers[client] = null;
        
hint[client] = false;
        return 
Plugin_Stop;
    }



    
float eyepos[3], eyeangle[3], startpos[3], endpos[3];

    
GetClientEyePosition(clienteyepos);
    
GetClientEyeAngles(clienteyeangle);

    
GetAngleVectors(eyeanglestartposNULL_VECTORNULL_VECTOR);
    
ScaleVector(startpos10.0);
    
AddVectors(startposeyeposstartpos);

    
GetAngleVectors(eyeangleendposNULL_VECTORNULL_VECTOR);
    
ScaleVector(endpos160.0);
    
AddVectors(endposeyeposendpos);


    
TR_TraceHullFilter(startposendpos, {-4.0,-4.0,-4.0}, {4.0,4.0,4.0}, MASK_SHOT_HULLTraceFilterclient);
    
int entity TR_GetEntityIndex();

    if(
entity MaxClients)
    {
        if(
hint[client])
        {
            
hint[client] = false;
            
PrintCenterText(client" ");
        }

        return 
Plugin_Continue;
    }

    
char clsname[MAX_NAME_LENGTH];
    
GetEntityClassname(entityclsnamesizeof(clsname));

    
//PrintToServer("clsname %s %i %i", clsname, GetEntProp(entity, Prop_Data, "m_takedamage"), entity);

    
if(!HasEntProp(entityProp_Data"m_takedamage")
    || 
GetEntProp(entityProp_Data"m_takedamage") <= DAMAGE_NO
    
|| !HasEntProp(entityProp_Data"m_iHealth")
    || 
GetEntProp(entityProp_Data"m_iHealth") <= 0)
    {

        if(
hint[client])
        {
            
hint[client] = false;
            
PrintCenterText(client" ");
        }

        return 
Plugin_Continue;
    }

    
hint[client] = true;


    
PrintCenterText(client "HEALTH\n %d" GetEntProp(entityProp_Data"m_iHealth"));

    return 
Plugin_Continue;
}

public 
bool TraceFilter(int entityint contentsMaskany data)
{
    return (
entity != data);

__________________
Do not Private Message @me

Last edited by Bacardi; 01-24-2024 at 06:44. Reason: fix - timer stopped on level change
Bacardi is offline