当前位置: 首页>>代码示例>>C++>>正文


C++ MF_LogError函数代码示例

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


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

示例1: g_fn_GetAmxString

cell AMX_NATIVE_CALL Rage::GetFunctionFromEntity(AMX* amx,cell* params)
{
	int len;
	char *func_name = g_fn_GetAmxString(amx,params[1],0,&len);

	VirtualFunction** virtual_function_ptr = Global::virtualFunctionsManager.get_by_label(func_name);
	
	if(!virtual_function_ptr)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Virtual function %s not registered",func_name);
		return -1;
	}

	VirtualFunction* virtual_function = *virtual_function_ptr;

	int entity = (int) params[2];

	void* object = IndexToPrivate(entity);

	if(!object)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Failed to get private data of entity '%d' for use with virtual function '%s'",entity,func_name);
		return -1;
	}

	return virtual_function->create_get_id(object);
}
开发者ID:Arkshine,项目名称:Rage,代码行数:27,代码来源:rage.cpp

示例2: SQL_NextResultSet

static cell AMX_NATIVE_CALL SQL_NextResultSet(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;
	}

	if (rs->NextResultSet())
	{
		return 1;
	}
	else
	{
		qInfo->info.rs = NULL;
		return 0;
	}
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:27,代码来源:basic_sql.cpp

示例3: rp_add_hook

// rp_add_hook(address, const description[], const handler[], bool:post, flags)
static cell AMX_NATIVE_CALL rp_add_hook(AMX *amx, cell *params)
{
	enum args_e
	{
		arg_count,
		arg_address,
		arg_description,
		arg_handler,
		arg_post,
		arg_flags
	};

	int funcid, len;
	void* addr = (void *)params[arg_address];
	const char* desc = g_amxxapi.GetAmxString(amx, params[arg_description], 0, &len);
	const char* funcname = g_amxxapi.GetAmxString(amx, params[arg_handler], 1, &len);

	if (!addr)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid library handle provided in rp_add_hook(0, \"%s\", \"%s\", ...)", desc, funcname);
		return NULL;
	}

	if (g_amxxapi.amx_FindPublic(amx, funcname, &funcid) != AMX_ERR_NONE)
	{
		setError("Public function \"%s\" not found", funcname);
		MF_LogError(amx, AMX_ERR_NATIVE, "%s", g_lastError);
		return NULL;
	}

	int fwdid = g_amxxapi.RegisterSPForward(amx, funcid, FP_DONE);
	return (cell)g_hookManager.createHook(addr, desc, params[arg_post] == 0, amx, fwdid, params[arg_flags]);
}
开发者ID:Adidasman1,项目名称:repatcher,代码行数:34,代码来源:natives.cpp

示例4: 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

示例5: SQL_FieldNumToName

static cell AMX_NATIVE_CALL SQL_FieldNumToName(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;
	}

	unsigned int col = static_cast<unsigned int>(params[2]);
	const char *namewa = rs->FieldNumToName(col);

	if (!namewa)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
		return 0;
	}

	MF_SetAmxString(amx, params[3], namewa, params[4]);

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

示例6: SQL_ReadResult

static cell AMX_NATIVE_CALL SQL_ReadResult(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 || rs->IsDone())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
		return 0;
	}

	IResultRow *row = rs->GetRow();

	unsigned int col = static_cast<unsigned int>(params[2]);
	if (col >= rs->FieldCount())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
		return 0;
	}

	cell numparams = params[0] / sizeof(cell);
	switch (numparams)
	{
	case 4:
		{
			const char *str = row->GetString(col);
			if (!str)
				str = "";
			cell *len = MF_GetAmxAddr(amx, params[4]);
			MF_SetAmxString(amx, params[3], str, (int)*len);
			break;
		}
	case 3:
		{
			REAL num = row->GetFloat(col);
			cell *addr = MF_GetAmxAddr(amx, params[3]);
			*addr = amx_ftoc(num);
			break;
		}
	case 2:
		{
			int num = row->GetInt(col);
			return num;
			break;
		}
	default:
		{
			MF_LogError(amx, AMX_ERR_NATIVE, "Bad number of arguments passed.");
			break;
		}
	}

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

示例7: SQL_IsNull

static cell AMX_NATIVE_CALL SQL_IsNull(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 || rs->IsDone())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
		return 0;
	}

	unsigned int col = static_cast<unsigned int>(params[2]);
	if (col >= rs->FieldCount())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
		return 0;
	}

	IResultRow *rr = rs->GetRow();

	return rr->IsNull(col) ? 1 : 0;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:28,代码来源:basic_sql.cpp

示例8: cwpn_dmg

// wid,att,vic,dmg,hp=0
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params)
{ 
	int weapon = params[1];

	// only for custom weapons
	if(weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS)
	{ 
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
		return 0;
	}

	int att = params[2];
	CHECK_PLAYER(params[2]);

	int vic = params[3];
	CHECK_PLAYER(params[3]);
	
	int dmg = params[4];
	if(dmg<1)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
		return 0;
	}
	
	int aim = params[5];
	if(aim < 0 || aim > 7)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
		return 0;
	}

	CPlayer* pAtt = GET_PLAYER_POINTER_I(att);
	CPlayer* pVic = GET_PLAYER_POINTER_I(vic);

	pVic->pEdict->v.dmg_inflictor = NULL;

	if(pAtt->index != pVic->index)
		pAtt->saveHit(pVic , weapon , dmg, aim);

	if(!pAtt) 
		pAtt = pVic;

	int TA = 0;

	if((pVic->pEdict->v.team == pAtt->pEdict->v.team) && (pVic != pAtt))
		TA = 1;

	MF_ExecuteForward(iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA);

	if(pVic->IsAlive())
		return 1;

	pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);

	MF_ExecuteForward(iFDeath,pAtt->index, pVic->index, weapon, aim, TA);

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

示例9: rp_get_return

// {_,Float}:rp_get_original_return(...)
static cell AMX_NATIVE_CALL rp_get_return(AMX *amx, cell *params)
{
	if (PARAMS_COUNT == 0)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "%s called without destination parameters.", __FUNCTION__);
		return 0;
	}

	if (!g_currentHandler)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Trying get return value without active hook.");
		return 0;
	}

	auto func = &g_currentHandler->func;
	dword value;
	double fvalue;
	bool success;

	switch (func->getReturnRegister())
	{
	case r_eax:
		success = g_hookManager.getReturn(&value);
		break;
	case r_st0:
		success = g_hookManager.getReturn(&fvalue);
		*(float *)&value = (float)fvalue;
		break;
	default:
		setError("Function without return type.");
		return 0; // no return
	}

	if (!success)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "%s", g_lastError);
		return 0;
	}

	if (PARAMS_COUNT == 2)
	{
		if (func->getReturnType() != bt_string)
		{
			MF_LogError(amx, AMX_ERR_NATIVE, "Return value isn't string.");
			return 0;
		}

		// TODO: implement getting of array via ConvertToAmxArray

		g_amxxapi.SetAmxString(amx, params[1], (char *)value, params[2]);
		return value;
	}

	cell* addr = g_amxxapi.GetAmxAddr(amx, params[1]);
	*addr = ConvertToAmxType(value, func->getReturnType());
	return 1;
}
开发者ID:Adidasman1,项目名称:repatcher,代码行数:58,代码来源:natives.cpp

示例10: csdm_give_item

//shamelessly pulled from fun
static cell AMX_NATIVE_CALL csdm_give_item(AMX *amx, cell *params) // native give_item(index, const item[]); = 2 params
{
	// Check index.
	if (params[1] < 1 || params[1] > gpGlobals->maxClients)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", params[1]);
		return 0;
	} else if (!MF_IsPlayerIngame(params[1])) {
		MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game", params[1]);
		return 0;
	}

	// Get player pointer.
	edict_t *pPlayer = MF_GetPlayerEdict(params[1]);

	// Create item entity pointer
	edict_t	*pItemEntity;

	// Make an "intstring" out of 2nd parameter
	int length;
	const char *szItem = MF_GetAmxString(amx, params[2], 1, &length);

	//check for valid item
	if (strncmp(szItem, "weapon_", 7) && 
		strncmp(szItem, "ammo_", 5) && 
		strncmp(szItem, "item_", 5) &&
		strncmp(szItem, "tf_weapon_", 10)
	) {
		return 0;
	}

	string_t item = ALLOC_STRING(szItem); // Using MAKE_STRING makes "item" contents get lost when we leave this scope! ALLOC_STRING seems to allocate properly...
	pItemEntity = CREATE_NAMED_ENTITY(item);

	if (FNullEnt(pItemEntity)) {
		MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem);
		return 0;
	}

	pItemEntity->v.origin = pPlayer->v.origin;
	pItemEntity->v.spawnflags |= (1 << 30);	//SF_NORESPAWN;

	MDLL_Spawn(pItemEntity);

	int save = pItemEntity->v.solid;

	MDLL_Touch(pItemEntity, ENT(pPlayer));

	if (pItemEntity->v.solid == save)
	{
		REMOVE_ENTITY(pItemEntity);
		//the function did not fail - we're just deleting the item
		return -1;
	}

	return ENTINDEX(pItemEntity);
}
开发者ID:Arkshine,项目名称:CSDM,代码行数:58,代码来源:csdm_natives.cpp

示例11: get_kvd

static cell AMX_NATIVE_CALL get_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;

	switch (params[2])
	{
	case KV_fHandled:
		{
			return kvd->fHandled;
			break;
		}
	case KV_ClassName:
		{
			if (params[0] / sizeof(cell) != 4)
			{
				MF_LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
				return 0;
			}
			cell *ptr = MF_GetAmxAddr(amx, params[4]);
			return MF_SetAmxString(amx, params[3], kvd->szClassName, (int)*ptr);
			break;
		}
	case KV_KeyName:
		{
			if (params[0] / sizeof(cell) != 4)
			{
				MF_LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
				return 0;
			}
			cell *ptr = MF_GetAmxAddr(amx, params[4]);
			return MF_SetAmxString(amx, params[3], kvd->szKeyName, (int)*ptr);
			break;
		}
	case KV_Value:
		{
			if (params[0] / sizeof(cell) != 4)
			{
				MF_LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
				return 0;
			}
			cell *ptr = MF_GetAmxAddr(amx, params[4]);
			return MF_SetAmxString(amx, params[3], kvd->szValue, (int)*ptr);
			break;
		}
	}

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

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

示例12: 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

示例13: custom_wpn_dmg

static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
	int weapon = params[1];
	if (  weapon < MAX_WEAPONS || weapon >= MAX_WEAPONS+MAX_CWEAPONS ||  !weaponData[weapon].used ){ // only for custom weapons
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
		return 0;
	}

	int att = params[2];
	CHECK_PLAYERRANGE(att);

	int vic = params[3];
	CHECK_PLAYERRANGE(vic);
	
	int dmg = params[4];
	if ( dmg<1 ){
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
		return 0;
	}
	
	int aim = params[5];
	if ( aim < 0 || aim > 7 ){
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
		return 0;
	}

	CPlayer* pAtt = GET_PLAYER_POINTER_I(att);
	CPlayer* pVic = GET_PLAYER_POINTER_I(vic);

	pVic->pEdict->v.dmg_inflictor = NULL;
	pAtt->saveHit( pVic , weapon , dmg, aim );

	if ( !pAtt ) pAtt = pVic;
	int TA = 0;
	if ( (pVic->teamId == pAtt->teamId) && ( pVic != pAtt) )
		TA = 1;
	MF_ExecuteForward( iFDamage, static_cast<cell>(pAtt->index),
		static_cast<cell>(pVic->index), static_cast<cell>(dmg), static_cast<cell>(weapon),
		static_cast<cell>(aim), static_cast<cell>(TA) );
	
	if ( pVic->IsAlive() )
		return 1;

	pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
	MF_ExecuteForward( iFDeath, static_cast<cell>(pAtt->index), static_cast<cell>(pVic->index),
		static_cast<cell>(weapon), static_cast<cell>(aim), static_cast<cell>(TA) );

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

示例14: 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

示例15: csdm_respawn

static cell AMX_NATIVE_CALL csdm_respawn(AMX *amx, cell *params)
{
	int index = params[1];

	if (index < 1 || index > gpGlobals->maxClients || !MF_IsPlayerIngame(index))
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", index);
		return 0;
	}

	edict_t *pEdict = MF_GetPlayerEdict(index);

	if (FNullEnt(pEdict))
		return 0;

	int team = GetPlayerTeam(pEdict);
	if (team == TEAM_T || team == TEAM_CT)
	{
		RespawnPlayer(pEdict);
	} else {
		return 0;
	}

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


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