Faq
Variables In Csharp
How can I use variables from Streamer.bot in a C# code?
Before using variables from triggers or subactions in a C# code, you will need to import them. Version 0.2.3 introduced a new method CPH.TryGetArg()
that is also best practice to accomplish this.
Example to import the %user%
variable (string) and %cumulative%
(int):
using System;
public class CPHInline
{
public bool Execute()
{
CPH.TryGetArg("user", out string userVar);
CPH.TryGetArg("cumulative", out int cumulative);
return true;
}
}
So "user"
within the quotation marks is our argument and userVar
is the variable name of our C# string. You can also name them the same. If the argument user
does not exist, it will default userVar
to null
. Numeric values are getting defaulted to 0
and bools to False
.