Raised This Month: $202 Target: $400
 50% 

SetViewEntityBody 2


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay       
1xAero
Junior Member
Join Date: Feb 2018
Old 02-09-2018 , 12:18   SetViewEntityBody 2
Reply With Quote #1



Version: 2
Requirements: AmxModX 1.8.3


Description from Hanna:

The main function of this plugin is changing the viewmodel bodygroup.

Original version by Hanna is here: https://forums.alliedmods.net/showthread.php?t=287754

Hanna profile: https://forums.alliedmods.net/member.php?u=273346

//Natives
native cs_set_viewmodel_body(iPlayer, iValue);
native cs_get_viewmodel_body(iPlayer);
native cs_set_user_sex(iPlayer, iValue);
native cs_get_user_sex(iPlayer);


Code:
//EXAMPLE OF USAGE

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

native cs_set_viewmodel_body(pPlayer, iValue);	//This will set v_ .mdl body (PlayerIndex, Bodygroup number)
native cs_get_viewmodel_body(pPlayer);			//To get what body is currently uses any player (PlayerIndex)
native cs_set_user_sex(pPlayer, iValue);		//Set user sex, custom option, mostly for WOMAN/MALE knife like in CSNZ (PlayerIndex, Sex values only (0 = MALE, 1 = FEMALE))
native cs_get_user_sex(pPlayer);				//Get player current sex (PlayerIndex)	

#define TRUE 1
#define FALSE 0

#define FEMALE 1
#define MALE 0

public plugin_init()
	RegisterHam(Ham_Spawn, "player", "HamF_Spawn_Player_Post", TRUE);
	
public client_connect(iPlayer)
	cs_set_user_sex(iPlayer, random_num(MALE, FEMALE))	//Let's randomize players sex after connecting
	
public HamF_Spawn_Player_Post(iPlayer)
{
	if(!is_user_connected(iPlayer))
		return HAM_IGNORED;
	
	switch(cs_get_user_sex(iPlayer))	//Get here now player sex setup we done in client_connect event
	{
		case FEMALE: cs_set_viewmodel_body(iPlayer, 1)	//Set v_ bodygroup number now for FEMALE
		default: cs_set_viewmodel_body(iPlayer, 0)		//For MALE, default
	}
		
	client_print(iPlayer, print_chat, "My current sex is %d, my hand body is %d", cs_get_user_sex(iPlayer), cs_get_viewmodel_body(iPlayer))	//SEX 0 = MALE, SEX 1 = FEMALE, OTHER XD?

	return HAM_IGNORED;	
}
Overview:



Models pack you can grab from Hanna's thread: https://forums.alliedmods.net/showthread.php?t=287754

* v2: Feb 8 2018 - Feb 9 2018 //xAero build
- Removed events from usage, added hook to prevent from enabling server
weapons cl_lw 0, rework on code, removed primary and secondary attack block,
this should fix custom weapons, added hooks inside update client data,
thanks to fl0wer, fixed knife mirroring, HamSendWeaponAnim emulates
all CS v_ default animations by itself, so i've not used any hooks for
reloading, idle or any other things. Done emulation of burst shell ejection
like client does, but through amxx. The attack is just only default CS
attack emulation, it does nothing.

* v2: Update 1 Feb 11 2018 //xAero build
- Corrected default v_ models path to unprecache. Was just "v_", but should
be "models/v_".
Attached Files
File Type: sma Get Plugin or Get Source (example.sma - 901 views - 1.3 KB)
File Type: sma Get Plugin or Get Source (setviewentitybody.sma - 738 views - 26.6 KB)

Last edited by 1xAero; 02-11-2018 at 02:40.
1xAero is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-09-2018 , 12:33   Re: SetViewEntityBody 2
Reply With Quote #2

Change "sex" to "gender".
__________________
Relaxing is offline
1xAero
Junior Member
Join Date: Feb 2018
Old 02-09-2018 , 13:17   Re: SetViewEntityBody 2
Reply With Quote #3

Added Linux differences checks on pdata offsets. Code reuploaded.

BTW, sex != gender?

Last edited by 1xAero; 02-09-2018 at 13:18.
1xAero is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-09-2018 , 14:05   Re: SetViewEntityBody 2
Reply With Quote #4

Quote:
Originally Posted by 1xAero View Post
Added Linux differences checks on pdata offsets. Code reuploaded.

BTW, sex != gender?
It's more common to use gender in this case.
__________________
Relaxing is offline
1xAero
Junior Member
Join Date: Feb 2018
Old 02-10-2018 , 08:22   Re: SetViewEntityBody 2
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
It's more common to use gender in this case.
So, u don't like SEX)?
1xAero is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-10-2018 , 16:53   Re: SetViewEntityBody 2
Reply With Quote #6

Just read my previous post once again.
__________________
Relaxing is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 02-10-2018 , 21:23   Re: SetViewEntityBody 2
Reply With Quote #7

The main reason that I can't use Hana's ViewEntityBody Plugins is you can't edit Recoil, Accuracy,... (Basicly weapon's data).
If this plugins can solve that problem, I think it will have better use.
__________________
My plugin:

Last edited by Celena Luna; 02-10-2018 at 21:24.
Celena Luna is offline
1xAero
Junior Member
Join Date: Feb 2018
Old 02-11-2018 , 00:43   Re: SetViewEntityBody 2
Reply With Quote #8

Quote:
Originally Posted by Celena Luna View Post
The main reason that I can't use Hana's ViewEntityBody Plugins is you can't edit Recoil, Accuracy,... (Basicly weapon's data).
If this plugins can solve that problem, I think it will have better use.
You need better weapon code. Look at Kord 12.7, profile https://forums.alliedmods.net/member.php?u=59151 coding style for weapons and what forwards he is hooking.
In this version there is no attack block. All you need is a bit hook Deploy forward for your weapon and point deploy animation in UpdateClient data (look at GetWeaponDrawAnim function)
That's it, u are done.

Last edited by 1xAero; 02-11-2018 at 00:44.
1xAero is offline
1xAero
Junior Member
Join Date: Feb 2018
Old 02-11-2018 , 02:41   Re: SetViewEntityBody 2
Reply With Quote #9

Updated, was careless and the path to default CS weapons for unprecaching was wrong.
Should be "models/", but not just "".
1xAero is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 02-12-2018 , 09:22   Re: SetViewEntityBody 2
Reply With Quote #10

can you give me an example? I have missed a lot of update in weapon coding because I am focusing on NPC
__________________
My plugin:

Last edited by Celena Luna; 02-12-2018 at 09:22.
Celena Luna is offline
Reply


Thread Tools
Display Modes

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 12:06.


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