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

Lightning beam to aiming point


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-30-2011 , 07:47   Lightning beam to aiming point
Reply With Quote #1

I've been trying to create a lightning beam to the point id is aiming.
This is part of a FM_CmdStart hook & is called when id presses IN_USE.

I've tried all the commented ways of message_begin() but i can't get it working.
I'm sure the message is called because the lower part of that code block does work.


I'm also not really understanding when to use the origin & id parameters of message_begin().
Can someone explain that ?

PHP Code:
                        new iOrigin[3], iAimOrigin[3];
                        
get_user_origin(idiOrigin1);
                        
get_user_origin(idiAimOrigin3);
                        
                        
// message_begin(MSG_BROADCAST, SVC_TEMPENTITY, iOrigin, id)
                        // message_begin(MSG_BROADCAST, SVC_TEMPENTITY, iOrigin)
                        // message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
                        // message_begin(MSG_ALL, SVC_TEMPENTITY, iOrigin, id)
                        // message_begin(MSG_ALL, SVC_TEMPENTITY, iOrigin)
                        // message_begin(MSG_ALL, SVC_TEMPENTITY)
                        
write_byte(TE_LIGHTNING);
                        
write_coord(iOrigin[0]);
                        
write_coord(iOrigin[1]);
                        
write_coord(iOrigin[2]);
                        
write_coord(iAimOrigin[0]);
                        
write_coord(iAimOrigin[1]);
                        
write_coord(iAimOrigin[2]);
                        
write_byte(15);
                        
write_byte(50);
                        
write_byte(100);
                        
write_short(g_iSprLightning);
                        
message_end(); 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-30-2011 , 07:55   Re: Lightning beam to aiming point
Reply With Quote #2

origin in message_begin has to be used with MSG_PVS/MSG_PAS.

message_begin(MSG_BROADCAST, SVC_TEMPENTITY) should work. or MSG_ALL.
__________________
Arkshine is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-30-2011 , 08:11   Re: Lightning beam to aiming point
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
origin in message_begin has to be used with MSG_PVS/MSG_PAS.
Thanks, i guess the player param is used for MSG_ONE / MSG_ONE_UNRELIABLE then, right ?

Quote:
Originally Posted by Arkshine View Post
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) should work. or MSG_ALL.
I tried both again but it still isn't working.

this is the complete FM_CmdStart function:
PHP Code:
public FwdCmdStart(idhHandle)
{
    static 
iButton;
    
iButton get_uc(hHandleUC_Buttons);
    
    if(
iButton IN_USE)
    {
        switch(
g_iCurrentDay)
        {
            case 
Day_Pikahunt:
            {
                if(
g_bIsPikachu[id])
                {
                    static 
FloatflGametime;
                    
flGametime get_gametime();
                    
                    if((
g_flLastPikaAttack[id] + get_pcvar_float(g_pPikaCooldown)) < flGametime)
                    {    
                        new 
iOrigin[3], iAimOrigin[3];
                        
get_user_origin(idiOrigin1);
                        
get_user_origin(idiAimOrigin3);
                        
                        
message_begin(MSG_ALLSVC_TEMPENTITY);
                        
write_byte(TE_LIGHTNING);
                        
write_coord(iOrigin[0]);
                        
write_coord(iOrigin[1]);
                        
write_coord(iOrigin[2]);
                        
write_coord(iAimOrigin[0]);
                        
write_coord(iAimOrigin[1]);
                        
write_coord(iAimOrigin[2]);
                        
write_byte(150);
                        
write_byte(500);
                        
write_byte(100);
                        
write_short(g_iSprLightning);
                        
message_end();
                        
                        
emit_sound(idCHAN_VOICEg_szSoundPikaAttack
                            
VOL_NORMATTN_NORM0PITCH_NORM); 
                            
                        new 
iEntityiBody;
                        
get_user_aiming(idiEntityiBody);
                        
                        
// if(IsPlayer(iEntity) && cs_get_user_team(id) != cs_get_user_team(iEntity))
                        
if(IsPlayer(iEntity))
                            
ExecuteHamB(Ham_TakeDamageiEntityididget_pcvar_float(g_pPikaDamage), DMG_GENERIC);
                        
                        
g_flLastPikaAttack[id] = flGametime;
                    }
                }
            }
        }
    }

The lightning still doesn't do anything with both MSG_BROADCAST and MSG_ALL.
The sound is working
and another thing that i don't understand is that the dmg dealt to the player i'm aiming at is 42 while the g_pPikaDamage cvar is 50.0.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-30-2011 , 10:43   Re: Lightning beam to aiming point
Reply With Quote #4

A beam from your origin to you aim point is difficult to see from your point of view, have to try to see the beam of another player ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-30-2011 , 11:15   Re: Lightning beam to aiming point
Reply With Quote #5

I've made a little plugin to test the beam but i can't still see it with either MSG_ALL or MSG_BROADCAST.
It says the beam has been created though.

PHP Code:
#include <amxmodx>

new g_iOrigins[2][3]
    , 
g_iSprLightning
;


public 
plugin_precache()
    
g_iSprLightning precache_model("sprites/lgtning.spr");

    
public 
plugin_init()
    
register_clcmd("say /beam""CmdBeam");

    
public 
CmdBeam(id)
{
    if(!
g_iOrigins[0][0])
    {
        
get_user_origin(idg_iOrigins[0], 1);
        
client_print(idprint_chat"Origin 1 set.");
    }
    
    else if(
g_iOrigins[0][0] && !g_iOrigins[1][0])
    {
        
get_user_origin(idg_iOrigins[1], 1);
        
client_print(idprint_chat"Origin 2 set.");
    }
    
    else
    {    
        
// message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
        
message_begin(MSG_ALLSVC_TEMPENTITY);
        
write_byte(TE_LIGHTNING);
        
write_coord(g_iOrigins[0][0]);
        
write_coord(g_iOrigins[0][1]);
        
write_coord(g_iOrigins[0][2]);
        
write_coord(g_iOrigins[1][0]);
        
write_coord(g_iOrigins[1][1]);
        
write_coord(g_iOrigins[1][2]);
        
write_byte(150);
        
write_byte(500);
        
write_byte(100);
        
write_short(g_iSprLightning);
        
message_end();
        
        
arrayset(g_iOrigins[0], 0sizeof(g_iOrigins[]));
        
arrayset(g_iOrigins[1], 0sizeof(g_iOrigins[]));
        
        
client_print(idprint_chat"Beam created & origins reset.");
    }

    return 
PLUGIN_HANDLED;

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 12-30-2011 , 13:51   Re: Lightning beam to aiming point
Reply With Quote #6

That will not create a beam to your aiming origin. You're getting the same origin twice.

Code:
if(!g_iOrigins[0][0]) {     get_user_origin(id, g_iOrigins[0], 1);     client_print(id, print_chat, "Origin 1 set."); } else if(g_iOrigins[0][0] && !g_iOrigins[1][0]) {
    get_user_origin(id, g_iOrigins[1], 3);
    client_print(id, print_chat, "Origin 2 set."); }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-30-2011 , 16:14   Re: Lightning beam to aiming point
Reply With Quote #7

i'm moving to another place every time i say /beam to see if i can see it from another point.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 12-30-2011 , 16:24   Re: Lightning beam to aiming point
Reply With Quote #8

Quote:
Originally Posted by drekes View Post
i'm moving to another place every time i say /beam to see if i can see it from another point.
Right. Have you tried using other values on the life, width and amplitude parameters?
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-30-2011 , 18:48   Re: Lightning beam to aiming point
Reply With Quote #9

Yeah, i started at the ones in the first post and changed them to the ones in the full function i posted and a few lower & higher values.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
liinuus
Senior Member
Join Date: Apr 2010
Old 12-30-2011 , 19:53   Re: Lightning beam to aiming point
Reply With Quote #10

Try using this.
Code:
new aim_origin[ 3 ]; get_user_origin( id, aim_origin, 3 );         message_begin( MSG_BROADCAST, SVC_TEMPENTITY ); write_byte( TE_BEAMENTPOINT ); write_short( id | 0x1000 ); write_coord( aim_origin[ 0 ] ); write_coord( aim_origin[ 1 ] ); write_coord( aim_origin[ 2 ] ); write_short( g_iSprLightning ); write_byte( 0 ); write_byte( 0 ); write_byte( 150 ); write_byte( 500 ); write_byte( 100 ); // noise amplitude in 0.01's write_byte( 200 ); // red write_byte( 200 ); // green write_byte( 200 ); // blue write_byte( 200 ); // brightness write_byte( 10 ); // scroll speed in 0.1's message_end( );
liinuus 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 16:27.


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