Hi all
I made a new trigger but ever time it runs I get RTE 438.
When I do a debug it points to clsCommands - GetPlayerMaxSP.at this line.

GetPlayerMaxSP = (Player(index).Char(CharNum).Level + Int(GetPlayerSPEED(index) / 2) + Class(Player(index).Char(CharNum).Class).Speed) * 2

In main.txt

Sub SPLossOnAttackNpc(index)
If GetPlayerSP(index) > 0 Then
    Call SetPlayerSP(index, Int(GetPlayerSP(index) - 1))
    Call SendSP(index)
    Call BattleMsg(index, "Your SP went down", 4, 0)
End If
End Sub

In ModGameLogic - AttackNpc

    ' Removes one SP when you attack, you can also set it to 2 or 3.
    If Scripting = 1 Then
       MyScript.ExecuteStatement "Scripts\main.txt", "SPLossOnAttackNpc " & Attacker
    Else
        If GetPlayerSP(Attacker) > 0 Then
            Call SetPlayerSP(Attacker, GetPlayerSP(Attacker) - 1)
            Call SendSP(Attacker)
        End If
    End If