Quote:
Originally Posted by NightlyRaine
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 OnActionCreated( BehaviorAction action, int actor, const char[] name )
{
if ( strcmp(name, "SurvivorLegsStayClose") == 0 )
{
action.OnUpdatePost = SurvivorLegsStayClose_OnUpdatePost;
}
}
/* ----------------------------------------------------------------------------------------------------*/
/* SurvivorLegsStayClose */
/* ----------------------------------------------------------------------------------------------------*/
public Action SurvivorLegsStayClose_OnUpdatePost( BehaviorAction action, float interval, ActionResult result )
{
if ( result.IsRequestingChange() )
{
if ( result.action != INVALID_ACTION )
{
char name[ACTION_NAME_LENGTH];
result.action.GetName(name, sizeof name);
PrintToServer( "%s", name );
}
}
return Plugin_Continue;
}
In game Console
PHP Code:
L 03/24/2022 - 16:36:31: [SM] Exception reported: Invalid action passed (66C1B5F0)
L 03/24/2022 - 16:36:31: [SM] Blaming: GetNameExample.smx
L 03/24/2022 - 16:36:31: [SM] Call stack trace:
L 03/24/2022 - 16:36:31: [SM] [0] BehaviorAction.GetName
L 03/24/2022 - 16:36:31: [SM] [1] Line 27, F:\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.