alliedmodders / sourcepawn

A small, statically typed scripting language.
Other
369 stars 63 forks source link

SourceMod API - page, NormalSHook misunderstanding #476

Closed ambaca closed 4 years ago

ambaca commented 4 years ago

From https://sm.alliedmods.net/new-api/

Problem: If I noob try to copy NormalSHook callback https://sm.alliedmods.net/new-api/sdktools_sound/NormalSHook

#include <sdktools>

public void OnPluginStart()
{
    AddNormalSoundHook(shook);
}

public Action shook(int clients[], int& numClients, char sample[], int& entity, int& channel, float& volume, int& level, int& pitch, int& flags, char soundEntry[], int& seed)
{
    PrintToServer("%i %s", entity, sample);
}

I get compile errors

test.sp(10) : error 100: function prototypes do not match
test.sp(13) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')
test.sp(13) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')
test.sp(13) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')
test.sp(13) : fatal error 190: too many error messages on one line




To get right one, get it work; I need go to look from file https://sm.alliedmods.net/new-api/sdktools_sound/__raw to get correct version of NormalSHook

#include <sdktools>

public void OnPluginStart()
{
    AddNormalSoundHook(shook);
}

public Action shook(int clients[MAXPLAYERS], int &numClients, char sample[PLATFORM_MAX_PATH],
      int &entity, int &channel, float &volume, int &level, int &pitch, int &flags,
      char soundEntry[PLATFORM_MAX_PATH], int &seed)
{
    PrintToServer("%i %s", entity, sample);
}
Fyren commented 4 years ago

Closing in favor of #523.