added 2 new natives
This commit is contained in:
		| @@ -140,8 +140,7 @@ static cell AMX_NATIVE_CALL cs_set_user_deaths(AMX *amx, cell *params) // cs_set | ||||
| 	WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_TEAM)); // should these be byte? | ||||
| 	MESSAGE_END(); | ||||
|  | ||||
| 	int *deaths = static_cast<int *>(MF_PlayerPropAddr(params[1], Player_Deaths)); | ||||
| 	*deaths = params[2]; | ||||
| 	*static_cast<int *>(MF_PlayerPropAddr(params[1], Player_Deaths)) = params[2]; | ||||
|  | ||||
| 	return 1; | ||||
| } | ||||
| @@ -1408,6 +1407,87 @@ static cell AMX_NATIVE_CALL cs_set_armoury_type(AMX *amx, cell *params) | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static cell AMX_NATIVE_CALL cs_set_user_zoom(AMX *amx, cell *params) | ||||
| { | ||||
| 	// Set the weapon zoom type of a user | ||||
| 	// params[1] = user index | ||||
| 	// params[2] = zoom type | ||||
| 	// params[3] = mode (0=blocking mode, 1=player will loose the zoom set by changing weapon) | ||||
|  | ||||
| 	int index = params[1]; | ||||
| 	// Check index  | ||||
| 	CHECK_PLAYER(index); | ||||
|  | ||||
| 	int value, type = params[2]; | ||||
| 	int curweap = *static_cast<int *>(MF_PlayerPropAddr(index, Player_CurrentWeapon)); | ||||
| 	 | ||||
| 	// Fetch player pointer  | ||||
| 	edict_t *pPlayer = MF_GetPlayerEdict(index); | ||||
| 	// Reset any previous zooming | ||||
| 	g_zooming[index] = 0; | ||||
|  | ||||
| 	if (type == CS_RESET_ZOOM) | ||||
| 	{ | ||||
| 		*((int *)pPlayer->pvPrivateData + OFFSET_ZOOMTYPE) = CS_NO_ZOOM; | ||||
| 		return 1; | ||||
| 	} | ||||
|  | ||||
| 	switch (type) | ||||
| 	{ | ||||
| 	case CS_SET_NO_ZOOM: | ||||
| 		value = CS_NO_ZOOM; | ||||
| 		break; | ||||
| 	case CS_SET_FIRST_ZOOM: | ||||
| 		value = CS_FIRST_ZOOM; | ||||
| 		break; | ||||
| 	case CS_SET_SECOND_ZOOM: | ||||
| 		if (curweap == CSW_G3SG1 || curweap == CSW_SG550 || curweap == CSW_SCOUT) | ||||
| 			value = CS_SECOND_NONAWP_ZOOM; | ||||
| 		else | ||||
| 			value = CS_SECOND_AWP_ZOOM; | ||||
| 		break; | ||||
| 	case CS_SET_AUGSG552_ZOOM: | ||||
| 		value = CS_AUGSG552_ZOOM; | ||||
| 		break; | ||||
| 	default: | ||||
| 		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid zoom type %d", type); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	if (!params[3]) | ||||
| 		g_zooming[index] = value; | ||||
| 	*((int *)pPlayer->pvPrivateData + OFFSET_ZOOMTYPE) = value; | ||||
|  | ||||
| 	return 1; | ||||
| } | ||||
|  | ||||
| static cell AMX_NATIVE_CALL cs_get_user_zoom(AMX *amx, cell *params) | ||||
| { | ||||
| 	// Returns the zoom type of a player | ||||
| 	// params[1] = user id | ||||
|  | ||||
| 	// Check Player | ||||
| 	CHECK_PLAYER(params[1]); | ||||
| 	// Fetch player pointer  | ||||
| 	edict_t *pPlayer = MF_GetPlayerEdict(params[1]); | ||||
| 	int value = *((int *)pPlayer->pvPrivateData + OFFSET_ZOOMTYPE); | ||||
|  | ||||
| 	switch (value) | ||||
| 	{ | ||||
| 	case CS_NO_ZOOM: | ||||
| 		return CS_SET_NO_ZOOM; | ||||
| 	case CS_FIRST_ZOOM: | ||||
| 		return CS_SET_FIRST_ZOOM; | ||||
| 	case CS_SECOND_AWP_ZOOM: | ||||
| 	case CS_SECOND_NONAWP_ZOOM: | ||||
| 		return CS_SET_SECOND_ZOOM; | ||||
| 	case CS_AUGSG552_ZOOM: | ||||
| 		return CS_SET_AUGSG552_ZOOM; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| AMX_NATIVE_INFO cstrike_Exports[] = { | ||||
| 	{"cs_set_user_money",			cs_set_user_money}, | ||||
| 	{"cs_get_user_money",			cs_get_user_money}, | ||||
| @@ -1453,6 +1533,8 @@ AMX_NATIVE_INFO cstrike_Exports[] = { | ||||
| 	{"cs_user_spawn",				cs_user_spawn}, | ||||
| 	{"cs_get_armoury_type",			cs_get_armoury_type}, | ||||
| 	{"cs_set_armoury_type",			cs_set_armoury_type}, | ||||
| 	{"cs_get_user_zoom",			cs_get_user_zoom}, | ||||
| 	{"cs_set_user_zoom",			cs_set_user_zoom}, | ||||
| 	//------------------- <-- max 19 characters! | ||||
| 	{NULL,							NULL} | ||||
| }; | ||||
| @@ -1481,6 +1563,8 @@ void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) | ||||
| 	// Reset player model a short while (MODELRESETTIME) after this if they are using an edited model. | ||||
| 	if(msg_type == GET_USER_MSG_ID(PLID, "ResetHUD", NULL)) { | ||||
| 		int entityIndex = ENTINDEX(ed); | ||||
| 		if (g_zooming[entityIndex]) | ||||
| 			g_zooming[entityIndex] = 0; | ||||
| 		if(g_players[entityIndex].GetModelled()) | ||||
| 			g_players[entityIndex].SetInspectModel(true); | ||||
| 			//g_players[ENTINDEX(ed)].SetTime(gpGlobals->time + MODELRESETTIME); | ||||
| @@ -1494,6 +1578,7 @@ void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) | ||||
| void ClientDisconnect(edict_t *pEntity) { | ||||
| 	int index = ENTINDEX(pEntity); | ||||
| 	g_players[index].SetModelled(false); | ||||
| 	g_zooming[index] = 0; | ||||
|  | ||||
| 	RETURN_META(MRES_IGNORED); | ||||
| } | ||||
| @@ -1521,7 +1606,16 @@ void PlayerPostThink(edict_t* pPlayer) { | ||||
| 	RETURN_META(MRES_IGNORED); | ||||
| } | ||||
|  | ||||
| void PlayerPreThink(edict_t *pPlayer) | ||||
| { | ||||
| 	int entityIndex = ENTINDEX(pPlayer); | ||||
| 	if (g_zooming[entityIndex]) | ||||
| 	{ | ||||
| 		*((int *)pPlayer->pvPrivateData + OFFSET_ZOOMTYPE) = g_zooming[entityIndex]; | ||||
| 	} | ||||
|  | ||||
| 	RETURN_META(MRES_IGNORED); | ||||
| } | ||||
|  | ||||
| void OnAmxxAttach() | ||||
| { | ||||
|   | ||||
| @@ -77,6 +77,7 @@ | ||||
| 	#define OFFSET_MAPZONE				235 + EXTRAOFFSET | ||||
| 	#define OFFSET_ISDRIVING			350 + EXTRAOFFSET // 040926 | ||||
| 	#define OFFSET_STATIONARY			362 + EXTRAOFFSET // 040927 (363 works also!) | ||||
| 	#define OFFSET_ZOOMTYPE				363 + EXTRAOFFSET | ||||
|  | ||||
| 	#define OFFSET_AWM_AMMO				377 + EXTRAOFFSET // 041029: All of these *_AMMO:s were changed -5 | ||||
| 	#define OFFSET_SCOUT_AMMO			378 + EXTRAOFFSET | ||||
| @@ -118,6 +119,7 @@ | ||||
| 	#define OFFSET_MAPZONE				268 + EXTRAOFFSET // +27 | ||||
| 	#define OFFSET_ISDRIVING			386 + EXTRAOFFSET // 040927 | ||||
| 	#define OFFSET_STATIONARY			400 + EXTRAOFFSET // 040927 (401 works also) | ||||
| 	#define OFFSET_ZOOMTYPE				402 + EXTRAOFFSET | ||||
|  | ||||
| 	#define OFFSET_AWM_AMMO				426 + EXTRAOFFSET // +44 | ||||
| 	#define OFFSET_SCOUT_AMMO			427 + EXTRAOFFSET // +44 | ||||
| @@ -242,6 +244,12 @@ | ||||
| #define CS_ARMOR_KEVLAR					1 | ||||
| #define CS_ARMOR_ASSAULTSUIT			2 | ||||
|  | ||||
| #define CS_FIRST_ZOOM					0x28 | ||||
| #define CS_SECOND_AWP_ZOOM				0xA | ||||
| #define CS_SECOND_NONAWP_ZOOM			0xF | ||||
| #define CS_AUGSG552_ZOOM				0x37 | ||||
| #define CS_NO_ZOOM						0x5A | ||||
|  | ||||
| enum CS_Internal_Models { | ||||
| 	CS_DONTCHANGE = 0, | ||||
| 	CS_CT_URBAN = 1, | ||||
| @@ -254,9 +262,19 @@ enum CS_Internal_Models { | ||||
| 	CS_T_GUERILLA = 8, | ||||
| 	CS_CT_VIP = 9 | ||||
| }; | ||||
|  | ||||
| enum | ||||
| { | ||||
| 	CS_RESET_ZOOM = 0, | ||||
| 	CS_SET_NO_ZOOM, | ||||
| 	CS_SET_FIRST_ZOOM, | ||||
| 	CS_SET_SECOND_ZOOM, | ||||
| 	CS_SET_AUGSG552_ZOOM, | ||||
| }; | ||||
| // cstrike-specific defines above | ||||
|  | ||||
| CCstrikePlayer g_players[33]; | ||||
| int g_zooming[33] = {0}; | ||||
| bool g_precachedknife = false; | ||||
| bool g_noknives = false; | ||||
| // Globals above | ||||
|   | ||||
| @@ -106,7 +106,7 @@ | ||||
| #define FN_ClientUserInfoChanged		ClientUserInfoChanged		/* pfnClientUserInfoChanged()	(wd) Client has updated their setinfo structure */ | ||||
| // #define FN_ServerActivate			ServerActivate				/* pfnServerActivate()			(wd) Server is starting a new map */ | ||||
| #define FN_ServerDeactivate				ServerDeactivate			/* pfnServerDeactivate()		(wd) Server is leaving the map (shutdown or changelevel); SDK2 */ | ||||
| // #define FN_PlayerPreThink			PlayerPreThink				/* pfnPlayerPreThink() */ | ||||
| #define FN_PlayerPreThink				PlayerPreThink				/* pfnPlayerPreThink() */ | ||||
| #define FN_PlayerPostThink				PlayerPostThink				/* pfnPlayerPostThink() */ | ||||
| // #define FN_StartFrame				StartFrame					/* pfnStartFrame() */ | ||||
| // #define FN_ParmsNewLevel				ParmsNewLevel				/* pfnParmsNewLevel() */ | ||||
|   | ||||
| @@ -269,3 +269,24 @@ native cs_set_armoury_type(index, type); | ||||
|  * NOTE: If user can't plant (cs_get_user_plant(index) is 0) then cs_get_user_mapzones(index) & CS_MAPZONE_BOMBTARGET will return 0 too. | ||||
|  */ | ||||
| native cs_get_user_mapzones(index); | ||||
|  | ||||
| /* Zoom type enum. Used for get/set_user_zoom() natives. | ||||
| enum | ||||
| { | ||||
| 	CS_RESET_ZOOM = 0,		// Reset any zoom blocking (when using this type, mode has no effect) | ||||
| 	CS_SET_NO_ZOOM,			// Disable any sort of zoom (ie: to disable zoom in all weapons use this with mode=0) | ||||
| 	CS_SET_FIRST_ZOOM,		// Set first zoom (awp style)  | ||||
| 	CS_SET_SECOND_ZOOM,		// Set second zoom (awp style) | ||||
| 	CS_SET_AUGSG552_ZOOM,		// Set aug/sg552 zoom style | ||||
| }; | ||||
| /* Sets a weapon zoom type on a player, any zoom type will work for all weapons, so you can even set an awp zoom to pistols :D | ||||
|  * The 2nd param has to be one of the above zoom types in the enum. Mode can only be 0 or 1. | ||||
|  * If mode=0 (blocking mode), the user will be forced to use the zoom type set by the native, and wont be able to change it (even by changing weapon) | ||||
|  * until the native resets the zoom with CS_RESET_ZOOM. | ||||
|  * If mode=1 the user will be able to restore back to a normal view by changing weapon. | ||||
|  */ | ||||
| native cs_set_user_zoom(index, type, mode); | ||||
|  | ||||
| /* Returns how a user is zooming during the native call. Values correspond to the above enum, but will return 0 if an error occurred. | ||||
|  */ | ||||
| native cs_get_user_zoom(index); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user