AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Questions on "message_begin()" (https://forums.alliedmods.net/showthread.php?t=329180)

bobii 12-12-2020 02:29

Questions on "message_begin()"
 
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

Natsheh 12-12-2020 10:28

Re: Questions on "message_begin()"
 
Use MSG_ALL instead of MSG_BROADCAST

bobii 12-12-2020 18:31

Re: Questions on "message_begin()"
 
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.

AnimalMonster 12-12-2020 19:03

Re: Questions on "message_begin()"
 
1st yeha you should use MSG_ALL 2nd mind showing the code to see what we can advise you to do?

bobii 12-13-2020 04:06

Re: Questions on "message_begin()"
 
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.

AnimalMonster 12-13-2020 08:11

Re: Questions on "message_begin()"
 
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

HamletEagle 12-13-2020 08:49

Re: Questions on "message_begin()"
 
Quote:

Originally Posted by AnimalMonster (Post 2728652)
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.

AnimalMonster 12-13-2020 08:57

Re: Questions on "message_begin()"
 
Quote:

Originally Posted by HamletEagle (Post 2728662)
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:)

Natsheh 12-13-2020 11:14

Re: Questions on "message_begin()"
 
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

bobii 12-13-2020 13:55

Re: Questions on "message_begin()"
 
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.


All times are GMT -4. The time now is 14:08.

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