Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Changing weapons
#1
Hi,
I want to change the weapons of the clients, and this is also working, but if they climb on something they loose the weapon. You have to press 1 again to swap back which is really annoying.

I Could fix this with calling the Method SwitchToWeapon. But this method is only implementend it the current unstable version of nukems server addon. So i tried to decompile it to find the function and implement it myself.

Code:
[StructLayout(LayoutKind.Sequential, Size = 0x278), UnsafeValueType, MiscellaneousBits(0x41), DebugInfoInPDB, NativeCppClass]
internal struct Entity_t
{
}
unsafe public static class Other_TExtensionMethods
{
      [SuppressUnmanagedCodeSecurity]
      [MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
      public static extern void ServerSwitchToWeapon([In] int obj0, [In] int obj1);


    private static unsafe Entity_t* CG;

    public static void SwitchToWeapon(this Other_t other, int WeaponID)
    {
        Other_TExtensionMethods.ServerSwitchToWeapon(*((int*)Other_TExtensionMethods.CG), WeaponID);
    }
}

actually this is compiling, but the addon will not get loaded then.

My code to swap the weapon is:
Code:
this.ServerClient.Other.OffhandWeapon = this.PrimaryWeapon.GetID();
this.ServerClient.Other.CurrentWeapon = this.ServerClient.Other.OffhandWeapon;
//The extension method from above
this.ServerClient.Other.SwitchToWeapon(this.ServerClient.Other.OffhandWeapon);

I hope sombody knows how to implement this function or an other way to avoid that the weapon disapears on climbin.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help GunGame Dedicated Server more than 20 weapons? graphix2004 0 2,495 07-26-2015, 22:28
Last Post: graphix2004
  Help changing direction of spawned objects as4dkhan 0 1,546 08-29-2014, 00:54
Last Post: as4dkhan

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.