Raised This Month: $32 Target: $400
 8% 

Replace player's spray with sprite


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 11:19   Replace player's spray with sprite
Reply With Quote #1

Hi,

Need a code where's player's spray is replaced with sprite

I found this (by @Natsheh) but I have never worked with write_*:

PHP Code:
public client_impulse (idimpulse)
{
    if (
impulse == 201)
    {
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY
    
write_byte(TE_SPRAY
    
write_coord(position.x
    
write_coord(position.y
    
write_coord(position.z
    
write_coord(direction.x
    
write_coord(direction.y
    
write_coord(direction.z
    
write_short(modelindex
    
write_byte(count
    
write_byte(speed
    
write_byte(noise
    
write_byte(rendermode
    
message_end()  
    return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE

Airkish is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-19-2018 , 11:32   Re: Replace player's spray with sprite
Reply With Quote #2

Simply hook Ham_Player_ImpulseCommands (Pre), check if pev_impulse is equal to 201 and then set it to 0, then display sprite to player.
There's no such excuse as 'never worked with write_*', they're all documented and there's a bunch of threads where they are used.

Last edited by edon1337; 07-19-2018 at 11:33.
edon1337 is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 13:47   Re: Replace player's spray with sprite
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
Simply hook Ham_Player_ImpulseCommands (Pre), check if pev_impulse is equal to 201 and then set it to 0, then display sprite to player.
There's no such excuse as 'never worked with write_*', they're all documented and there's a bunch of threads where they are used.
Ok so this works - blocks spray and sound.
Need code to set sprite at spray's place
PHP Code:
public Player_ImpulseCommands(id)
{
    if(
pev(idpev_impulse) == 201) {
        return 
HAM_SUPERCEDE
    
}

    return 
HAM_IGNORED

Airkish is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-19-2018 , 14:24   Re: Replace player's spray with sprite
Reply With Quote #4

To set sprite:
PHP Code:
// write_byte(TE_SPRITE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index) 
// write_byte(scale in 0.1's) 
// write_byte(brightness) 
To know where to set the origin of the sprite, use this stock:
PHP Code:
stock fm_get_aimorigin(indexFloat:origin[3])
{
    new 
Float:start[3], Float:view_ofs[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsview_ofs);
    
xs_vec_add(startview_ofsstart);
    
    new 
Float:dest[3];
    
pev(indexpev_v_angledest);
    
engfunc(EngFunc_MakeVectorsdest);
    
global_get(glb_v_forwarddest);
    
xs_vec_mul_scalar(dest9999.0dest);
    
xs_vec_add(startdestdest);
    
    
engfunc(EngFunc_TraceLinestartdest0index0);
    
get_tr2(0TR_vecEndPosorigin);
    
    return 
1;

edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-19-2018 , 14:29   Re: Replace player's spray with sprite
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
To set sprite:
PHP Code:
// write_byte(TE_SPRITE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index) 
// write_byte(scale in 0.1's) 
// write_byte(brightness) 
To know where to set the origin of the sprite, use this stock:
PHP Code:
stock fm_get_aimorigin(indexFloat:origin[3])
{
    new 
Float:start[3], Float:view_ofs[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsview_ofs);
    
xs_vec_add(startview_ofsstart);
    
    new 
Float:dest[3];
    
pev(indexpev_v_angledest);
    
engfunc(EngFunc_MakeVectorsdest);
    
global_get(glb_v_forwarddest);
    
xs_vec_mul_scalar(dest9999.0dest);
    
xs_vec_add(startdestdest);
    
    
engfunc(EngFunc_TraceLinestartdest0index0);
    
get_tr2(0TR_vecEndPosorigin);
    
    return 
1;

Or simply get_user_origin(id, Origin, 3).
__________________
HamletEagle is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 14:54   Re: Replace player's spray with sprite
Reply With Quote #6

PHP Code:
public Player_ImpulseCommands(id)
{
    new 
origin[3];
    
get_user_origin(idorigin3);

    if(
pev(idpev_impulse) == 201) {
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
           
write_byte(TE_SPRITE)
        
write_coord(origin[0])
        
write_coord(origin[1])
        
write_coord(origin[2])
        
write_short(sprite
        
write_byte(1
        
write_byte(150
        
message_end()
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED

Sprite follows where I aim
Airkish is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-19-2018 , 15:00   Re: Replace player's spray with sprite
Reply With Quote #7

Quote:
Originally Posted by Airkish View Post
Sprite follows where I aim
Because that's what sprites do?
edon1337 is offline
Old 07-19-2018, 15:05
Ghosted
This message has been deleted by Ghosted.
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 15:06   Re: Replace player's spray with sprite
Reply With Quote #8

Quote:
Originally Posted by edon1337 View Post
Because that's what sprites do?
I want it to stay where I sprayed and not move

edit: I just figured out that this is done with model, but still the same problem, it follows my aim

Last edited by Airkish; 07-19-2018 at 15:27.
Airkish 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 15:01.


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