[Solved]MH2GoldCTG : Forced weapons position :

Discussions about Coding and Scripting
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

[Solved]MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

Hello everyone, does anyone know how to choose the location of each weapon on a server, so it forces every weapons in the location we decide for our MonsterHuntCTG, for example force the sniper to be forced in "center" So it would be choosing the location of the weapons that we want, whether it is right, center or left.
Last edited by Letylove49 on Tue Feb 24, 2026 2:10 pm, edited 3 times in total.
Image
Image
Letylove49 aka Alicia
User avatar
DsL444
Novice
Posts: 21
Joined: Tue Sep 12, 2023 5:21 pm
Location: Germany

Re: weapons position :

Post by DsL444 »

Edit Map. :wtf:
:sniper1:
=============
Join us on Discord! :tu: https://discord.gg/2ZZwYhwpVE
User avatar
Barbie
Godlike
Posts: 3318
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: weapons position :

Post by Barbie »

Code: Select all

if (FindActorByName('SniperRifle0', A, 'SniperRifle')) A.SetLocation(vect(1, 2, 3));
"If Origin not in center it be not in center." --Buggie
User avatar
HeadHuntiing
Novice
Posts: 7
Joined: Sat May 03, 2025 11:39 am
Personal rank: CTG Founder/MHA HEAD
Location: France

Re: weapons position :

Post by HeadHuntiing »

normally I don't have time to take care of what LetyLove need to because I work on a lot of things, but at the level of the positioning of the weapons I have been taking care of it since yesterday a little, with the little free time i have, I know how to do it, I edit the settings of the weapon, I know how to do it but I will need do more tests, but I asked LetyLove to do this post because maybe there exist a mutator etc, (I STILL SEND YOU THE CODE JUST IN CASE) : PlayerViewOffset=(X=0.000000,Y=0.000000,Z=-1.700000)
function SetHand(float Hand)
{
Mesh = mesh'Botpack.Rifle2m';
MultiSkins[0] = Texture'MH2GoldCTGv3.Rifle.AA';
MultiSkins[1] = Texture'MH2GoldCTGv3.Rifle.SR';
MultiSkins[3] = Texture'MH2GoldCTGv3.Rifle.Rifle2d';
PlayerViewOffset = vect(0.0, 0.0, -1.7);
}
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: weapons position :

Post by Letylove49 »

Barbie wrote: Sun Sep 07, 2025 9:06 am

Code: Select all

if (FindActorByName('SniperRifle0', A, 'SniperRifle')) A.SetLocation(vect(1, 2, 3));

we must add this function into the MH2 or the weapon ?
Image
Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 3318
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: weapons position :

Post by Barbie »

Letylove49 wrote: Mon Sep 08, 2025 8:40 pm we must add this function into the MH2 or the weapon ?
I think I misunderstood your question - you want to force a player having the weapon on left, right or center and NOT moving weapons in a map?
"If Origin not in center it be not in center." --Buggie
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: weapons position :

Post by Letylove49 »

Barbie wrote: Mon Sep 08, 2025 9:40 pm
Letylove49 wrote: Mon Sep 08, 2025 8:40 pm we must add this function into the MH2 or the weapon ?
I think I misunderstood your question - you want to force a player having the weapon on left, right or center and NOT moving weapons in a map?
Yes we want to force the weapon on the center,
Image
Image
Letylove49 aka Alicia
User avatar
HeadHuntiing
Novice
Posts: 7
Joined: Sat May 03, 2025 11:39 am
Personal rank: CTG Founder/MHA HEAD
Location: France

Re: weapons position :

Post by HeadHuntiing »

What he's saying is that we need to force the MH2Rifle to be displayed in the center, ignoring the players' weaponhand UT settings. We know it's possible, but we were mainly asking in case a mutator or something else already existed, instead of me doing a lots of testing, because I'm currently looking into it, but at the same time, I don't necessarily have the time because I'm always working on dozens of projects at the same time.

In any case, it's forcing the sniper to be played in the center.
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Force weapons position on MH

Post by Letylove49 »


// Force position of weapons (forced on center and ignore client settings.)

Function Force weapon postion (Weaponclass, Vect)
if (FindActorByName('MH2Rifle', A, 'MH2Rifle')) A.SetLocation(vect(2));
i get bad function definition, what is wrong ?
Image
Image
Letylove49 aka Alicia
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: weapons position :

Post by Letylove49 »

viewtopic.php?t=17115 next of this topic here. Sorry for the dopple post.
Image
Image
Letylove49 aka Alicia
lafoxxx
Average
Posts: 56
Joined: Sun Jun 01, 2025 7:31 pm
Personal rank: UNUSED

Re: weapons position :

Post by lafoxxx »

Hi I have slightly different question but will ask here in order not to duplicate threads.
So, I use keybinding to set "handedness" to -1 or 1, but it only applies after I open Preferences.
But for some weapons its muzzleflash moves left to right as I push the buttons -- but not the model (also -- unless I open Preferences).
Sniper rifle reacts to button presses, it gets "tilted" slightly -- but still not changes its position (you guessed it -- unless I open Preferences).

What shall I apply to "append" the new position without opening Preferences?
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

i have try this function but i got type mismatch in = , what is wrong ?
exec Function bool setHand(string Handname)
{
Local byte Hand;
Local bool SetHand;


if(Hand!=0)
LeftName=Hand=0;

if(Hand!=1)
CenterName= Hand=1;

if(Hand!=2)
RightName= Hand=2;


if(Hand!=3)
HiddenName= Hand =3;


}

i wisch to know if this is correct :
if(UseAltSniper)
if(Hand!=1)
exec other.ConsoleCommand("sethand center" );
GiveWeapon(Other,class'MH2Rifle');
else
GiveWeapon(Other,class'Botpack.SniperRifle');
if(Hand!=1)
exec other.ConsoleCommand("sethand center" );
Image
Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 3318
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: MH2GoldCTG : Forced weapons position :

Post by Barbie »

Assuming LeftName is if type bool you should use LeftName = Hand == 0;

Apart from that the code looks :facepalm:
"If Origin not in center it be not in center." --Buggie
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

Barbie wrote: Sat Jan 24, 2026 11:10 am Assuming LeftName is if type bool you should use LeftName = Hand == 0;

Apart from that the code looks :facepalm:
ok i will try that too.

i have try this and that i can compile but that doesnt work.
exec Function bool setHand( byte Hand)
{




//Change value to new value

if(Hand!=0)
Hand = 0;

if(Hand!=1)
Hand = 1;

if(Hand!=2)
Hand = 2;


if(Hand!=3)
Hand = 3;


}
Image
Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 3318
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: MH2GoldCTG : Forced weapons position :

Post by Barbie »

Letylove49 wrote: Sat Jan 24, 2026 2:37 pm i have try this and that i can compile but that doesnt work.

Code: Select all

exec Function bool setHand( byte Hand) {
//Change value to new value

	if(Hand!=0)  Hand = 0;
	if(Hand!=1)  Hand = 1;
	if(Hand!=2)  Hand = 2;
	if(Hand!=3) Hand = 3;
} 
That code does nothing except burning some CPU cycles. It has no return value and the function parameter is not by reference, so changes of it do only remain within function scope. Also at end of function Hand has always the value 3.
It is a good habit to write a short comment at the function header: What should that code do, what is the range of function's return value and what range the parameters may have.
"If Origin not in center it be not in center." --Buggie