Just started to write first module and stuck.
I'm using map.h to fill a map with certain values.
The code:
Code:
#include <map.h>
#include <string>
#include "amxxmodule.h"
struct Node {
char *name;
char *auth;
char *flags;
int sid;
int fid;
int red;
};
Node node;
std::map<std::string, Node> admin_map;
static cell AMX_NATIVE_CALL admin_list_addadmin(AMX *amx,cell *params)
{
int length;
char *name = MF_GetAmxString(amx, params[1], 0, &length);
char *auth = MF_GetAmxString(amx, params[2], 1, &length);
char *flags = MF_GetAmxString(amx, params[3], 2, &length);
node.name = name;
node.auth = auth;
node.flags = flags;
node.sid = params[4];
node.fid = params[6];
node.red = 0;
MF_Log("Inserting %s with token %s", name, auth);
//admin_map.insert(std::make_pair(auth,node));
admin_map[auth] = node;
return 1;
}
static cell AMX_NATIVE_CALL admin_list_isadmin(AMX *amx,cell *params)
{
return 1;
}
AMX_NATIVE_INFO wtf_exports[] =
{
{ "admin_list_addadmin", admin_list_addadmin },
{ "admin_list_isadmin", admin_list_isadmin },
{ NULL, NULL }
};
void OnAmxxAttach()
{
MF_AddNatives(wtf_exports);
}
The problem is here:
admin_map[auth] = node;
When server starts, it says that module is bad load. When i remove this part of code (admin_map[auth] = node;) and recompile - everything (two natives) works fine.
Any help?
Linux, gcc-4.2.3.
__________________