Raised This Month: $ Target: $400
 0% 

<old>(map.h)<old> <new>problem with chars</new>


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Lightokun
Member
Join Date: Oct 2009
Old 08-10-2011 , 09:10   <old>(map.h)<old> <new>problem with chars</new>
Reply With Quote #1

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.
__________________

Last edited by Lightokun; 08-13-2011 at 06:26.
Lightokun is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode