Skip to content

Error with return and GetNativeCell as any value #401

@Bara

Description

@Bara

Since SM1.11 i can't use this (or similar) anymore return g_bTest[GetNativeCell(1)];, will result into this compile error error 077: arrays cannot be indexed by non-integral type 'any'.

Testcase:

#include <sourcemod>

bool g_bTest[MAXPLAYERS + 1] = { false, ... };

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
    CreateNative("ES_ClientTestError", Native_ClientTestError);
    CreateNative("ES_ClientTestOk", Native_ClientTestOk);
    
    return APLRes_Success;
}

public int Native_ClientTestError(Handle plugin, int numParams)
{
    return g_bTest[GetNativeCell(1)]; // enumstruct.sp(15) : error 077: arrays cannot be indexed by non-integral type 'any'
}

public int Native_ClientTestOk(Handle plugin, int numParams)
{
    return g_bTest[view_as<int>(GetNativeCell(1))]; // That's fine
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions