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

[CSGO] Conversion of the code to work with another entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ThePunkyRabbid
Junior Member
Join Date: Aug 2013
Old 02-07-2015 , 13:44   [CSGO] Conversion of the code to work with another entity
Reply With Quote #1

Is it possible to make this code work with func_physbox that has an output of OnDamaged?

PHP Code:
public OnEntityCreated(entity, const String:classname[]) SDKHook(entitySDKHook_UseOnUseHook);

public 
Action:OnUseHook(entityactivatorcallerUseType:typeFloat:value)
{
    if (
G_bConfigLoaded && !G_bRoundTransition && IsValidEdict(entity))
    {
        for (new 
index 0index entArraySizeindex++)
        {
            if (
entArray[index][ent_entityid] == Entity_GetHammerID(entity))
            {
              if (
entArray[index][ent_chat])
              {              
               new 
String:name[64];
               
GetEntityClassname(entity,namesizeof(name));
               if(
type == Use_Toggle)
               {
                if(
StrEqual("func_button"name))
                {
                if (
entArray[index][ent_mode] == && entArray[index][ent_cooldowntime] <= -1)
                 {                
                  for (new 
ply 1ply <= MaxClientsply++)
                        {
                            if (
IsClientConnected(ply) && IsClientInGame(ply))
                            {
                                if (!
GetConVarBool(G_hCvar_ModeTeamOnly) || (GetConVarBool(G_hCvar_ModeTeamOnly) && GetClientTeam(ply) == GetClientTeam(caller) || !IsPlayerAlive(ply) || CheckCommandAccess(ply"entWatch_chat"ADMFLAG_CHAT)))
                                {
                                  
CPrintToChat(ply,"\x07%s[entWatch] \x07%s%N \x07%s \x07%s\x07%s%t \x07%s%s"color_tagcolor_namecallercolor_usecolor_usecolor_use"use"entArray[index][ent_color], entArray[index][ent_name]);
                                }
                            }
                        } 
                    
entArray[index][ent_cooldowntime] = entArray[index][ent_cooldown];
                 } 
                }
               }
              }  
            }   
        }
    }

ThePunkyRabbid is offline
ThePunkyRabbid
Junior Member
Join Date: Aug 2013
Old 02-08-2015 , 08:51   Re: [CSGO] Conversion of the code to work with another entity
Reply With Quote #2

bump? :c Anyone has any tips on how to make this work with the func_physbox and the output i posted above?
ThePunkyRabbid is offline
Mehis
Senior Member
Join Date: Mar 2013
Location: basement
Old 02-09-2015 , 04:47   Re: [CSGO] Conversion of the code to work with another entity
Reply With Quote #3

Don't bump topics.

PHP Code:
public OnEntityCreatedent, const String:Classname[] )
{
    if ( 
StrEqualClassname"func_physbox" ) )
        
SDKHookentSDKHook_OnTakeDamageMyHook );

As a punishment you will have to figure out the hook callback by yourself... ;)
I can't check it right now.
Mehis is offline
ThePunkyRabbid
Junior Member
Join Date: Aug 2013
Old 02-09-2015 , 11:43   Re: [CSGO] Conversion of the code to work with another entity
Reply With Quote #4

Sorry about that :/ If i'm not wrong the callback would be simply OnTakeDamage and public Action:OnTakeDamage right? I might sound little dumb, but can't figure out how to add this to the existing code as can't use 2 OnEntityCreated entries...

PHP Code:
public Action:OnTakeDamage(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if (
G_bConfigLoaded && !G_bRoundTransition && IsValidEdict(entity))
    {
        for (new 
index 0index entArraySizeindex++)
        {
            if (
entArray[index][ent_entityid] == Entity_GetHammerID(entity))
            {
              if (
entArray[index][ent_chat])
              {              
               new 
String:name[64];
               
GetEntityClassname(entity,namesizeof(name));
               if(
damagetype==DMG_BULLET)
               {
               if (
StrEqual("func_physbox"name)) 
                {
                if (
entArray[index][ent_mode] == && entArray[index][ent_cooldowntime] <= -1)
                 {                
                  for (new 
ply 1ply <= MaxClientsply++)
                        {
                            if (
IsClientConnected(ply) && IsClientInGame(ply))
                            {
                                if (!
GetConVarBool(G_hCvar_ModeTeamOnly) || (GetConVarBool(G_hCvar_ModeTeamOnly) && GetClientTeam(ply) == GetClientTeam(inflictor) || !IsPlayerAlive(ply) || CheckCommandAccess(ply"entWatch_chat"ADMFLAG_CHAT)))
                                {
                                  
CPrintToChat(ply,"\x07%s[entWatch] \x07%s%N \x07%s \x07%s\x07%s%t \x07%s%s"color_tagcolor_nameinflictorcolor_usecolor_usecolor_use"shot"entArray[index][ent_color], entArray[index][ent_name]);
                                }
                            }
                        } 
                    
entArray[index][ent_cooldowntime] = entArray[index][ent_cooldown];
                 }                 
                }
               } 
              }
            }
        }
    }

Also what should I use in GetClientTeam(inflictor) and the printochat part?

Last edited by ThePunkyRabbid; 02-09-2015 at 12:30.
ThePunkyRabbid is offline
Mehis
Senior Member
Join Date: Mar 2013
Location: basement
Old 02-10-2015 , 02:33   Re: [CSGO] Conversion of the code to work with another entity
Reply With Quote #5

Haven't tested it, but it should work.

Try to read the comments and understand what happens. It'll help you in the future.

If OnEntityCreated has some other hooks, you can simply just add the code I put there at the end of yours.

PHP Code:
public OnEntityCreatedent, const String:Classname[] ) 

    if ( 
StrEqualClassname"func_physbox" ) )
    {    
        
SDKHookentSDKHook_OnTakeDamagePhysbox_TakeDamage );
    }


public 
Action:Physbox_TakeDamageentity, &attacker, &inflictor, &Float:damage, &damagetype )
{
    
// Check for invalid ents and plugin related stuff.
    
if ( !G_bConfigLoaded || G_bRoundTransition || !IsValidEdictentity ) ) return Plugin_Continue;
    
    
// Wrong damage type?
    
if ( damagetype != DMG_BULLET ) return Plugin_Continue;
    
    
// Is our attacker a player?
    
if ( attacker <= || attacker MaxClients ) return Plugin_Continue;
    
    
// Is our attacker even in-game?
    
if ( !IsClientInGameattacker ) ) return Plugin_Continue;
    
    for ( new 
index 0index entArraySizeindex++ )
    {
        
// Not our match?
        
if ( entArray[index][ent_entityid] != Entity_GetHammerIDentity ) ) continue;
        
        
// We don't need this because we only hook func_physboxs that take damage!
        //if (StrEqual("func_physbox", name))
        
        
if ( entArray[index][ent_mode] == && entArray[index][ent_cooldowntime] <= -)
        {
            
// Inflictor is the weapon.
            // Attacker is the client.
            
new att_team GetClientTeamattacker );
            
            for ( new 
ply 1ply <= MaxClientsply++ )
            {
                if ( 
IsClientConnectedply ) && IsClientInGameply ) )
                {
                    if ( !
GetConVarBoolG_hCvar_ModeTeamOnly ) || ( /*GetConVarBool( G_hCvar_ModeTeamOnly ) &&*/ GetClientTeamply ) == att_team || !IsPlayerAliveply ) || CheckCommandAccessply"entWatch_chat"ADMFLAG_CHAT ) ) )
                    {
                        
CPrintToChatply,"\x07%s[entWatch] \x07%s%N \x07%s \x07%s\x07%s%t \x07%s%s"color_tagcolor_nameattackercolor_usecolor_usecolor_use"shot"entArray[index][ent_color], entArray[index][ent_name] );
                    }
                }
            }
            
            
entArray[index][ent_cooldowntime] = entArray[index][ent_cooldown];
        }
    }
    
    return 
Plugin_Continue;


Last edited by Mehis; 02-10-2015 at 02:35.
Mehis is offline
ThePunkyRabbid
Junior Member
Join Date: Aug 2013
Old 02-10-2015 , 12:05   Re: [CSGO] Conversion of the code to work with another entity
Reply With Quote #6

Used this on start then Action:OnUseHook and Action: Physbox_TakeDamage
PHP Code:
public OnEntityCreated(entity, const String:classname[])

    if ( 
StrEqualclassname"func_physbox" ) )
    {    
        
SDKHookentitySDKHook_OnTakeDamagePhysbox_TakeDamage );
    }
    else
    {
        
SDKHook(entitySDKHook_UseOnUseHook);
    }

But unfortunately it didn't work even when I changed some stuff here and there
Attaching the source code for you to look into as I am trying to make it work day after day with no results ;/ (the .sp is that has your part of code like you posted not the one with your part edited)


///This is the edited part of your code that I tried and didn't work aswell :/
PHP Code:
public Action:Physbox_TakeDamageentity, &attacker, &inflictor, &Float:damage, &damagetype )
{
    if (!
G_bConfigLoaded && G_bRoundTransition && !IsValidEdictentity ))
    {
     if (
damagetype == DMG_GENERIC)
     {
        for (new 
index 0index entArraySizeindex++)
        {
        if (
entArray[index][ent_entityid] == Entity_GetHammerID(entity))
            {
              if (
entArray[index][ent_chat])
              {    
               new 
String:name[64];
               
GetEntityClassname(entity,namesizeof(name));
               if ( 
entArray[index][ent_mode] == && entArray[index][ent_cooldowntime] <= -)
               {
                for ( new 
ply 1ply <= MaxClientsply++ )
                {
                 if ( 
IsClientConnectedply ) && IsClientInGameply ) )
                 {
                    if (!
GetConVarBool(G_hCvar_ModeTeamOnly) || (GetConVarBool(G_hCvar_ModeTeamOnly) && GetClientTeam(ply) == GetClientTeam(attacker) || !IsPlayerAlive(ply) || CheckCommandAccess(ply"entWatch_chat"ADMFLAG_CHAT)))
                    {
                        
CPrintToChat(ply,"\x07%s[entWatch] \x07%s%N \x07%s \x07%s\x07%s%t \x07%s%s"color_tagcolor_nameattackercolor_usecolor_usecolor_use"shot"entArray[index][ent_color], entArray[index][ent_name]);
                    }
                 }
                }
                
entArray[index][ent_cooldowntime] = entArray[index][ent_cooldown];
               }
              }
            }
        }
     }
    }

Sorry I'm terrible at coding and I'm just trying to add something to an existing plugin (ofc without taking any credits as I simply don't even deserve nor want to).
Attached Files
File Type: sp Get Plugin or Get Source (entWatch2.sp - 74 views - 40.8 KB)

Last edited by ThePunkyRabbid; 02-10-2015 at 12:32.
ThePunkyRabbid 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 18:51.


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