AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Message 'Brass' (https://forums.alliedmods.net/showthread.php?t=176155)

Welgericht 01-14-2012 13:01

Message 'Brass'
 
I have some problems with message 'Brass', plug-in compiles but it doesn't work. Here is the code:
PHP Code:

#include < amxmodx >

#include < fakemeta >

#define PLUGIN  "Test"
#define VERSION "Test"
#define AUTHOR  "Test"

new model

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say /test""clcmd_test")
}

public 
plugin_precache()
{
    
model precache_model("models/shell.mdl")
}

public 
clcmd_test(id)
{
    new 
origin[3], fAngle[3]

    
pev(idpev_originorigin)
    
pev(idpev_view_ofsfAngle)

    
message_begin(MSG_ONEget_user_msgid("Brass"), {0,0,0}, id );
    
write_byte(TE_MODEL// MessageID
    
write_coord(origin[0]) // Start X
    
write_coord(origin[1]) // Start Y
    
write_coord(origin[2]) // Start Z
    
write_coord(fAngle[0]) // Velocity X
    
write_coord(fAngle[1]) // Velocity Y
    
write_coord(fAngle[2]) // Velocity Z
    
write_angle(30.0// Angle Rotation
    
write_short(model// Model Index
    
write_byte(1// Bounce sound type
    
write_byte(25// Life (2.5 sec.)
    
message_end()


Where is my mistake?

ConnorMcLeod 01-14-2012 13:10

Re: Message 'Brass'
 
Use get_user_origin to you can retrieve an integer vector.
view_ofs is just holding head offset in the .z part, if you want angles use rather pev_angles or pev_v_angle, and to use Float vector, use engfunc(EngFunc_WriteCoord, instead of write_coord.
In write_angle pass 30 and not 30.0

KORD_12.7 01-14-2012 19:21

Re: Message 'Brass'
 
I'm using this:

PHP Code:

// Temp entity bounce sound types
#define TE_BOUNCE_NULL            0
#define TE_BOUNCE_SHELL            1
#define TE_BOUNCE_SHOTSHELL        2

#define DEFAULT_VIEWHEIGHT        28.0
#define VEC_DUCK_VIEW            12.0

GetDefaultShellInfo(const iPlayer, const FloatvecOrigin[3], const FloatvecVelocity[3], FloatvecShellVelocity[3], FloatvecShellOrigin[3], 
    const 
FloatvecForward[3], const FloatvecRight[3], const FloatvecUp[3], const FloatflForwardScale, const FloatflUpScale, const FloatflRightScale)
{
    new 
FloatflR
    
new FloatflU
    
new FloatvecViewOfs[3]
    
    
vecViewOfs[2] = pev(iPlayerpev_flags) & FL_DUCKING VEC_DUCK_VIEW DEFAULT_VIEWHEIGHT
    
    flR 
random_float(50.070.0)
    
flU random_float(100.0150.0)
    
    for (new 
03i++)
    {
        
vecShellVelocity[i] = vecVelocity[i] + vecRight[i] * flR vecUp[i] * flU vecForward[i] * 25
        vecShellOrigin
[i] = vecOrigin[i] + vecViewOfs[i] + vecUp[i] * flUpScale vecForward[i] * flForwardScale vecRight[i] * flRightScale
    
}
}

UTIL_EjectBrass(const FloatvecOrigin[3], const FloatvecVelocity[3], const FloatflRotation, const iModelIndex, const iSoundtype)
{
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecOrigin0);
    
write_byte(TE_MODEL);
    
engfunc(EngFunc_WriteCoordvecOrigin[0]);
    
engfunc(EngFunc_WriteCoordvecOrigin[1]);
    
engfunc(EngFunc_WriteCoordvecOrigin[2]);
    
engfunc(EngFunc_WriteCoordvecVelocity[0]);
    
engfunc(EngFunc_WriteCoordvecVelocity[1]);
    
engfunc(EngFunc_WriteCoordvecVelocity[2]);
    
engfunc(EngFunc_WriteAngleflRotation)
    
write_short(iModelIndex)
    
write_byte(iSoundtype)
    
write_byte(25);// 2.5 seconds
    
message_end
}


/* LOL.
*
* native hl_wpn_eject_brass(const iPlayer, const iShellModelIndex, const iSoundtype, const Float: flForwardScale, const Float: flUpScale, const Float: flRightScale);
*/
public _hl_wpn_eject_brass(iPluginiParams)
{
    if (
iParams != 6)
    {
        
log_error(AMX_ERR_NATIVE"Bad arguments num, expected 6, passed %d"iParams);
        return 
0;
    }
    
    new 
iPlayer
    
    CHECK_PLAYER
((iPlayer get_param(1)))
    
    new 
FloatvecUp[3]
    new 
FloatvecRight[3]
    new 
FloatvecForward[3]
    new 
FloatvecAngles[3]
    new 
FloatvecOrigin[3]
    new 
FloatvecVelocity[3]
    new 
FloatvecShellVelocity[3]
    new 
FloatvecShellOrigin[3]
    
    
pev(iPlayerpev_anglesvecAngles)
    
pev(iPlayerpev_originvecOrigin)
    
pev(iPlayerpev_velocityvecVelocity)
    
    
global_get(glb_v_forwardvecForward)
    
global_get(glb_v_rightvecRight)
    
global_get(glb_v_upvecUp)
    
    
GetDefaultShellInfo(iPlayervecOriginvecVelocityvecShellVelocityvecShellOriginvecForwardvecRightvecUpFloatget_param(4), Floatget_param(5), Floatget_param(6));
    
UTIL_EjectBrass(vecShellOriginvecShellVelocityvecAngles[2], get_param(2), get_param(3))
    
    return 
1;



ConnorMcLeod 01-15-2012 06:02

Re: Message 'Brass'
 
Quote:

Originally Posted by KORD_12.7 (Post 1631949)
I'm using this:

Counter-Strike has a specific Brass message, where in HL temp entities are used, maybe your code could be used replacing SVC_TEMPENTITY with gmsgBrass though :)


All times are GMT -4. The time now is 01:38.

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