View Single Post
NightlyRaine
New Member
Join Date: Jan 2020
Location: Kansas USA
Old 03-24-2022 , 17:49   Re: [L4D2] Actions
Reply With Quote #11

This is how I was trying to use GetName(), if I change result.action.GetName(name, sizeof name); to action.GetName(name, sizeof name); it works, but I can't get the result name.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#include <actions>

public void OnActionCreatedBehaviorAction actionint actor, const char[] name )
{
    if ( 
strcmp(name"SurvivorLegsStayClose") == )
    {
        
action.OnUpdatePost SurvivorLegsStayClose_OnUpdatePost;
    }


/* ----------------------------------------------------------------------------------------------------*/
/* SurvivorLegsStayClose */
/* ----------------------------------------------------------------------------------------------------*/
public Action SurvivorLegsStayClose_OnUpdatePostBehaviorAction actionfloat intervalActionResult result )
{    
    if ( 
result.IsRequestingChange() )
    {
        if ( 
result.action != INVALID_ACTION )
        {
            
char name[ACTION_NAME_LENGTH];
            
result.action.GetName(namesizeof name);
            
PrintToServer"%s"name );
        }
    }

    return 
Plugin_Continue;

In game Console
PHP Code:

L 03
/24/2022 16:36:31: [SMException reportedInvalid action passed (66C1B5F0)
L 03/24/2022 16:36:31: [SMBlamingGetNameExample.smx
L 03
/24/2022 16:36:31: [SMCall stack trace:
L 03/24/2022 16:36:31: [SM]   [0BehaviorAction.GetName
L 03
/24/2022 16:36:31: [SM]   [1Line 27F:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\GetNameExample.sp::SurvivorLegsStayClose_OnUpdatePost
133.27
Rochelle:: SurvivorLegsStayClose caused SurvivorLegsStayClose to SUSPEND_FOR SurvivorLegsRegroup  (I'm too far away from the closest human survivor)
133.27: Rochelle::  SUSPENDING SurvivorLegsStayClose
133.27: Rochelle::  SUSPENDING SurvivorLegsMoveOn
133.27: Rochelle::  STARTING SurvivorLegsRegroup
SurvivorLegsRegroup<<SurvivorLegsStayClose( SurvivorLegsMoveOn ) 

And side question, would it be possible to change actions to other existing exactions?
Like when SurvivorLegsMoveOn Suspends_For SurvivorLegsBattleStations, would it be possible to get it to suspend for L4D1SurvivorLegsBattlesStations? Or SurvivorLegsWait? Asking so I know what all is possible.
NightlyRaine is offline