AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Showing the sprite just for the own team (https://forums.alliedmods.net/showthread.php?t=163284)

bibu 07-28-2011 14:54

Showing the sprite just for the own team
 
PHP Code:

                 message_begin(MSG_ALLSVC_TEMPENTITY)
                        
write_byte(TE_PLAYERATTACHMENT)
                        
write_byte(id)
                        
write_coord(45)
                        
write_short(sprite)
                        
write_short(20)
                        
message_end() 

Everyone can see this, how todo this without that the other team sees this?

abdul-rehman 07-28-2011 15:18

Re: Showing the sprite just for the own team
 
You can get players of a specific team by using the get_players native, then you can loop through them and send the message individually to every one using MSG_ONE_UNRELIABLE/MSG_ONE

bibu 07-28-2011 15:41

Re: Showing the sprite just for the own team
 
Won't that attach it to every one in the team then?

abdul-rehman 07-28-2011 15:52

Re: Showing the sprite just for the own team
 
Oh sorry didnt understand ur question, Sorry :oops:
Another thing you can do is create an entity and set it to MOVETYPE_FOLLOW, this will kinda attach it to players, then you can filter the entity in FM_AddToFullPack forward and then limit its transmission to specific players (like displaying it to only player's teammate as you want)
For eg: My Sprites on HUD plugin uses FM_AddToFullPack forward for showing the sprite to its owner only and not to other players, you can look at it for an eg.

bibu 07-28-2011 16:13

Re: Showing the sprite just for the own team
 
Oh wow... Kind of complicated for something like this. Hope someone other will maybe find another solution. :)

abdul-rehman 07-28-2011 16:21

Re: Showing the sprite just for the own team
 
I also thought that FM_AddToFullPack was complicated but after a few tests with it, i got the hang of it, its really usefule in such stuff :up:

Btw there r pro's here who can find a better solution then this.

Hunter-Digital 07-29-2011 03:09

Re: Showing the sprite just for the own team
 
Just use MSG_ONE/MSG_ONE_UNRELIABLE and send it to every player from that team, only they would see that attachment since it's a message, not an actual entity attachment.

For entitiy attachments you need to use addtofullpack to pick who can see them.

bibu 01-27-2012 18:47

Re: Showing the sprite just for the own team
 
Quote:

Originally Posted by Hunter-Digital (Post 1520830)
Just use MSG_ONE/MSG_ONE_UNRELIABLE and send it to every player from that team, only they would see that attachment since it's a message, not an actual entity attachment.

For entitiy attachments you need to use addtofullpack to pick who can see them.

So I tried todo that again, but I failed.

This should only be seeable for those who are in the team of the target (this shows it for everyone on the server):

PHP Code:

    message_beginMSG_ALLSVC_TEMPENTITY );
        
write_byteTE_PLAYERATTACHMENT );
        
write_bytetarget );
        
write_coord45 );
        
write_short(g_szSprite); 
        
write_short(20);
        
message_end(); 

With
PHP Code:

MSG_ONE_UNRELIABLE 

it crashes.

Hunter-Digital 01-28-2012 09:11

Re: Showing the sprite just for the own team
 
It crashes, but you didn't say why... I *assume* that it's because you don't tell the code who to send the message to.

Code:

message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, player)

bibu 01-28-2012 10:13

Re: Showing the sprite just for the own team
 
Thanks. :)


All times are GMT -4. The time now is 00:47.

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