-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.cpp
More file actions
80 lines (65 loc) · 2.28 KB
/
plugin.cpp
File metadata and controls
80 lines (65 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//----------------------------------------------------------
//
// SA-MP Multiplayer Modification For GTA:SA
// Copyright 2004-2009 SA-MP Team
//
//----------------------------------------------------------
#include "amx/amx.h"
#include "plugincommon.h"
#include "natives.h"
//----------------------------------------------------------
typedef void (*logprintf_t)(char* format, ...);
logprintf_t logprintf;
void **ppPluginData;
extern void *pAMXFunctions;
//----------------------------------------------------------
// The Support() function indicates what possibilities this
// plugin has. The SUPPORTS_VERSION flag is required to check
// for compatibility with the server.
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
{
return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
}
//----------------------------------------------------------
// The Load() function gets passed on exported functions from
// the SA-MP Server, like the AMX Functions and logprintf().
// Should return true if loading the plugin has succeeded.
PLUGIN_EXPORT bool PLUGIN_CALL Load( void **ppData )
{
pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
return true;
}
//----------------------------------------------------------
// The Unload() function is called when the server shuts down,
// meaning this plugin gets shut down with it.
PLUGIN_EXPORT void PLUGIN_CALL Unload( )
{
}
//----------------------------------------------------------
// The AmxLoad() function gets called when a new gamemode or
// filterscript gets loaded with the server. In here we register
// the native functions we like to add to the scripts.
PLUGIN_EXPORT int PLUGIN_CALL AmxLoad( AMX *amx )
{
AMX_NATIVE_INFO SpectrumNatives[] =
{
DECL_AMX_MAP(Init),
DECL_AMX_MAP(Free),
DECL_AMX_MAP(PlayStream),
DECL_AMX_MAP(StopStream),
DECL_AMX_MAP(ErrorGetCode),
DECL_AMX_MAP(ChannelGetData),
DECL_AMX_MAP(ChannelGetLevel),
DECL_AMX_MAP(ChannelGetLength),
{ 0, 0 }
};
return amx_Register( amx, SpectrumNatives, -1 );
}
//----------------------------------------------------------
// When a gamemode is over or a filterscript gets unloaded, this
// function gets called. No special actions needed in here.
PLUGIN_EXPORT int PLUGIN_CALL AmxUnload( AMX *amx )
{
return AMX_ERR_NONE;
}