View Single Post
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 03-29-2022 , 14:29   Re: [L4D2] Actions
Reply With Quote #15

Quote:
Originally Posted by NightlyRaine View Post
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.
Just a suggestion, but when writing code, you should define the include files before adding these lines:
Code:
#pragma newdecls required
#pragma semicolon 1
This way, any include files which may be old or do not use semicolons for whatever reason should still allow your plugin to compile without errors.
ThatKidWhoGames is offline