• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MF_GetAmxString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MF_GetAmxString函数的典型用法代码示例。如果您正苦于以下问题:C++ MF_GetAmxString函数的具体用法?C++ MF_GetAmxString怎么用?C++ MF_GetAmxString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MF_GetAmxString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: regex_replace

//native regex_replace(Regex:pattern, string[], maxLen, const replace[], flags = REGEX_FORMAT_DEFAULT, &errcode = 0);
static cell AMX_NATIVE_CALL regex_replace(AMX *amx, cell *params)
{
	int id = params[1] - 1;
	if (id >= (int)PEL.length() || id < 0 || PEL[id]->isFree())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
		return 0;
	}

	int textLen, replaceLen;
	char *text = MF_GetAmxString(amx, params[2], 0, &textLen);
	const char *replace = MF_GetAmxString(amx, params[4], 1, &replaceLen);

	cell *erroCode = MF_GetAmxAddr(amx, params[6]);

	RegEx *x = PEL[id]; 
	int e = x->Replace(text, params[3] + 1, replace, replaceLen, params[5]);

	if (e == -1)
	{
		*erroCode = x->mErrorOffset;
		x->ClearMatch();
		return -2;
	}
	else if (e == 0)
	{
		*erroCode = 0;
		x->ClearMatch();
		return 0;
	}

	MF_SetAmxString(amx, params[2], text, params[3]);

	return e;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:36,代码来源:module.cpp


示例2: find_ent_by_model

static cell AMX_NATIVE_CALL find_ent_by_model(AMX *amx, cell *params) { 
	int iStart = params[1];
	int iLength, iLength2;
	char *szClass = MF_GetAmxString(amx, params[2], 0, &iLength);
	char *szModel = MF_GetAmxString(amx, params[3], 1, &iLength2);

	edict_t *pStart;

	if (iStart == -1)
	{
		pStart = NULL;
	} else {
		if (!is_ent_valid(iStart))
			pStart = NULL;
		else
			pStart = INDEXENT2(iStart);
	}

	edict_t *pEdict = FIND_ENTITY_BY_STRING(pStart, "classname", szClass);

	const char *check;

	while (pEdict && !FNullEnt(pEdict))
	{
		check = STRING(pEdict->v.model);
		if (!check || strcmp(check, szModel))
			pEdict = FIND_ENTITY_BY_STRING(pEdict, "classname", szClass);
		else
			return ENTINDEX(pEdict);
	}

	return 0;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:33,代码来源:entity.cpp


示例3: socket_listen_t

// native socket_listen_t( rc, hostname, port, protocol, recvhandler ) // Give access to iMaxConnections also ?
static cell AMX_NATIVE_CALL socket_listen_t(AMX *amx, cell *params)  /* 5 param */
{
	if( !params[1] )
		return -1;

	// Get SocketThread form param[1]
	CThreadedSocketItem* SocketThread = (CThreadedSocketItem *)params[1];
	
    int len;
	char* szTempHostnam = MF_GetAmxString(amx,params[2],0,&len);
	if( SocketThread->Hostname != NULL )
	{
		delete [] SocketThread->Hostname;
		SocketThread->Hostname = NULL;
	}
	SocketThread->Hostname = new char [len+1];
	// Copy Hostname
	strcpy( SocketThread->Hostname, szTempHostnam );
	SocketThread->Hostname[len] = '\0';

	SocketThread->port = params[3];
	SocketThread->protocol = params[4];	
	
	// Register Forward and save fwdID in fid array
	SocketThread->fIDs[FID_LISTEN] = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[5], 0, &len), FP_CELL, FP_CELL, FP_DONE);
	if( SocketThread->fIDs[FID_LISTEN] < 0 )
	{
		return -2; // Could not find Public CallBack function to register it
	}
	
	// Since all the required data is set, Run the thread in required state
	SocketThread->ThreadState(STATE_LISTEN);

	return 0;
}
开发者ID:ShootingKing-AM,项目名称:ThreadedSockets,代码行数:36,代码来源:sockets.cpp


示例4: register_touch

static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params)
{
	int len;

	char *Toucher = MF_GetAmxString(amx, params[1], 0, &len);
	char *Touched = MF_GetAmxString(amx, params[2], 1, &len);

	Touch *p = new Touch;

	if (!strlen(Toucher) || strcmp(Toucher, "*")==0) {
		p->Toucher.assign("");
	} else {
		p->Toucher.assign(Toucher);
	}
	if (!strlen(Touched) || strcmp(Touched, "*")==0) {
		p->Touched.assign("");
	} else {
		p->Touched.assign(Touched);
	}

	p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[3], 2, &len), FP_CELL, FP_CELL, FP_DONE);

	Touches.push_back(p);

	if (!g_pFunctionTable->pfnTouch)
		g_pFunctionTable->pfnTouch=pfnTouch;

	return p->Forward;
}
开发者ID:9iky6,项目名称:amxmodx,代码行数:29,代码来源:engine.cpp


示例5: register_cwpn

// name,logname,melee=0 
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params)
{ 
	int i;
	bool bFree = false;

	for(i = DODMAX_WEAPONS - DODMAX_CUSTOMWPNS; i < DODMAX_WEAPONS; i++)
	{
		if(!weaponData[i].needcheck)
		{
			bFree = true;
			break;
		}
	}

	if(!bFree)
		return 0;

	int iLen;
	char *szName = MF_GetAmxString(amx, params[1], 0, &iLen);
	char *szLogName = MF_GetAmxString(amx, params[3], 0, &iLen);

	strcpy(weaponData[i].name,szName);
	strcpy(weaponData[i].logname,szLogName);
	weaponData[i].needcheck = true;
	weaponData[i].melee = params[2] ? true:false;
	return i;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:28,代码来源:NBase.cpp


示例6: set_kvd

static cell AMX_NATIVE_CALL set_kvd(AMX *amx, cell *params)
{
	KVD_Wrapper *kvdw;
	KeyValueData *kvd;
	if (params[1] == 0)
		kvdw = &g_kvd_glb;
	else
		kvdw = reinterpret_cast<KVD_Wrapper *>(params[1]);
	kvd = kvdw->kvd;

	if (*params / sizeof(cell) < 3)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "No data passed");
		return 0;
	}

	cell *ptr = MF_GetAmxAddr(amx, params[3]);
	int len;

	switch (params[2])
	{
	case KV_fHandled:
		{
			kvd->fHandled = (int)*ptr;
			return 1;
			break;
		}
	case KV_ClassName:
		{
			kvdw->cls = MF_GetAmxString(amx, params[3], 0, &len);
			kvd->szClassName = const_cast<char *>(kvdw->cls.chars());
			return 1;
			break;
		}
	case KV_KeyName:
		{
			kvdw->key = MF_GetAmxString(amx, params[3], 0, &len);
			kvd->szKeyName = const_cast<char *>(kvdw->key.chars());
			return 1;
			break;
		}
	case KV_Value:
		{
			kvdw->val = MF_GetAmxString(amx, params[3], 0, &len);
			kvd->szValue = const_cast<char *>(kvdw->val.chars());
			return 1;
			break;
		}
	}

	MF_LogError(amx, AMX_ERR_NATIVE, "Invalid KeyValueData member: %d", params[2]);

	return 0;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:54,代码来源:fm_tr2.cpp


示例7: Call_Int_Str_Str

cell Call_Int_Str_Str(AMX* amx, cell* params)
{
	SETUP(2);

	char *sz3=MF_GetAmxString(amx, params[3], 0, NULL);
	char *sz4=MF_GetAmxString(amx, params[4], 1, NULL);

#if defined(_WIN32)
	return reinterpret_cast<int (__fastcall *)(void*, int, const char *, const char *)>(__func)(pv, 0, sz3, sz4);
#elif defined(__linux__) || defined(__APPLE__)
	return reinterpret_cast<int (*)(void *, const char *, const char *)>(__func)(pv, sz3, sz4);
#endif
}
开发者ID:reuben,项目名称:amxmodx,代码行数:13,代码来源:call_funcs.cpp


示例8: set_lights

// SetLights, this sets the lights for the map.
//(vexd)
static cell AMX_NATIVE_CALL set_lights(AMX *amx, cell *params) { 
	int iLength;
	char *szLights = MF_GetAmxString(amx, params[1], 0, &iLength);

	if (FStrEq(szLights, "#OFF")) {
		glinfo.bCheckLights = false;
		g_pFunctionTable_Post->pfnStartFrame = NULL;
		memset(glinfo.szLastLights, 0x0, 128);
		(g_engfuncs.pfnLightStyle)(0, glinfo.szRealLights);
		return 1;
	}
	
	g_pFunctionTable_Post->pfnStartFrame = StartFrame_Post;
	glinfo.bCheckLights = true;

	//Reset LastLights
	memset(glinfo.szLastLights, 0x0, 128);
	//Store the previous lighting.
	memcpy(glinfo.szLastLights, szLights, strlen(szLights));

	(g_engfuncs.pfnLightStyle)(0, szLights);

	// These make it so that players/weaponmodels look like whatever the lighting is
	// at. otherwise it would color players under the skybox to these values.
	SERVER_COMMAND("sv_skycolor_r 0\n");
	SERVER_COMMAND("sv_skycolor_g 0\n");
	SERVER_COMMAND("sv_skycolor_b 0\n");

	return 1;
}
开发者ID:9iky6,项目名称:amxmodx,代码行数:32,代码来源:engine.cpp


示例9: SQL_QuoteString

static cell AMX_NATIVE_CALL SQL_QuoteString(AMX *amx, cell *params)
{
	int len;
	char *str = MF_GetAmxString(amx, params[4], 0, &len);
	size_t newsize;
	static char buffer[8192];

	if (params[1] != 0)
	{
		IDatabase *pDb = (IDatabase *)GetHandle(params[1], Handle_Database);
		if (!pDb)
		{
			MF_LogError(amx, AMX_ERR_NATIVE, "Invalid database handle: %d", params[1]);
			return 0;
		}

		if (pDb->QuoteString(str, buffer, sizeof(buffer)-1, &newsize) == 0)
		{
			MF_SetAmxString(amx, params[2], buffer, params[3]);
			return newsize;
		} else {
			return -1;
		}
	} else {
		if (g_Sqlite.QuoteString(str, buffer, sizeof(buffer)-1, &newsize) == 0)
		{
			MF_SetAmxString(amx, params[2], buffer, params[3]);
			return newsize;
		} else {
			return -1;
		}
	}
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:33,代码来源:basic_sql.cpp


示例10: SQL_MakeDbTuple

static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amx, cell *params)
{
	SQL_Connection *sql = new SQL_Connection;
	int len;

	sql->port = 0;
	sql->host = strdup("");
	sql->user = strdup("");
	sql->pass = strdup("");

	char *db = MF_GetAmxString(amx, params[4], 0, &len);
	char path[255];
	FILE *fp;

	MF_BuildPathnameR(path, sizeof(path)-1, "%s", db);
	if ((fp=fopen(path, "rb")))
	{
		fclose(fp);
		sql->db = strdup(path);
	} else {
		MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3",
			MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
			db);
		sql->db = strdup(path);
	}

	unsigned int num = MakeHandle(sql, Handle_Connection, FreeConnection);

	return num;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:30,代码来源:basic_sql.cpp


示例11: ns_giveitem

// ns_giveiteM(id,"item");
static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
{
	CreatePlayerPointer(amx,params[1]);

	char *classname = MF_GetAmxString(amx,params[2],0,NULL);

	if (!player->IsConnected())
	{
		return 0;
	}
	if (player->GetPev()->deadflag > 0)
	{
		return 0;
	}

	edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING2(classname));

	if (!object)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Error creating entity \"%s\"", classname);
		return 0;
	}

	SET_ORIGIN(object,player->GetPev()->origin);						// move to player
	gpGamedllFuncs->dllapi_table->pfnSpawn(object);						// emulate spawn
	object->v.flags |= FL_ONGROUND;										// make it think it's touched the ground
	gpGamedllFuncs->dllapi_table->pfnThink(object);						// 
	gpGamedllFuncs->dllapi_table->pfnTouch(object,player->GetEdict());	// give it to the player

	return 1;
}
开发者ID:reuben,项目名称:amxmodx,代码行数:32,代码来源:player.cpp


示例12: Call_Void_Str_Str_Int

cell Call_Void_Str_Str_Int(AMX *amx, cell *params)
{
	SETUP(3);

	char *sz3=MF_GetAmxString(amx, params[3], 0, NULL);
	char *sz4=MF_GetAmxString(amx, params[4], 1, NULL);
	int i5=*MF_GetAmxAddr(amx, params[5]);

#if defined(_WIN32)
	reinterpret_cast<void (__fastcall *)(void*, int, const char *, const char *, int)>(__func)(pv, 0, sz3, sz4, i5);
#elif defined(__linux__) || defined(__APPLE__)
	reinterpret_cast<void (*)(void *, const char *, const char *, int)>(__func)(pv, sz3, sz4, i5);
#endif

	return 1;
}
开发者ID:reuben,项目名称:amxmodx,代码行数:16,代码来源:call_funcs.cpp


示例13: SQL_FieldNameToNum

static cell AMX_NATIVE_CALL SQL_FieldNameToNum(AMX *amx, cell *params)
{
	AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
	if (!qInfo)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
		return 0;
	}

	IResultSet *rs = qInfo->info.rs;

	if (!rs)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
		return 0;
	}

	int len;
	char *namewa = MF_GetAmxString(amx, params[2], 0, &len);
	unsigned int columnId;
	if (!rs->FieldNameToNum(namewa, &columnId))
	{
		return -1;
	}

	return columnId;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:27,代码来源:basic_sql.cpp


示例14: csdm_reload_cfg

static cell AMX_NATIVE_CALL csdm_reload_cfg(AMX *amx, cell *params)
{
	char file[255];

	file[0] = '\0';

	if  (params[0] / sizeof(cell) != 0)
	{
		int len;
		char *str = MF_GetAmxString(amx, params[1], 0, &len);
		if (str[0] != '\0')
		{
			MF_BuildPathnameR(file, sizeof(file)-1, "%s/%s", LOCALINFO("amxx_configsdir"), str);
		}
	}

	if (file[0] == '\0')
	{
		MF_BuildPathnameR(file, sizeof(file)-1, "%s/csdm.cfg", LOCALINFO("amxx_configsdir"));
	}

	if (g_Config.ReadConfig(file) != Config_Ok)
	{
		MF_Log("Could not read config file: %s", file);
		return 0;
	}

	return 1;
}
开发者ID:Arkshine,项目名称:CSDM,代码行数:29,代码来源:csdm_natives.cpp


示例15: fm_return

static cell AMX_NATIVE_CALL fm_return(AMX *amx, cell *params)
{
	int len;
	switch (params[1])
	{
	case FMV_STRING:
		{
			mStringResult = STRING(ALLOC_STRING(MF_GetAmxString(amx, params[2], 0 ,&len)));
			break;
		}
	case FMV_FLOAT:
		{
			mFloatResult = amx_ctof(*(MF_GetAmxAddr(amx,params[2])));
			break;
		}
	case FMV_CELL:
		{
			mCellResult = *(MF_GetAmxAddr(amx,params[2]));
			break;
		}
	default:
		{
		return 0;
		break;
		}
	}

	retType = params[1];

	return 1;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:31,代码来源:forward.cpp


示例16: amx_geoip_region_code

// native geoip_region_code(const ip[], result[], len);
static cell AMX_NATIVE_CALL amx_geoip_region_code(AMX *amx, cell *params)
{
	int length;
	int finalLength = 0;
	char code[12]; // This should be largely enough to hold xx-yyyy and more if needed.

	char *ip = stripPort(MF_GetAmxString(amx, params[1], 0, &length));

	const char *pathCountry[] = { "country", "iso_code", NULL };
	const char *countryCode = lookupString(ip, pathCountry, &length);

	if (countryCode)
	{
		finalLength = length + 1; // + 1 for dash.
		ke::SafeSprintf(code, finalLength + 1, "%s-", countryCode); // + EOS.

		const char *pathRegion[] = { "subdivisions", "0", "iso_code", NULL }; // First result.
		const char *regionCode = lookupString(ip, pathRegion, &length);

		if (regionCode)
		{
			finalLength += length;
			strncat(code, regionCode, length);
		}
		else
		{
			finalLength = 0;
		}
	}

	return MF_SetAmxString(amx, params[2], finalLength ? code : "", ke::Min(finalLength, params[3]));
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:33,代码来源:geoip_natives.cpp


示例17: amx_geoip_code3_ex

// native bool:geoip_code3_ex(const ip[], result[4]);
static cell AMX_NATIVE_CALL amx_geoip_code3_ex(AMX *amx, cell *params)
{
	int length;
	char *ip = stripPort(MF_GetAmxString(amx, params[1], 0, &length));

	const char *path[] = { "country", "iso_code", NULL };
	const char *code = lookupString(ip, path, &length);

	if (!code)
	{
		return 0;
	}

	for (size_t i = 0; i < ARRAYSIZE(GeoIPCountryCode); ++i)
	{
		if (!strncmp(code, GeoIPCountryCode[i], 2))
		{
			code = GeoIPCountryCode3[i];
			break;
		}
	}

	MF_SetAmxString(amx, params[2], code, 3);

	return 1;
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:27,代码来源:geoip_natives.cpp


示例18: SQL_SetAffinity

static cell AMX_NATIVE_CALL SQL_SetAffinity(AMX *amx, cell *params)
{
	int len;
	char *str = MF_GetAmxString(amx, params[1], 0, &len);

	if (!str[0])
	{
		return 1;
	}

	if (stricmp(str, g_Sqlite.NameString()) == 0)
	{
		return 1;
	}

	SqlFunctions *pFuncs = (SqlFunctions *)MF_RequestFunction(SQL_DRIVER_FUNC);
	while (pFuncs)
	{
		if (pFuncs->driver->IsCompatDriver(str))
		{
			return pFuncs->set_affinity(amx);
		}
		pFuncs = pFuncs->prev;
	}

	return 0;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:27,代码来源:basic_sql.cpp


示例19: find_ent_by_owner

static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params)  // native find_ent_by_owner(start_from_ent, classname[], owner_index); = 3 params
{
	int iEnt = params[1];
	int oEnt = params[3];
	// Check index to start searching at, 0 must be possible for iEnt.
	CHECK_ENTITY_SIMPLE(oEnt);

	edict_t *pEnt = INDEXENT2(iEnt);
	edict_t *entOwner = INDEXENT2(oEnt);

	//optional fourth parameter is for jghg2 compatibility
	const char* sCategory = NULL; 
	switch(params[4]){ 
		case 1: sCategory = "target"; break; 
		case 2: sCategory = "targetname"; break; 
		default: sCategory = "classname"; 
	}

	// No need to check if there is a real ent where entOwner points at since we don't access it anyway.

	int len;
	char* classname = MF_GetAmxString(amx, params[2], 0, &len);

	while (true) {
		pEnt = FIND_ENTITY_BY_STRING(pEnt, sCategory, classname);
		if (FNullEnt(pEnt)) // break and return 0 if bad
			break;
		else if (pEnt->v.owner == entOwner) // compare pointers
			return ENTINDEX(pEnt);
	}

	// If it comes here, the while loop ended because an ent failed (FNullEnt() == true)
	return 0;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:34,代码来源:entity.cpp


示例20: csdm_setstyle

static cell AMX_NATIVE_CALL csdm_setstyle(AMX *amx, cell *params)
{
	int len;
	char *name = MF_GetAmxString(amx, params[1], 0, &len);

	if (strcmp(name, "none") == 0)
	{
		g_SpawnMethod = -1;
		return 1;
	}

	SpawnMethod *pSpawn = NULL;

	for (size_t i=0; i<g_SpawnMngr.Spawns(); i++)
	{
		pSpawn = g_SpawnMngr.GetSpawn(i);
		if (strcmpi(pSpawn->GetName(), name) == 0)
		{
			g_SpawnMethod = i;
			return 1;
		}
	}

	return 0;
}
开发者ID:Arkshine,项目名称:CSDM,代码行数:25,代码来源:csdm_natives.cpp



注:本文中的MF_GetAmxString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MF_LogError函数代码示例发布时间:2022-05-30
下一篇:
C++ MF_GetAmxAddr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap