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

Function from SDK not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zekStein
Member
Join Date: Feb 2011
Location: Romania :(
Old 01-06-2012 , 11:30   Function from SDK not working
Reply With Quote #1

PHP Code:

//- Win32 Includes
#include "main.h"
#include <windows.h>
#include <stdio.h>
//- Sdk Includes
#include "sdk/amxxmodule.h"

#include "CString.h"

//- Other includes.
#include <meta_api.h>
#include <cstdlib>
#include <extdll.h>

#include "cbase.h"
#include "weapons.h"

MULTIDAMAGE gMultiDamage;


int UTIL_PointContents(    const Vector &vec )
{
    return 
POINT_CONTENTS(vec);
}

void ClearMultiDamage(void)
{
    
gMultiDamage.pEntity NULL;
    
gMultiDamage.amount    0;
    
gMultiDamage.type 0;
}

void ApplyMultiDamage(entvars_t *pevInflictorentvars_t *pevAttacker )
{
    
Vector        vecSpot1;//where blood comes from
    
Vector        vecDir;//direction blood should go
    
TraceResult    tr;
    
    if ( !
gMultiDamage.pEntity )
        return;

    
gMultiDamage.pEntity->TakeDamage(pevInflictorpevAttackergMultiDamage.amountgMultiDamage.type );
}

void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEndIGNORE_MONSTERS igmonIGNORE_GLASS ignoreGlassedict_t *pentIgnoreTraceResult *ptr )
{
    
TRACE_LINEvecStartvecEnd, (igmon == ignore_monsters TRUE FALSE) | (ignoreGlass?0x100:0), pentIgnoreptr );
}


void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEndIGNORE_MONSTERS igmonedict_t *pentIgnoreTraceResult *ptr )
{
    
TRACE_LINEvecStartvecEnd, (igmon == ignore_monsters TRUE FALSE), pentIgnoreptr );
}

CBaseEntity *UTIL_FindEntityInSphereCBaseEntity *pStartEntity, const Vector &vecCenterfloat flRadius )
{
    
edict_t    *pentEntity;

    if (
pStartEntity)
        
pentEntity pStartEntity->edict();
    else
        
pentEntity NULL;

    
pentEntity FIND_ENTITY_IN_SPHEREpentEntityvecCenterflRadius);

    if (!
FNullEnt(pentEntity))
        return 
CBaseEntity::Instance(pentEntity);
    return 
NULL;
}

inline edict_tINDEXENT2int iEdictNum )

    if (
iEdictNum >= && iEdictNum <= gpGlobals->maxClients)
        return 
MF_GetPlayerEdict(iEdictNum);
    else
        return (*
g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); 
}

#define CHECK_ENTITY(x) \
    
if (|| gpGlobals->maxEntities) { \
        
MF_LogError(amxAMX_ERR_NATIVE"Entity out of range (%d)"x); \
        return 
0; \
    } else { \
        if (
<= gpGlobals->maxClients) { \
            if (!
MF_IsPlayerIngame(x)) { \
                
MF_LogError(amxAMX_ERR_NATIVE"Invalid player %d (not in-game)"x); \
                return 
0; \
            } \
        } else { \
            if (
!= && FNullEnt(INDEXENT(x))) { \
                
MF_LogError(amxAMX_ERR_NATIVE"Invalid entity %d"x); \
                return 
0; \
            } \
        } \
    }

void RadiusDamageVector vecSrcentvars_t *pevInflictorentvars_t *pevAttackerfloat flDamagefloat flRadius/*int iClassIgnore,*/ int bitsDamageType )
{
    
CBaseEntity *pEntity NULL;
    
TraceResult    tr;
    
float        flAdjustedDamagefalloff;
    
Vector        vecSpot;

    if ( 
flRadius )
        
falloff flDamage flRadius;
    else
        
falloff 1.0;

    
int bInWater = (UTIL_PointContents vecSrc ) == CONTENTS_WATER);

    
vecSrc.+= 1;// in case grenade is lying on the ground

    
if ( !pevAttacker )
        
pevAttacker pevInflictor;

    
// iterate on all entities in the vicinity.
    
while ((pEntity UTIL_FindEntityInSpherepEntityvecSrcflRadius )) != NULL)
    {
        if ( 
pEntity->pev->takedamage != DAMAGE_NO )
        {
            
// UNDONE: this should check a damage mask, not an ignore
            //if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )
            //{ houndeyes don't hurt other houndeyes with their attack
            //    continue;
            //}

            // blast's don't tavel into or out of water
            
if (bInWater && pEntity->pev->waterlevel == 0)
                continue;
            if (!
bInWater && pEntity->pev->waterlevel == 3)
                continue;

            
vecSpot pEntity->BodyTargetvecSrc );
            
            
UTIL_TraceLine vecSrcvecSpotdont_ignore_monstersENT(pevInflictor), &tr );

            if ( 
tr.flFraction == 1.0 || tr.pHit == pEntity->edict() )
            {
// the explosion can 'see' this entity, so hurt them!
                
if (tr.fStartSolid)
                {
                    
// if we're stuck inside them, fixup the position and distance
                    
tr.vecEndPos vecSrc;
                    
tr.flFraction 0.0;
                }
                
                
// decrease damage for an ent that's farther from the bomb.
                
flAdjustedDamage = ( vecSrc tr.vecEndPos ).Length() * falloff;
                
flAdjustedDamage flDamage flAdjustedDamage;
            
                if ( 
flAdjustedDamage )
                {
                    
flAdjustedDamage 0;
                }
            
                
// ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) );
                
if (tr.flFraction != 1.0)
                {
                    
ClearMultiDamage( );
                    
pEntity->TraceAttackpevInflictorflAdjustedDamage, (tr.vecEndPos vecSrc).Normalize( ), &trbitsDamageType );
                    
ApplyMultiDamagepevInflictorpevAttacker );
                }
                else
                {
                    
pEntity->TakeDamage pevInflictorpevAttackerflAdjustedDamagebitsDamageType );
                }
            }
        }
    }
}


static 
cell AMX_NATIVE_CALL native_UTIL_RadiusDamage(AMXamx ,cellparams
{
    
int iBitsDamageType params[6];
    
int index params[2];
    
CHECK_ENTITY(index);
    
edict_t *pEdict INDEXENT2(index);

    
entvars_t *= &(pEdict->v);


    
int index2 params[3];
    
CHECK_ENTITY(index2);
    
edict_t *pEdict2 INDEXENT2(index2);

    
entvars_t *v2 = &(pEdict2->v);

    
cell *newVectorCell MF_GetAmxAddr(amxparams[1]);

    
REAL fDamage amx_ctof(params[4]);

    
REAL fRadius amx_ctof(params[5]);

    
RadiusDamage(Vector((float)newVectorCell[0], (float)newVectorCell[1], (float)newVectorCell[2]), vv2fDamagefRadiusiBitsDamageType );
    
    return 
1;
}

AMX_NATIVE_INFO natives[] = {
    { 
"UTIL_RadiusDamage"native_UTIL_RadiusDamage },
    { 
NULLNULL }
};
                             

void OnAmxxAttach() { ; MF_AddNatives(natives); } 
This is my code.
On server, nothing happens
What is wrong ?

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "DUMITRU"

native UTIL_RadiusDamageFloat:vecSrc], pevInflictorpevAttackerFloat:flDamageFloat:flRadiusbitsDamageType );


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
    
register_clcmd("caca""cmdcaca");
}


public 
cmdcacaid )
{
    new 
Float:s[3]
    
pev(idpev_origins);
    
    
UTIL_RadiusDamages,  id,  id10.0200.0DMG_ALWAYSGIB )

__________________
DUMITRU

Last edited by zekStein; 01-06-2012 at 12:03. Reason: DUMITRU
zekStein is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 01-07-2012 , 00:51   Re: Function from SDK not working
Reply With Quote #2

you can't directly use CBaseEntity class in your module, because the game mod has already inherit the CBaseEntity in sdk. The one you try to make it work is not the one the game mod used. You should find the address of RadiusDamage, and make a function pointer with the proper parameter list, then assign the address to that pointer, then you can call it like you call a common function.
something like this:
Code:
typedef void (*FN_RadiusDamage)( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int bitsDamageType );
FN_RadiusDamage RadiusDamage;
RadiusDamage = (FN_RadiusDamage)(0x########); //real_address_of_radiusdamage_function, you should find it yourself(easy in linux)
then you can use it
RadiusDamage( ..., ...);
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
zekStein
Member
Join Date: Feb 2011
Location: Romania :(
Old 01-07-2012 , 06:42   Re: Function from SDK not working
Reply With Quote #3

Exists any tutorial related to the address finding ?
Or that address was already posted ?
__________________
DUMITRU
zekStein 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 10:31.


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