AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Block MSG_ALL SVC_TEMPENTITY for a player (https://forums.alliedmods.net/showthread.php?t=334845)

Natsheh 10-22-2021 19:47

Block MSG_ALL SVC_TEMPENTITY for a player
 
Hello, i would like to know if its possible to block SVC_TEMPENTITY Messages from some players, when the dest is MSG_ALL or MSG_BROADCAST.

HamletEagle 10-23-2021 06:40

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
You can try to hook pfnMessageBegin, check if the second argument(msg_type) is SVC_TEMPENTITY and block the call. Then, block all subsequent calls of pfnWriteByte, pfnWriteChar, pfnWriteShort, pfnWriteLong, pfnWriteAngle, pfnWriteCoord, pfnWriteString, pfnWriteEntity until you encounter a pfnMessageEnd and then stop blocking messages. This is because the start of a message is signaled by pfnMessageBegin and the end by pfnMessageEnd. Between begin and end there are calls to pass arguments that also need to be blocked.

You can do this with orpheu, the same way you hooked pfnSetModel.

Natsheh 10-23-2021 08:12

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
So basically i need to copy all the message subsequent values and msg type then block the message then send the message to the desired clients, right?

DJEarthQuake 10-23-2021 08:33

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
Use set_msg_block if unable to rewrite the source. Remember to use MSG_ONE/MSG_ONE_UNRELIABLE for 'specified clients'. What broadcast?

Natsheh 10-23-2021 08:37

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
Quote:

Originally Posted by DJEarthQuake (Post 2761406)
Use set_msg_block if unable to rewrite the source. Remember to use MSG_ONE/MSG_ONE_UNRELIABLE for 'specified clients'. What broadcast?

You misunderstood what i really want , i don't want to completely block the message i just want to block it from a couple of players.

DJEarthQuake 10-23-2021 08:43

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
Can't do that with broadcast. Try it. Crash.

HamletEagle 10-23-2021 11:03

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
Quote:

Originally Posted by Natsheh (Post 2761404)
So basically i need to copy all the message subsequent values and msg type then block the message then send the message to the desired clients, right?

Yes, so how I would do it is:
1. pfnMessageBegin called, initialize a structure to save message arguments. I would save it a list of (arg type, arg value) where arg type is short, string, entity, coord etc. Also save the message type(MSG_ALL/BROADCAST). Block the call.
2. On each call of pfnWrite* functions add an entry to your list/array, in the format (type, value). Block the calls.
3. On pfnMessageEnd block the original call, send a new message using MSG_ONE/MSG_ONE_UNRELIABLE(depending on if the original message was broadcast/all) to all players EXCEPT the ones you want to ignore. Compose the message back using the information you saved. Clear the list to prepare for a new message.
From pfnMessageEnd hook you may be unable to immediately send another message(needs to be tested). If you can't, add a small delay of 0.1 seconds.

Natsheh 10-23-2021 11:35

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
Thanks, ill try it and be back with a feedback!

But adding a delay seems like a bad idea.

HamletEagle 10-23-2021 12:21

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
I already mentioned the delay should be considered only if you can't immediately send another message from pfnMessageEnd. Either use a small task, a thinking entity that would allow you to think faster than 0.1 seconds or if you are using amxx 1.9+ look into http://amxmodx.org/api/amxmodx/RequestFrame
I repeat, test without any kind of delays. If the server crashes then consider adding a delay.

Natsheh 10-25-2021 15:27

Re: Block MSG_ALL SVC_TEMPENTITY for a player
 
Quote:

Originally Posted by HamletEagle (Post 2761427)
I already mentioned the delay should be considered only if you can't immediately send another message from pfnMessageEnd. Either use a small task, a thinking entity that would allow you to think faster than 0.1 seconds or if you are using amxx 1.9+ look into http://amxmodx.org/api/amxmodx/RequestFrame
I repeat, test without any kind of delays. If the server crashes then consider adding a delay.

Problem solved it worked there was no need for a delay since the message_end & message_begin were blocked.


All times are GMT -4. The time now is 12:59.

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