AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D2] The survivor_rescued event can't seem to be prevented (https://forums.alliedmods.net/showthread.php?t=336001)

sorallll 01-20-2022 07:44

[L4D2] The survivor_rescued event can't seem to be prevented
 
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

Marttt 01-20-2022 10:03

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
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.

HarryPotter 01-20-2022 11:40

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
If you don't want to have any rescue room.
use stripper to filter all I guess ?

PHP Code:

filter:
{
    
"classname" "info_survivor_rescue"



Bacardi 01-20-2022 12:20

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
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 :D

sorallll 01-20-2022 12:32

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
2 Attachment(s)
Quote:

Originally Posted by HarryPotter (Post 2768910)
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;



Silvers 01-20-2022 13:36

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
If you want to block the spawn, you need to detour the function for it. Blocking the event won't do that.

sorallll 01-20-2022 14:22

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
Quote:

Originally Posted by Silvers (Post 2768920)
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 01-21-2022 05:37

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
Quote:

Originally Posted by Bacardi (Post 2768913)
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 :D

This is my purpose, thanks

Dragokas 01-22-2022 18:29

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
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.

sorallll 01-22-2022 19:52

Re: [L4D2] The survivor_rescued event can't seem to be prevented
 
Quote:

Originally Posted by Dragokas (Post 2769088)
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


All times are GMT -4. The time now is 01:29.

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