Beispiel #1
0
/*
	iuser3 = 0 standing up
	iuser3 = 1 going prone or mg tearing down
	iuser3 = 2 setting up mg while laying down
*/
void CPlayer::PreThink()
{
	if(!ingame || ignoreBots(pEdict))
		return;

	if(oldteam != pEdict->v.team && iFTeamForward != -1)
		MF_ExecuteForward(iFTeamForward, index, pEdict->v.team, oldteam);

	if(oldclass != pEdict->v.playerclass && iFClassForward != -1)
		MF_ExecuteForward(iFClassForward, index, pEdict->v.playerclass, oldclass);

	if(oldprone != pEdict->v.iuser3 && oldprone != 2 && pEdict->v.iuser3 != 2 && iFProneForward != -1)
		MF_ExecuteForward(iFProneForward, index, pEdict->v.iuser3);

	if(oldstamina > pEdict->v.fuser4 && iFStaminaForward != -1)
		MF_ExecuteForward(iFStaminaForward, index, ((int)pEdict->v.fuser4));

	if(wpns_bitfield != pEdict->v.weapons)
		WeaponsCheck(pEdict->v.weapons & ~(1<<31));

	// Set the old variables for 
	oldprone = pEdict->v.iuser3;
	oldteam = pEdict->v.team;
	oldclass = pEdict->v.playerclass;
	oldstamina = pEdict->v.fuser4;

	wpns_bitfield = pEdict->v.weapons & ~(1<<31);
}
Beispiel #2
0
// 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;
}
Beispiel #3
0
void StartFrame()
{
	if (StartFrameForward != -1)
		MF_ExecuteForward(StartFrameForward);
	else if (VexdServerForward != -1)
		MF_ExecuteForward(VexdServerForward);

	RETURN_META(MRES_IGNORED);
}
Beispiel #4
0
//public QueryHandler(state, Handle:query, error[], errnum, data[], size)
void MysqlThread::Execute()
{
	cell data_addr;
	if (m_datalen)
	{
		data_addr = MF_PrepareCellArray(m_data, m_datalen);
	} else {
		static cell tmpdata[1] = {0};
		data_addr = MF_PrepareCellArray(tmpdata, 1);
	}
	int state = 0;
	if (!m_qrInfo.connect_success)
	{
		state = -2;
	} else if (!m_qrInfo.query_success) {
		state = -1;
	}
	float diff = gpGlobals->time - m_qrInfo.queue_time;
	cell c_diff = amx_ftoc(diff);
	unsigned int hndl = MakeHandle(&m_qrInfo.amxinfo, Handle_Query, NullFunc);
	if (state != 0)
	{
		MF_ExecuteForward(m_fwd, 
			(cell)state, 
			(cell)hndl, 
			m_qrInfo.amxinfo.error, 
			m_qrInfo.amxinfo.info.errorcode,
			data_addr,
			m_datalen,
			c_diff);
	} else {
		MF_ExecuteForward(m_fwd,
			(cell)0,
			(cell)hndl,
			"",
			(cell)0,
			data_addr,
			m_datalen,
			c_diff);
	}
		FreeHandle(hndl);
	if (m_qrInfo.amxinfo.pQuery)
	{
		m_qrInfo.amxinfo.pQuery->FreeHandle();
		m_qrInfo.amxinfo.pQuery = NULL;
	}
	delete [] m_qrInfo.amxinfo.opt_ptr;
	m_qrInfo.amxinfo.opt_ptr = NULL;
}
Beispiel #5
0
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;
}
void CThreadedSockets::recvData()
{
	// Call CSocket function and return the result in CallBack parameter

	// Check if some data is waiting for us to be read
	if( Socket->CheckSocket() )
	{
		printf( "in CThreSocks::recvData, calling CSocket function\n" );
		int ret = Socket->socketRecv(&szRecvData, iRecvDatalen);	
		printf( "in CThreSocks::recvData, szRecvData - %s[%d]\n", szRecvData, iRecvDatalen );
		printf( "in CThreSocks::recvData, calling callback function\n" );
		printf( "in CThreSocks::recvData, setting state to idle\n" );
		// Set STATE_IDLE only if the connection is closed or error or someone else didnot change to otherstate 
		if((ret <= 0) && (State == STATE_READ))
			State = STATE_IDLE;
		
		// Therefore, the call back is triggered until the Data is completely extracted from the socket
		int retVal = MF_ExecuteForward(fIDs[FID_RECV], (cell)STATE_READ, (cell)ret, szRecvData, (cell)iRecvDatalen);

		// Now for dynamically changing buffer length...
		if( retVal > 0 )
			iRecvDatalen = retVal;
		
		printf( "in CThreSocks::recvData, ExecuteForward returned %d with fid %d\n", retVal, fIDs[FID_RECV]);
	}	
}
void CThreadedSockets::listensocket()
{
	printf( "in CThreSocks::listensocket, calling CSocket function\n" );
	// Call CSocket function and return the result in CallBack parameter
	int ret = Socket->socketListen(Hostname, port, protocol);
	MF_ExecuteForward(fIDs[FID_LISTEN], (cell)STATE_LISTEN, (cell)ret);
}
void CThreadedSockets::openSocket()
{
	printf( "SOcket initialisation -- %p\n", Socket );
	// Call CSocket function and return the result in CallBack parameter
	int ret = Socket->socketOpen(Hostname, port, protocol);
	printf( "in CThreSocks::openSocket, ExecuteForward returned %d\n", MF_ExecuteForward(fIDs[FID_OPEN], (cell)STATE_CONNECT, (cell)ret));
}
Beispiel #9
0
void FakespawnPlayer(edict_t *pEdict)
{
	int team = GetPlayerTeam(pEdict);

	if (team != TEAM_T && team != TEAM_CT)
	{
		return;
	}

	int index = ENTINDEX(pEdict);

	player_states *pPlayer = GET_PLAYER(index);

	if (pPlayer->spawning)
		return;

	pPlayer->spawning = true;

	if (g_PreSpawn > 0  && MF_ExecuteForward(g_PreSpawn, (cell)index, (cell)1) > 0)
	{
		pPlayer->spawning = false;
		return;
	}

	SpawnHandler(index, true);
	pPlayer->spawning = false;
}
Beispiel #10
0
bool NotifyForRemove(unsigned int owner, edict_t *ent, edict_t *box)
{
	cell idx1 = (cell)ENTINDEX(ent);
	cell idx2 = box ? (cell)ENTINDEX(box) : 0;

	return (MF_ExecuteForward(g_RemoveWeapon, (cell)owner, idx1, idx2) == 0);
}
void FailPlugin(AMX *amx, int id, int err, const char *reason)
{
	int fwd=MF_RegisterSPForwardByName(amx, "__fatal_ham_error", FP_CELL, FP_CELL, FP_STRING, FP_DONE);

	MF_ExecuteForward(fwd, id, err, reason);

	MF_UnregisterSPForward(fwd);
}
Beispiel #12
0
int Detour_ClientCommand(edict_t *pEdict)
{
	if (*g_UseBotArgs)
	{
		int client = ENTINDEX(pEdict);
		const char *args = *g_BotArgs;
		return MF_ExecuteForward(g_CSCliCmdFwd, (cell)client, args);
	}
	return 0;
}
Beispiel #13
0
void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed)
{
	unsigned int i = 0;
	int retVal = 0;
	edict_t *pEntity = (edict_t *)player;
	g_cmd = (struct usercmd_s *)_cmd;
	int origImpulse = g_cmd->impulse; // incase a plugin alters it
	for (i=0; i<Impulses.length(); i++)
	{
		if (Impulses[i]->Check == g_cmd->impulse)
		{
			retVal = MF_ExecuteForward(Impulses[i]->Forward, (cell)ENTINDEX(pEntity), (cell)origImpulse);
			
			// don't return SUPERCEDE in any way here, 
			// we don't want to break client_impulse forward and access to cmd with [g/s]et_usercmd
			if (retVal)
				g_cmd->impulse = 0;
		}
	}

	// client_impulse
	if (ClientImpulseForward != -1 && origImpulse != 0) 
	{
		retVal = MF_ExecuteForward(ClientImpulseForward, (cell)ENTINDEX(pEntity), (cell)origImpulse);

		if (retVal)
			g_cmd->impulse = 0;
	}

	// client_CmdStart
	if (CmdStartForward != -1)
	{
		incmd = true;
		retVal = MF_ExecuteForward(CmdStartForward, (cell)ENTINDEX(pEntity));
		incmd = false;

		if (retVal)
			RETURN_META(MRES_SUPERCEDE);
	}

	RETURN_META(MRES_IGNORED);
}
Beispiel #14
0
void FFA_Disable()
{
	// unpatch!
	DoUnPatch(&g_takedmg_patches);
	DoUnPatch(&g_pkilled_patches);
	g_ffa_state = false;
	//we don't care about efficiency here
	CVAR_SET_FLOAT("mp_friendlyfire", g_last_ff_set);
	CVAR_SET_STRING("mp_freeforall", "0");
	MF_ExecuteForward(g_StateChange, CSDM_FFA_DISABLE);
}
Beispiel #15
0
void FFA_Enable()
{
	// patch!
	DoPatch(&g_takedmg_patches);
	DoPatch(&g_pkilled_patches);
	g_ffa_state = true;
	//we don't care about efficiency here
	g_last_ff_set = CVAR_GET_FLOAT("mp_friendlyfire");
	CVAR_SET_FLOAT("mp_friendlyfire", 1.0f);
	CVAR_SET_STRING("mp_freeforall", "1");
	MF_ExecuteForward(g_StateChange, CSDM_FFA_ENABLE);
}
Beispiel #16
0
void ClientKill(edict_t *pEntity)
{
	int retVal = 0;

	if (ClientKillForward != -1) {
		retVal = MF_ExecuteForward(ClientKillForward, (cell)ENTINDEX(pEntity));
		if (retVal)
			RETURN_META(MRES_SUPERCEDE);
	}

	RETURN_META(MRES_IGNORED);
}
Beispiel #17
0
void pfnTouch(edict_t *pToucher, edict_t *pTouched)
{
	unsigned int i = 0;
	int retVal = 0;
	const char *ptrClass = STRING(pToucher->v.classname);
	const char *ptdClass = STRING(pTouched->v.classname);
	int ptrIndex = ENTINDEX(pToucher);
	int ptdIndex = ENTINDEX(pTouched);
	META_RES res=MRES_IGNORED;
	for (i=0; i<Touches.length(); i++)
	{
		if (Touches[i]->Toucher.isVoid())
		{
			if (Touches[i]->Touched.isVoid())
			{
				retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
				if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
					RETURN_META(MRES_SUPERCEDE);
				else if (retVal)
					res=MRES_SUPERCEDE;
			} else if (Touches[i]->Touched.compare(ptdClass)==0) {
				retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
				if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
					RETURN_META(MRES_SUPERCEDE);
				else if (retVal)
					res=MRES_SUPERCEDE;
			}
		} else if (Touches[i]->Toucher.compare(ptrClass)==0) {
			if (Touches[i]->Touched.isVoid())
			{
				retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
				if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
					RETURN_META(MRES_SUPERCEDE);
				else if (retVal)
					res=MRES_SUPERCEDE;
			} else if (Touches[i]->Touched.compare(ptdClass)==0) {
				retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
				if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
					RETURN_META(MRES_SUPERCEDE);
				else if (retVal)
					res=MRES_SUPERCEDE;
			}
		}
	}
	/* Execute pfnTouch forwards */
	if (pfnTouchForward != -1) {
		retVal = MF_ExecuteForward(pfnTouchForward, (cell)ptrIndex, (cell)ptdIndex);
		if (retVal)
			RETURN_META(MRES_SUPERCEDE);
	}
	if (VexdTouchForward != -1) {
		retVal = MF_ExecuteForward(VexdTouchForward, (cell)ptrIndex, (cell)ptdIndex);
		if (retVal)
			RETURN_META(MRES_SUPERCEDE);
	}

	RETURN_META(res);
}
Beispiel #18
0
void Think(edict_t *pent)
{
	unsigned int i = 0;
	const char *cls = STRING(pent->v.classname);
	META_RES res=MRES_IGNORED;
	int retVal=0;
	for (i=0; i<Thinks.length(); i++)
	{
		if (Thinks[i]->Class.compare(cls)==0)
		{
			retVal=MF_ExecuteForward(Thinks[i]->Forward, (cell)ENTINDEX(pent));
			if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
				RETURN_META(MRES_SUPERCEDE);
			else if (retVal)
				res=MRES_SUPERCEDE;
		}
	}
	retVal=MF_ExecuteForward(pfnThinkForward, (cell)ENTINDEX(pent));
	if (retVal)
		res=MRES_SUPERCEDE;

	RETURN_META(res);
}
Beispiel #19
0
void Client_InitObj(void* mValue){
  static int num;

  if ( mDest != MSG_ALL )
	  return;

  switch (mState++){
  case 0:
	  num = 0;
	  mObjects.count = *(int*)mValue;
	  if ( mObjects.count == 0 )
		  mObjects.Clear();
	  break;
  case 1:
	  mObjects.obj[num].pEdict = INDEXENT(*(int*)mValue);
	  break;
  case 2:
	  mObjects.obj[num].index = *(int*)mValue;
	  break;
  case 3:
	  mObjects.obj[num].default_owner = *(int*)mValue;
	  mObjects.obj[num].owner = mObjects.obj[num].default_owner;
	  break;
  case 4:
	  mObjects.obj[num].visible = *(int*)mValue; 
	  break;
  case 5:
	  mObjects.obj[num].icon_neutral = *(int*)mValue;
	  break;
  case 6:
	  mObjects.obj[num].icon_allies = *(int*)mValue;
	  break;
  case 7:
	  mObjects.obj[num].icon_axis = *(int*)mValue;
	  break;
  case 8:
	  mObjects.obj[num].origin_x = *(float*)mValue;
	  break;
  case 9: // 8,9 coord
	  mObjects.obj[num].origin_y = *(float*)mValue;
	  mState = 1;
	  num++;
	  if ( num == mObjects.count ){
		  mObjects.Sort();
		  MF_ExecuteForward( iFInitCP );
	  }

	  break;
  }
}
Beispiel #20
0
void KeyValue(edict_t *pEntity, KeyValueData *pkvd)
{
	int retVal = 0;
	g_inKeyValue=true;
	g_pkvd=pkvd;
	int index = ENTINDEX(pEntity);
	if (DispatchKeyForward != -1) {
		retVal = MF_ExecuteForward(DispatchKeyForward, (cell)index);
		g_inKeyValue=false;
		if (retVal)
			RETURN_META(MRES_SUPERCEDE);
	}
	g_inKeyValue=false;
	RETURN_META(MRES_IGNORED);
}
void CThreadedSockets::accpetsocket()
{
	// Call CSocket function and return the result in CallBack parameter
		
	// Check if some new client is waiting for us to be accepted
	if( Socket->CheckSocket() )
	{
		// Check if the state is still STATE_ACCEPT
		if( State == STATE_ACCEPT )
			State = STATE_IDLE;

		int ret = Socket->socketAccept( &szClientAddr, &clientport, &iClientAddrLen );
		MF_ExecuteForward(fIDs[FID_ACCEPT], (cell)STATE_ACCEPT, (cell)ret, szClientAddr, (cell)iClientAddrLen, (cell)clientport);
	}
}
Beispiel #22
0
int Spawn(edict_t *pEntity)
{
	if (!g_precachedStuff) {
		// Used for SetView, added by JGHG
		PRECACHE_MODEL("models/rpgrocket.mdl");
		g_precachedStuff = true;
	}
	if (SpawnForward != -1) {
		int retVal = 0;
		int id = ENTINDEX(pEntity);
		retVal = MF_ExecuteForward(SpawnForward, (cell)id);
		if (retVal)
			RETURN_META_VALUE(MRES_SUPERCEDE, -1);
	}
	RETURN_META_VALUE(MRES_IGNORED, 0);
}
Beispiel #23
0
void PlayerPostThink_Post(edict_t *pEntity)
{
	if(plinfo[ENTINDEX(pEntity)].pViewEnt) {
		edict_t *pCamEnt = plinfo[ENTINDEX(pEntity)].pViewEnt;

		MAKE_VECTORS(pEntity->v.v_angle + pEntity->v.punchangle);
		Vector vecSrc	 = pEntity->v.origin + pEntity->v.view_ofs;
		Vector vecAiming = gpGlobals->v_forward;
		TraceResult tr;

		switch(plinfo[ENTINDEX(pEntity)].iViewType) {
			case CAMERA_3RDPERSON:
				TRACE_LINE(vecSrc, vecSrc - (vecAiming * 128), ignore_monsters, ENT(pEntity), &tr);
				SET_VIEW(pEntity, pCamEnt);
				pCamEnt->v.origin = tr.vecEndPos;
				pCamEnt->v.angles = pEntity->v.v_angle;
				break;
			case CAMERA_UPLEFT:
				TRACE_LINE(vecSrc, vecSrc - ((vecAiming * 32) - ((gpGlobals->v_right * 15) + (gpGlobals->v_up * 15))), ignore_monsters, ENT(pEntity), &tr);
				SET_VIEW(pEntity, pCamEnt);
				pCamEnt->v.origin = tr.vecEndPos;
				pCamEnt->v.angles = pEntity->v.v_angle;
				break;
			case CAMERA_TOPDOWN:
				TRACE_LINE(vecSrc, vecSrc + Vector(0,0,2048), dont_ignore_monsters, ENT(pEntity), &tr);
				SET_VIEW(pEntity, pCamEnt);
				pCamEnt->v.origin = tr.vecEndPos;
				pCamEnt->v.origin.z -= 40;
				pCamEnt->v.angles = Vector(90,pEntity->v.v_angle.y,0);
				break;
			default:
				SET_VIEW(pEntity, pEntity);
				REMOVE_ENTITY(plinfo[ENTINDEX(pEntity)].pViewEnt);
				plinfo[ENTINDEX(pEntity)].iViewType = CAMERA_NONE;
				plinfo[ENTINDEX(pEntity)].pViewEnt = NULL;
				break;
		}
	}

	if (PlayerPostThinkForward != -1)
	{
		if (MF_ExecuteForward(PlayerPostThinkForward, (cell)ENTINDEX(pEntity)))
			RETURN_META(MRES_SUPERCEDE);
	}

	RETURN_META(MRES_IGNORED);
}
Beispiel #24
0
DETOUR_DECL_MEMBER1(GiveShield, void, bool, bRetire) // void CBasePlayer::GiveShield(bool bRetire)
{
	// Special case for shield. Game doesn't use GiveNamedItem() to give a shield.
	if (CurrentItemId == CSI_SHIELDGUN)
	{
		int client = G_HL_TypeConversion.cbase_to_id(this);

		if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0)
		{
			return;
		}
	}

	// From here, forward is not blocked, resetting this
	// to ignore code in AddAccount which is called right after.
	CurrentItemId = 0;

	// Give me my shield!
	DETOUR_MEMBER_CALL(GiveShield)(bRetire);
}
Beispiel #25
0
DETOUR_DECL_MEMBER1(GiveNamedItem, void, const char*, pszName) // void CBasePlayer::GiveNamedItem(const char *pszName)
{
	// If the current item id is not null, this means player has triggers a buy command.
	if (CurrentItemId)
	{
		int client = G_HL_TypeConversion.cbase_to_id(this);

		if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
		{
			return;
		}
	}

	// From here, forward is not blocked, resetting this
	// to ignore code in AddAccount which is called right after.
	CurrentItemId = 0;

	// Give me my item!
	DETOUR_MEMBER_CALL(GiveNamedItem)(pszName);
}
Beispiel #26
0
void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2)
{
	if (PlaybackForward != -1) {
		edict_t *e = (edict_t *)pInvoker;
		int retVal = 0;
		static cell cOrigin[3];
		static cell cAngles[3];
		Vector vOrigin = (Vector)origin;
		Vector vAngles = (Vector)angles;
		cOrigin[0] = amx_ftoc(vOrigin.x);
		cOrigin[1] = amx_ftoc(vOrigin.y);
		cOrigin[2] = amx_ftoc(vOrigin.z);
		cAngles[0] = amx_ftoc(vAngles.x);
		cAngles[1] = amx_ftoc(vAngles.y);
		cAngles[2] = amx_ftoc(vAngles.z);
		cell CellOrigin = MF_PrepareCellArray(cOrigin, 3);
		cell CellAngles = MF_PrepareCellArray(cAngles, 3);
		retVal = MF_ExecuteForward(PlaybackForward, (cell)flags, (cell)ENTINDEX(e), (cell)eventindex, delay, CellOrigin, CellAngles, fparam1, fparam2, (cell)iparam1, (cell)iparam2, (cell)bparam1, (cell)bparam2);
		if (retVal)
			RETURN_META(MRES_SUPERCEDE);
	}
	RETURN_META(MRES_IGNORED);

}
Beispiel #27
0
void CPlayer::WeaponsCheck(int weapons)
{
	if(wpns_bitfield == 0)
		return;
	
	else if(pEdict->v.weapons == 0)
		return;

	int old;
	int cur;

	for(int i = 1; i < MAX_WEAPONS; ++i)
	{
		// Check to see we are not talking about a grenade and we have changed
		if(i != 13 && i != 14 && i != 15 && i != 16 && i != 36)
		{
			old = wpns_bitfield&(1<<i);
			cur = weapons&(1<<i);

			if(old != cur)
				MF_ExecuteForward(iFWpnPickupForward, index, i, ((weapons&(1<<i)) ? 1 : 0));
		}
	}
}
Beispiel #28
0
DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientCommand(edict_t *pEntity)
{
	const char *command = CMD_ARGV(0);
	
	// A new command is triggered, reset variable, always.
	CurrentItemId = 0;

	// Purpose is to retrieve an item id based on alias name or selected item from menu,
	// to be used in OnBuy* forwards.
	if ((ForwardOnBuyAttempt != -1 || ForwardOnBuy != -1) && command && *command)
	{
		int itemId = 0;
		
		// Handling buy via menu.
		if (!strcmp(command, "menuselect")) 
		{
			int slot = atoi(CMD_ARGV(1));

			if (slot > 0 && slot < 9)
			{
			    static const int menuItemsTe[][9] = 
				{
					/* Menu_Buy              */ { 0, 0, 0, 0, 0, 0, CSI_PRIAMMO, CSI_SECAMMO, 0 },
					/* Menu_BuyPistol        */ { 0, CSI_GLOCK18, CSI_USP, CSI_P228, CSI_DEAGLE, CSI_ELITE, 0, 0, 0 },
					/* Menu_BuyRifle         */ { 0, CSI_GALIL, CSI_AK47, CSI_SCOUT, CSI_SG552, CSI_AWP, CSI_G3SG1, 0, 0 },
					/* Menu_BuyMachineGun    */ { 0, CSI_M249, 0, 0, 0, 0, 0, 0, 0 },
					/* Menu_BuyShotgun       */ { 0, CSI_M3, CSI_XM1014, 0, 0, 0, 0, 0, 0 },
					/* Menu_BuySubMachineGun */ { 0, CSI_MAC10, CSI_MP5NAVY, CSI_UMP45, CSI_P90, 0, 0, 0, 0 },
					/* Menu_BuyItem          */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, 0, 0 }
				};

				static const int menuItemsCt[][9] = 
				{
					/* Menu_Buy              */ { 0, 0, 0, 0, 0, 0, CSI_PRIAMMO, CSI_SECAMMO, 0 },
					/* Menu_BuyPistol        */ { 0, CSI_GLOCK18, CSI_USP, CSI_P228, CSI_DEAGLE, CSI_FIVESEVEN, 0, 0, 0 },
					/* Menu_BuyRifle         */ { 0, CSI_FAMAS, CSI_SCOUT, CSI_M4A1, CSI_AUG, CSI_SG550, CSI_AWP, 0, 0 },
					/* Menu_BuyMachineGun    */ { 0, CSI_M249, 0, 0, 0, 0, 0, 0, 0 },
					/* Menu_BuyShotgun       */ { 0, CSI_M3, CSI_XM1014, 0, 0, 0, 0, 0, 0 },
					/* Menu_BuySubMachineGun */ { 0, CSI_TMP, CSI_MP5NAVY, CSI_UMP45, CSI_P90, 0, 0, 0, 0 },
					/* Menu_BuyItem          */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, CSI_DEFUSER, CSI_SHIELDGUN }
				};

				int menuId = get_pdata<int>(pEdict, MenuOffset);

				if (menuId >= Menu_Buy && menuId <= Menu_BuyItem)
				{
					switch (get_pdata<int>(pEdict, TeamOffset))
					{
						case TEAM_T: itemId = menuItemsTe[menuId - 4][slot]; break; // -4 because array is zero-based and Menu_Buy* constants starts from 4.
						case TEAM_CT:itemId = menuItemsCt[menuId - 4][slot]; break;
					}

					if (itemId)
					{
						CurrentItemId = itemId;
					}
				}
			}
		}
		else // Handling buy via alias
		{
			if (ItemAliasList.retrieve(command, &itemId))
			{
				CurrentItemId = itemId;
			}
		}
	}

	int client = ENTINDEX(pEdict);

	if (ForwardInternalCommand != -1 && *UseBotArgs)
	{
		const char *args = *BotArgs;

		if (MF_ExecuteForward(ForwardInternalCommand, static_cast<cell>(client), args) > 0)
		{
			return;
		}
	}

	if (ForwardOnBuyAttempt != -1 && 
		CurrentItemId             && 
		MF_IsPlayerAlive(client)  && 
		MF_ExecuteForward(ForwardOnBuyAttempt, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
	{
		return;
	}

	DETOUR_STATIC_CALL(C_ClientCommand)(pEdict);
}
void CThreadedSockets::sendData()
{
	// Call CSocket function and return the result in CallBack parameter
	int ret = Socket->socketSend(szData, iDatalen);
	MF_ExecuteForward(fIDs[FID_SEND], (cell)STATE_SEND, (cell)ret);
}
void CThreadedSockets::closeSocket()
{
	// Call CSocket function and return the result in CallBack parameter
	int ret = Socket->socketClose();
	MF_ExecuteForward(fIDs[FID_CLOSE], (cell)STATE_DISCONNECT, (cell)ret);
}