Raised This Month: $51 Target: $400
 12% 

Plugin not compile [ZPS]


Post New Thread Reply   
 
Thread Tools Display Modes
ORdli
Member
Join Date: Nov 2021
Old 01-23-2024 , 16:29   Re: Plugin not compile [ZPS]
Reply With Quote #11

Quote:
Originally Posted by Grey83 View Post
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdktools_functions>

bool bShow;

public 
void OnMapStart()
{
    
CreateTimer(1.0Timer_HP_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

    
HookEvent("round_begins"Event_RoundEventHookMode_PostNoCopy);
    
HookEvent("round_win"Event_RoundEventHookMode_PostNoCopy);
}

public 
void Event_Round(Event event, const char[] namebool dontBroadcast)
{
    
bShow name[6] == 'b';
}

public 
Action Timer_HP(Handle timer)
{
    if(!
bShow)
        return 
Plugin_Continue;

    static 
char cls[16];
    for(
int i 1aim<= MaxClientsi++)
        if(
IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(i)
        && (
aim GetClientAimTarget(ifalse)) > MaxClients && GetEntityClassname(aimclssizeof(cls))
        && (!
strncmp(cls"func_breakable"14false) || (!strncmp(cls"prop_physics"12false)))
            
PrintHintText("Health [ %d / %d ]"GetEntProp(aimProp_Data"m_iHealth"), GetEntProp(aimProp_Data"m_iMaxHealth"));

    return 
Plugin_Continue;



plugin not compile

/groups/sourcemod/upload_tmp/textU0FRni.sp(31) : error 001: expected token: ")", but found "-identifier-"

1 Error

Last edited by ORdli; 01-23-2024 at 16:30. Reason: have error
ORdli is offline
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
ORdli
Member
Join Date: Nov 2021
Old 01-23-2024 , 20:13   Re: Plugin not compile [ZPS]
Reply With Quote #13

Quote:
Originally Posted by Bacardi View Post
I made this. And tested.

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



public void OnPluginStart()
{


    
HookEventEx("player_connect"player_connect);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
            
CreateTimer(0.8player_timerGetClientUserId(i), TIMER_REPEAT);
    }
}

public 
void player_connect(Event event, const char[] namebool dontBroadcast)
{
    
CreateTimer(0.8player_timerevent.GetInt("userid"0), TIMER_REPEAT);
}

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

    if(
userid == 0)
        return 
Plugin_Stop;


    
int client GetClientOfUserId(userid);

    if(
client == 0)
        return 
Plugin_Stop;

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


    
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);


Worked! Thanks!
ORdli is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-24-2024 , 04:47   Re: Plugin not compile [ZPS]
Reply With Quote #14

I updated code, timer stopped sometimes during map change. Now it should work.
Bacardi is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 01-24-2024 , 07:07   Re: Plugin not compile [ZPS]
Reply With Quote #15

Quote:
Originally Posted by ORdli View Post
textU0FRni.sp(31) : error 001: expected token: ")", but found "-identifier-"
I forgot to add a closing parenthesis at the end of line 30
__________________
Grey83 is offline
101
Member
Join Date: Nov 2023
Old 01-26-2024 , 14:03   Re: Plugin not compile [ZPS]
Reply With Quote #16

Quote:
Originally Posted by Grey83 View Post
I forgot to add a closing parenthesis at the end of line 30
It was Perfect, but I prefer not to use a loop with many checks inside a short-time repeated timer . Creating a single timer for each human without looping or checking is very cheap , and once he disconnected he take the garbage.

Last edited by 101; 01-26-2024 at 14:17.
101 is offline
101
Member
Join Date: Nov 2023
Old 01-26-2024 , 14:30   Re: Plugin not compile [ZPS]
Reply With Quote #17

Quote:
Originally Posted by ORdli View Post
I tested both plugins, the first from 101 works, but the amount of HP is not shown correctly, and not on all objects, it skips prop_physic
That because u requested a script to only show the breakable shit , try this: ( if u want some additional details) then reply .

PHP Code:
#include <sdktools_functions>

#define Timer_Refresh    1.0

new Handle:h_timer[MAXPLAYERS+1];

public 
OnPluginStart() 
{
    
HookEvent("player_spawn",E_P_S);
}

public 
E_P_S(Handle:event, const String:name[], bool:Broadcast
{
    new 
GetEventInt(event,"entindex");
    if ( !
IsFakeClient(P) &&  h_timer[P] ==null )
    {
        
h_timer[P]=CreateTimer(Timer_Refresh ,Timer_DisplayHealthTIMER_REPEAT);
    }
}

public 
Action Timer_DisplayHealth(Handle Timer,any P)
{
    
int Eye_Target GetClientAimTarget(Pfalse);
    
    switch ( 
Eye_Target)
    {
        case -
: return Plugin_Continue;
        case -
SetFailState("This Function Is Not Supported");
    }
    
    
int Health GetEntProp(Eye_TargetProp_Data"m_iHealth");

    if ( 
Health>)
    {
        
PrintHintText("Health[ %d ]" Health);
    }
    return 
Plugin_Continue;
}

public 
OnClientDisconnect(P)
{
    if (
h_timer[P]!=null)
        
delete h_timer[P];


Last edited by 101; 01-26-2024 at 14:32.
101 is offline
Reply



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 03:56.


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