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

Solved [L4D2] The survivor_rescued event can't seem to be prevented


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sorallll
Senior Member
Join Date: Oct 2018
Old 01-20-2022 , 07:44   [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #1

mmsource-1.12.0-git1157-linux
sourcemod-1.11.0-git6843-linux

PHP Code:
HookEvent("survivor_rescued"Event_SurvivorRescuedPreEventHookMode_Pre);
HookEvent("survivor_rescued"Event_SurvivorRescuedPost);

Action Event_SurvivorRescuedPre(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("victim"));
    if(
client == || !IsClientInGame(client))
        return 
Plugin_Continue;

    
LogError("Event_SurvivorRescuedPre->%N"client);
    return 
Plugin_Handled;
}

void Event_SurvivorRescuedPost(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("victim"));
    if(
client == || !IsClientInGame(client))
        return;

    
LogError("Event_SurvivorRescuedPost->%N"client);

Event_SurvivorRescuedPost still fires

Last edited by sorallll; 01-21-2022 at 13:15.
sorallll is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 01-20-2022 , 10:03   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #2

Usually these kind of hook just prevent the notification sometimes won't block the event.
Better give more context on what you are trying to do, and why.
__________________

Last edited by Marttt; 01-20-2022 at 10:16.
Marttt is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 01-20-2022 , 11:40   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #3

If you don't want to have any rescue room.
use stripper to filter all I guess ?

PHP Code:
filter:
{
    
"classname" "info_survivor_rescue"

__________________
HarryPotter is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-20-2022 , 12:20   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #4

Like @Marttt said.

Server create (some) events and send those to player like a announcement, then events appear in client game and perhaps trigger something in client game.

You can block these announcement to clients, but it not work on every event.

Events appear when something is already happened.

------
In your example,
you can't stop server side POST event by blocking PRE hooked event.


But returning Plugin_Stop will block PRE hooked events, even from other plugins (with same event "name").
It depends in which order plugin is loaded, then it will block calls after that.

*edit So, don't use it

Last edited by Bacardi; 01-20-2022 at 12:21.
Bacardi is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 01-20-2022 , 12:32   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #5

Quote:
Originally Posted by HarryPotter View Post
If you don't want to have any rescue room.
use stripper to filter all I guess ?

PHP Code:
filter:
{
    
"classname" "info_survivor_rescue"

I intend to use this method to respawn the player while preventing the survivor_rescued event triggered by this resurrection, but unfortunately it does not work
PHP Code:
// [L4D2] Spawn Survivor Bots (https://forums.alliedmods.net/showthread.php?p=2762460)
bool bRespawnSurvivor(int client, const float vOrigin[3], const float vAngles[3])
{
    
int entity CreateEntityByName("info_survivor_rescue");
    if(
entity == -1)
        return 
false;

    
TeleportEntity(entityvOriginvAnglesNULL_VECTOR);
    
    static 
char sModel[128];
    
GetClientModel(clientsModelsizeof sModel);
    
SetEntityModel(entitysModel);
    
    
DispatchSpawn(entity);
    
ActivateEntity(entity);
    
    
DispatchKeyValue(entity"nextthink""10.0");
    
    
SetEntPropEnt(entityProp_Send"m_survivor"client);
    
AcceptEntityInput(entity"Rescue");
    
RemoveEdict(entity);
    
    
SetEntityHealth(clientGetEntProp(clientProp_Send"m_iMaxHealth"));
    return 
true;

Attached Files
File Type: sp Get Plugin or Get Source (survivor_auto_respawn.sp - 71 views - 24.8 KB)

Last edited by sorallll; 01-20-2022 at 12:35.
sorallll is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-20-2022 , 13:36   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #6

If you want to block the spawn, you need to detour the function for it. Blocking the event won't do that.
__________________
Silvers is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 01-20-2022 , 14:22   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #7

Quote:
Originally Posted by Silvers View Post
If you want to block the spawn, you need to detour the function for it. Blocking the event won't do that.
It looks like it's going to be troublesome
sorallll is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 01-21-2022 , 05:37   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
Like @Marttt said.

Server create (some) events and send those to player like a announcement, then events appear in client game and perhaps trigger something in client game.

You can block these announcement to clients, but it not work on every event.

Events appear when something is already happened.

------
In your example,
you can't stop server side POST event by blocking PRE hooked event.


But returning Plugin_Stop will block PRE hooked events, even from other plugins (with same event "name").
It depends in which order plugin is loaded, then it will block calls after that.

*edit So, don't use it
This is my purpose, thanks
sorallll is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 01-22-2022 , 18:29   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #9

sorallll, Can you explain what is this topic for? I mean, XYZ, why do you want to block survivor_rescued event?

Also, why not use CTerrorPlayer::RoundRespawn, like done here. You can try natives from there.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 01-22-2022 at 18:33.
Dragokas is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 01-22-2022 , 19:52   Re: [L4D2] The survivor_rescued event can't seem to be prevented
Reply With Quote #10

Quote:
Originally Posted by Dragokas View Post
sorallll, Can you explain what is this topic for? I mean, XYZ, why do you want to block survivor_rescued event?

Also, why not use CTerrorPlayer::RoundRespawn, like done here. You can try natives from there.
I'm using your method now
sorallll 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 18:11.


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