Member
Join Date: Feb 2011
Location: Romania :(
|
01-06-2012
, 11:30
Function from SDK not working
|
#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 *pevInflictor, entvars_t *pevAttacker ) { Vector vecSpot1;//where blood comes from Vector vecDir;//direction blood should go TraceResult tr; if ( !gMultiDamage.pEntity ) return;
gMultiDamage.pEntity->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type ); }
void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr ) { TRACE_LINE( vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE) | (ignoreGlass?0x100:0), pentIgnore, ptr ); }
void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr ) { TRACE_LINE( vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE), pentIgnore, ptr ); }
CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ) { edict_t *pentEntity;
if (pStartEntity) pentEntity = pStartEntity->edict(); else pentEntity = NULL;
pentEntity = FIND_ENTITY_IN_SPHERE( pentEntity, vecCenter, flRadius);
if (!FNullEnt(pentEntity)) return CBaseEntity::Instance(pentEntity); return NULL; }
inline edict_t* INDEXENT2( int iEdictNum ) { if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients) return MF_GetPlayerEdict(iEdictNum); else return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); }
#define CHECK_ENTITY(x) \ if (x < 0 || x > gpGlobals->maxEntities) { \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ return 0; \ } else { \ if (x <= gpGlobals->maxClients) { \ if (!MF_IsPlayerIngame(x)) { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \ return 0; \ } \ } else { \ if (x != 0 && FNullEnt(INDEXENT(x))) { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ return 0; \ } \ } \ }
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, /*int iClassIgnore,*/ int bitsDamageType ) { CBaseEntity *pEntity = NULL; TraceResult tr; float flAdjustedDamage, falloff; Vector vecSpot;
if ( flRadius ) falloff = flDamage / flRadius; else falloff = 1.0;
int bInWater = (UTIL_PointContents ( vecSrc ) == CONTENTS_WATER);
vecSrc.z += 1;// in case grenade is lying on the ground
if ( !pevAttacker ) pevAttacker = pevInflictor;
// iterate on all entities in the vicinity. while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, flRadius )) != 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->BodyTarget( vecSrc ); UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(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 < 0 ) { flAdjustedDamage = 0; } // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) ); if (tr.flFraction != 1.0) { ClearMultiDamage( ); pEntity->TraceAttack( pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize( ), &tr, bitsDamageType ); ApplyMultiDamage( pevInflictor, pevAttacker ); } else { pEntity->TakeDamage ( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType ); } } } } }
static cell AMX_NATIVE_CALL native_UTIL_RadiusDamage(AMX* amx ,cell* params) { int iBitsDamageType = params[6]; int index = params[2]; CHECK_ENTITY(index); edict_t *pEdict = INDEXENT2(index);
entvars_t *v = &(pEdict->v);
int index2 = params[3]; CHECK_ENTITY(index2); edict_t *pEdict2 = INDEXENT2(index2);
entvars_t *v2 = &(pEdict2->v);
cell *newVectorCell = MF_GetAmxAddr(amx, params[1]);
REAL fDamage = amx_ctof(params[4]);
REAL fRadius = amx_ctof(params[5]);
RadiusDamage(Vector((float)newVectorCell[0], (float)newVectorCell[1], (float)newVectorCell[2]), v, v2, fDamage, fRadius, iBitsDamageType ); return 1; }
AMX_NATIVE_INFO natives[] = { { "UTIL_RadiusDamage", native_UTIL_RadiusDamage }, { NULL, NULL } };
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_RadiusDamage( Float:vecSrc[ 3 ], pevInflictor, pevAttacker, Float:flDamage, Float:flRadius, bitsDamageType );
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) // Add your code here... register_clcmd("caca", "cmdcaca"); }
public cmdcaca( id ) { new Float:s[3] pev(id, pev_origin, s); UTIL_RadiusDamage( s, id, id, 10.0, 200.0, DMG_ALWAYSGIB ) }
__________________
DUMITRU
Last edited by zekStein; 01-06-2012 at 12:03.
Reason: DUMITRU
|
|