AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Plugin not compile [ZPS] (https://forums.alliedmods.net/showthread.php?t=345505)

ORdli 01-21-2024 18:36

Plugin not compile [ZPS]
 
PHP Code:

#include <sourcemod>

public void OnMapStart()
{
    
CreateTimer(1.0Timer_DisplayHealthTIMER_REPEAT);
}

public 
Action Timer_DisplayHealth(Handle:timer)
{
    for (
int entity 1entity <= MaxClientsentity++)
    {
        if (!
IsValidEntity(entity))
            continue;

        if (
GetClassname(entity) == "func_breakable")
        {
            
int health GetEntProp(entityProp_Data"m_iHealth"00);
            
int maxHealth GetEntProp(entityProp_Data"m_iMaxHealth"00);
            if (
health >= && maxHealth >= 0)
            {
                
ShowHealthInfoToClient(entityhealthmaxHealth);
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action ShowHealthInfoToClient(int clientint healthint maxHealth)
{
    
PrintToChat(client"Prop health: %d / %d"healthmaxHealth);
    return 
Plugin_Continue;



The plugin displayed the amount of HP for breaking objects in the game such as doors and barricades, but on the new version 3.2.7 it no longer works, what’s wrong and what’s the matter?
the plugin displayed the amount of remaining HP for objects in the game like func_breakable and physical props, something like show damage only for collapsing obje.

Bacardi 01-22-2024 08:28

Re: Plugin not compile [ZPS]
 
Can you tell us, where you got that code ?
And what update you saw ?

That code not make sense. It check player indexs, unless "GetClassname()" has own magic in it.

*edit
still not make sense to look health from player itsel.

ORdli 01-22-2024 16:15

Re: Plugin not compile [ZPS]
 
Quote:

Originally Posted by Bacardi (Post 2816393)
Can you tell us, where you got that code ?
And what update you saw ?

That code not make sense. It check player indexs, unless "GetClassname()" has own magic in it.

*edit
still not make sense to look health from player itsel.



as far as I know it worked on older versions of the game, I found it from old builds for creating unofficial ready-made servers for zombie panic on github.

101 01-23-2024 00:09

Re: Plugin not compile [ZPS]
 
Quote:

Originally Posted by ORdli (Post 2816406)
as far as I know it worked on older versions of the game, I found it from old builds for creating unofficial ready-made servers for zombie panic on github.

Noway ,everything here is wrong , the code , the logic , the sense and also ur answers .
If i were u , I would request some help like this :
My Game is :X . my goal with - exact manner - is :N , and here is my "full" code :S ,but the problem i have faced is :Z ,
and here some report :P
Quote:

Reports :
C:\game\X\addons\R\Y\*.smx : error 100: function F does not make sense
C:\game\X\addons\R\Y\*.smx : error 101: You can't use MaxClients that has a limit range [32-100] While You Are Searching For a Non-Human Stuff that index might be 1000 , Use GetMaxEntities() Instead .
C:\game\X\addons\R\Y\*.smx : error 102: GetClassName() is undefined , Note : ClassNames of clients seats that refers to "MaxClients" will never match string "func_breakable".
...
...
ATM , i have to guess a solution for a random game "Zombie Panic! Source" like this , but i still don't understand the main purpose :
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");
    }
    
    
char className[32];
    
GetEdictClassname(Eye_TargetclassName32);
    
    if (
StrContains(className"func_break" ,false) != -1)
    {
        
int Health GetEntProp(Eye_TargetProp_Data"m_iHealth"00);
        
int MHealth GetEntProp(Eye_TargetProp_Data"m_iMaxHealth"00);
        
PrintHintText("Health[ %d / %d ]" Health MHealth );
    }
    return 
Plugin_Continue;
}

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


This will print a hint message when a human aims at a breakable entity (I guess So) .

Bacardi 01-23-2024 03:41

Re: Plugin not compile [ZPS]
 
Good work 101, I have not tested tough :)

Grey83 01-23-2024 12:09

Re: Plugin not compile [ZPS]
 
Quote:

Originally Posted by ORdli (Post 2816359)
The plugin displayed the amount of HP for breaking objects in the game such as doors and barricades, but on the new version 3.2.7 it no longer works, what’s wrong and what’s the matter?

ChatGPT is still very bad at writing plugins on SourcePawn

Grey83 01-23-2024 12:29

Re: Plugin not compile [ZPS]
 
Quote:

Originally Posted by 101 (Post 2816417)
This will print a hint message when a human aims at a breakable entity (I guess So).

I think this would be a better option
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_start"Event_RoundEventHookMode_PostNoCopy);
    
HookEvent("round_end"Event_RoundEventHookMode_PostNoCopy);
}

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

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))
            
PrintHintText("Health [ %d / %d ]"GetEntProp(aimProp_Data"m_iHealth"), GetEntProp(aimProp_Data"m_iMaxHealth"));

    return 
Plugin_Continue;



Bacardi 01-23-2024 12:42

Re: Plugin not compile [ZPS]
 
For info, we talk about Zombie Panic Source, game what have own unique events made.

I maybe wrong but I don't think those "round_start" and "round_end" event exist on that game.

I found these tough but do those get fired, I have not tested.
Code:

        "round_begins"                // Round has begun
        {
        }

        "round_win"                        // Round has ended
        {
                "mapname"                "string"
                "humanwin"                "bool"
        }

I would use OnMapStart or else instead.
That mod have a lot difference

ORdli 01-23-2024 13:10

Re: Plugin not compile [ZPS]
 
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, the second plugin compiled and works but it does not show anything, the essence of the plugin was that it showed how much HP remains of an object being destroyed when damage is dealt, for example, there is a barricade on the map that has 2000 HP; when damage is dealt, information is shown in the center of the screen about how much HP is left for the barricade to break it or for any physical object in the game that can be broken, be it is this a door or a drawer!

Grey83 01-23-2024 15:20

Re: Plugin not compile [ZPS]
 
Quote:

Originally Posted by Bacardi (Post 2816466)
I maybe wrong but I don't think those "round_start" and "round_end" event exist on that game.

I found these tough but do those get fired, I have not tested.

Quote:

Originally Posted by ORdli (Post 2816468)
prop_physic

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;




All times are GMT -4. The time now is 06:57.

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