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

Questions on "message_begin()"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bobii
Junior Member
Join Date: Dec 2020
Old 12-12-2020 , 02:29   Questions on "message_begin()"
Reply With Quote #1

Hi,

We have a private cs 1.6 server. The original smoke as you know is very transparent and does not offer so much utility. I tried all plugins (I think) I could find. None of them work as intended. Then I decided learn why they don't. They all have the same ´problem because they essentially use the same idea to solve the problem.
Plugins such as:
https://forums.alliedmods.net/showthread.php?p=849413
https://forums.alliedmods.net/showthread.php?p=970945


And that idea is:

Code:
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
sending messages to clients and draw spriters at the original smoke location and delete the original smoke entity.

Now the main problem with this approach is:
Players who a re a bit far away from the grenade location or don't have vision, their clients do not draw these sprites on the screen so that means when they arrive to the location there is no smoke. Others closer to the location of course sees the smoke.

So I have 2 questions:
  1. I am wondering if anyone have any idea why this would happen? It is strange that no one complained about this before. But in our trials it seems to be a pretty consistent problem not random at all.
  2. Can there be an alternative approach then deleting the original entity, creating a new entity and using messages to draw sprites on client screen? Just give me an hint

Last edited by bobii; 12-12-2020 at 06:20.
bobii is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-12-2020 , 10:28   Re: Questions on "message_begin()"
Reply With Quote #2

Use MSG_ALL instead of MSG_BROADCAST
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
bobii
Junior Member
Join Date: Dec 2020
Old 12-12-2020 , 18:31   Re: Questions on "message_begin()"
Reply With Quote #3

Tried all the possibilities already.

MSG_BROADCAST
MSG_ALL

and in a for loop over all clients I tried:

MSG_ONE
MSG_ONE_RELIABLE

It feels like tempentity depends on the player distance to the entity.
bobii is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 12-12-2020 , 19:03   Re: Questions on "message_begin()"
Reply With Quote #4

1st yeha you should use MSG_ALL 2nd mind showing the code to see what we can advise you to do?
AnimalMonster is offline
bobii
Junior Member
Join Date: Dec 2020
Old 12-13-2020 , 04:06   Re: Questions on "message_begin()"
Reply With Quote #5

Well it is basically ColoredSmokenades https://forums.alliedmods.net/attach...5&d=1245089468

But I use it with different sprites. The sprites are over here https://gamebanana.com/effects/6000

Code:
  get_players(players, num, "a"); //GetPlayers_ExcludeDead)
                for(i=0;i<=num;i++) {
                if( !is_user_connected(players[i] ) || is_user_bot( players[i] )  ){
                        continue;
                        }
                        //message_begin( MSG_ALL, SVC_TEMPENTITY );
                        message_begin( MSG_ONE , SVC_TEMPENTITY, _, players[i]);
                        write_byte( TE_FIREFIELD );
                        engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
                        engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
                        engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
                        write_short( 100 );
                        write_short( g_szSmokeSprites[ iSmoke ] );
                        write_byte( 100 );
                        write_byte( TEFIRE_FLAG_ALPHA );
                        write_byte( 1000 );
                        message_end();

                        //message_begin( MSG_ALL, SVC_TEMPENTITY );
                        message_begin( MSG_ONE , SVC_TEMPENTITY, _, players[i]);
                        write_byte( TE_FIREFIELD );
                        engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
                        engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
                        engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
                        write_short( 150 );
                        write_short( g_szSmokeSprites[ iSmoke ] );
                        write_byte( 10 );
                        write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT );
                        write_byte( 1000 );
                        message_end( );
                }
For convenience here is the most relevant part of the code.

Last edited by bobii; 12-13-2020 at 04:06.
bobii is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 12-13-2020 , 08:11   Re: Questions on "message_begin()"
Reply With Quote #6

idk the problem but i would do
PHP Code:
for(new 0get_maxplayers(); i++)
{
        if(
is_user_alive(i) && is_user_connected(i))
        { 
// Code
        
}

Replacing players[i] with i

Last edited by AnimalMonster; 12-13-2020 at 08:12.
AnimalMonster is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-13-2020 , 08:49   Re: Questions on "message_begin()"
Reply With Quote #7

Quote:
Originally Posted by AnimalMonster View Post
idk the problem but i would do
PHP Code:
for(new 0get_maxplayers(); i++)
{
        if(
is_user_alive(i) && is_user_connected(i))
        { 
// Code
        
}

Replacing players[i] with i
And you would be terribly wrong by doing that.
Firstly, a user can not alive without being connected so logically checking both is useless.
Secondly, the proper way to iterate over all players is to use get_players. It removes the need to do any kind of validation(connected/alive/bot/dead/whatever) by using proper flags in get_players.

Please don't give advice until you actually understand how things work and why they work in a certain way.
__________________

Last edited by HamletEagle; 12-13-2020 at 11:08.
HamletEagle is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 12-13-2020 , 08:57   Re: Questions on "message_begin()"
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
And you would be terribly wrong by doing that.
Firstly, a user can not alive without being connected so logically checking both is useless.
Secondly, the proper way to iterate over all players is to use get_maxplayers. It removes the need to do any kind of validation(connected/alive/bot/dead/whatever) by using proper flags in get_players.

Please don't give advice until you actually understand how things work and why they work in a certain way.
Yeah, i didn't know but good thing is that you explained me that

Last edited by AnimalMonster; 12-13-2020 at 08:57.
AnimalMonster is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-13-2020 , 11:14   Re: Questions on "message_begin()"
Reply With Quote #9

In the loop condition you have..
PHP Code:
i<=num 
It should be

PHP Code:
num 
Cause it wont iterate out of array and you won't get a false result
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-15-2020 at 11:11.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
bobii
Junior Member
Join Date: Dec 2020
Old 12-13-2020 , 13:55   Re: Questions on "message_begin()"
Reply With Quote #10

Well I think we should focus on the real problem here. For loop there is just a trial. removing the loop and using MSG_ALL or MSG_BROADCAST have the same problem.

The core issue I think is these messages with TEMPENTITY depends on the distance.
It would be very helpful if someone can confirm that.

Other approach will be constantly broadcasting this message on a "thinking forward". Right now this function run inside a "FM_EmitSound"and I think it executes only once. If a client is too far away it simply misses it. But it would be nice to get a comment from someone who has knowledge about these.
bobii is offline
Reply


Thread Tools
Display Modes

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 13:27.


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