AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FakeMeta Trace_Line help (https://forums.alliedmods.net/showthread.php?t=61233)

Styles 09-24-2007 19:54

FakeMeta Trace_Line help
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    
register_forward(FM_PlayerPreThink"forward_prethink")
}

public 
forward_prethink(id)
{
    if(
pevidpev_button ) & IN_USE && !(pevidpev_oldbuttons ) & IN_USE ))
    {
        new 
Index,Body
        get_user_aiming
(id,Index,Body,200)
        
        if(!
Index || !is_user_alive(Index))
            return;
        new 
Float:v1[3]
        new 
Float:v2[3]
        new 
monster
        engfunc
(EngFunc_TraceLine,v1,v2,Index,monster)
        
client_print(idprint_chat"[AMXX TEST] V1: %f-%f-%f V2:%f-%f-%f M:%s"v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], monster)
    }


The line is always 0.000000 0.0000000 0.00000 is alwayas the results. Why?

Note: This is my first Try at this. I followed what was seen in the file.
Code:

EngFunc_TraceLine,                                        // void )                        (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
Thank You

Wilson [29th ID] 09-24-2007 20:58

Re: FakeMeta Trace_Line help
 
In fakemeta_const.inc, the first variable type after the EngFunc and DLLFunc commands is the return variable type, which is in this case "void". That tells you that EngFunc_TraceLine does not return anything at all.

What you need to do to get results from TraceLine is to hook FM_TraceLine. Use the parameters after the word "void" to get the parameters of the hook.

(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)

Those are the parameters that are sent, and thus hooked through FM_TraceLine. Use register_forward() to hook it.
Your function will look something like
public hook_traceline( Float:v1[3], Float:v2[3], nomonsters, id, ptr ) {

On a separate note, to actually accomplish anything with the traceline hook, use the TraceResult stuff inside fakemeta_const:


enum TraceResult
{
TR_AllSolid, // int
TR_StartSolid, // int
TR_InOpen, // int
TR_InWater, // int
TR_flFraction, // float
TR_vecEndPos, // float array[3]
TR_flPlaneDist, // float
TR_vecPlaneNormal, // float array[3]
TR_pHit, // int (edict_t*)
TR_iHitgroup, // int
};

Search the forums for any of those and you'll get some code examples.

Styles 09-24-2007 21:22

Re: FakeMeta Trace_Line help
 
Okay thanks I think i got it :)


All times are GMT -4. The time now is 16:05.

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