Jump to content
Sign in to follow this  
mastaZz

the character starts with a rag in his hands. And should with a weapon.

Recommended Posts

 

 

the character starts with a rag in his hands. And should with a weapon. Tell me what is wrong?

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
{
    player.GetStatStamina().Set(1000);
	player.RemoveAllItems();

    /*itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
    itemBs = ItemBase.Cast(itemEnt);
	itemEnt = player.GetInventory().CreateInInventory("SpaghettiCan");
    itemBs = ItemBase.Cast(itemEnt);
	itemEnt = player.GetInventory().CreateInInventory("CanOpener");
    itemBs = ItemBase.Cast(itemEnt);
	itemEnt = player.GetInventory().CreateInInventory("Rag");
    itemBs = ItemBase.Cast(itemEnt);
	ItemBase.Cast(rags).SetQuantity(4);*/
	
	EntityAI itemEnt;
    ItemBase itemBs;
	
	itemEnt = player.GetInventory().CreateInInventory("Rag");
		itemBs = ItemBase.Cast(itemEnt);
		itemBs.SetQuantity(4);
		SetRandomHealth(itemEnt);

    EntityAI primary;
    EntityAI axe = player.GetInventory().CreateInInventory("FirefighterAxe");
	EntityAI soda = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
	EntityAI spagetti = player.GetInventory().CreateInInventory("SpaghettiCan");
	EntityAI opener = player.GetInventory().CreateInInventory("CanOpener");
	

    switch (Math.RandomInt(0, 7)) 
	{
        case 0: primary = baikerClass(player); break;
        case 1: primary = akClass(player); break;
        case 2: primary = mosinaClass(player); break;
		case 3: primary = svdClass(player); break;
		case 4: primary = FirefightersClass(player); break;
		case 5: primary = reporterClass(player); break;
		case 6: primary = umpClass(player); break;
		case 7: primary = copClass(player); break;
    }

    player.LocalTakeEntityToHands(primary);
    player.SetQuickBarEntityShortcut(primary, 0, true);
    //player.SetQuickBarEntityShortcut(axe, 3, true);
}

 

Share this post


Link to post
Share on other sites

Hey @mastaZz It's your code sequence. It's because you start with

player.RemoveAllItems();

which will remove all clothing from the character. Then you create the rags and the character has to take them to the hands as there are no other inventory slots to put the rags in.

I'm assuming that you're spawning in clothes when calling the player class in your switch block. Put your switch block right after RemoveAllItems before creating any other items.

  • Like 1

Share this post


Link to post
Share on other sites

 

Thanks for the answer. I rearranged as you said

1 hour ago, ColKernel said:

Hey @mastaZz It's your code sequence. It's because you start with


player.RemoveAllItems();

which will remove all clothing from the character. Then you create the rags and the character has to take them to the hands as there are no other inventory slots to put the rags in.

I'm assuming that you're spawning in clothes when calling the player class in your switch block. Put your switch block right after RemoveAllItems before creating any other items.

 

that's what happened
 

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
	 player.RemoveAllItems();
	 player.LocalTakeEntityToHands(primary);
     player.SetQuickBarEntityShortcut(primary, 0, true);
   
     EntityAI primary;
	 
        switch (Math.RandomInt(0, 8)) {
         case 0: primary = baikerClass(player); break;
         case 1: primary = akClass(player); break;
         case 2: primary = mosinaClass(player); break;
		 case 3: primary = svdClass(player); break;
		 case 4: primary = FirefightersClass(player); break;
		 case 5: primary = reporterClass(player); break;
		 case 6: primary = umpClass(player); break;
		 case 7: primary = copClass(player); break;
		 case 8: primary = copClass(player); break;
        }

	 player.GetInventory().CreateInInventory("HuntingKnife");
	 ItemBase rags = player.GetInventory().CreateInInventory("Rag");
	 rags.SetQuantity(2);	 

    }

on line player.LocalTakeEntityToHands(primary); 

there was an error

can't find variable 'primary'

Share this post


Link to post
Share on other sites

It's the sequencing again. Now you ask the player to take primary to hands before defining and creating primary.

 player.LocalTakeEntityToHands(primary);
 player.SetQuickBarEntityShortcut(primary, 0, true);

should be after your switch block.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, ColKernel said:

It's the sequencing again. Now you ask the player to take primary to hands before defining and creating primary.


 player.LocalTakeEntityToHands(primary);
 player.SetQuickBarEntityShortcut(primary, 0, true);

should be after your switch block.

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
	 player.RemoveAllItems();

   
     EntityAI primary;
	 
        switch (Math.RandomInt(0, 8)) {
         case 0: primary = baikerClass(player); break;
         case 1: primary = akClass(player); break;
         case 2: primary = mosinaClass(player); break;
		 case 3: primary = svdClass(player); break;
		 case 4: primary = FirefightersClass(player); break;
		 case 5: primary = reporterClass(player); break;
		 case 6: primary = umpClass(player); break;
		 case 7: primary = copClass(player); break;
		 case 8: primary = copClass(player); break;
        }
	 player.LocalTakeEntityToHands(primary);		
	 player.SetQuickBarEntityShortcut(primary, 0, true);
	 player.GetInventory().CreateInInventory("HuntingKnife");
	 ItemBase rags = player.GetInventory().CreateInInventory("Rag");
	 rags.SetQuantity(2);	 

    }

 

if you do that, the character starts empty-handed

Share this post


Link to post
Share on other sites

Well, that's the right sequence at least.

How do your class functions look? For example, baikerClass? Is the primary weapon spawning in the inventory or not spawning at all?

  • Like 1

Share this post


Link to post
Share on other sites

 

the weapon appears in the hands  and in the fast slot

    void addMags(PlayerBase player, string mag_type, int count)
    {
          EntityAI mag;
        mag = player.GetInventory().CreateInInventory(mag_type);
        player.SetQuickBarEntityShortcut(mag, 1, true);
        EntityAI mag1;
        mag1 = player.GetInventory().CreateInInventory(mag_type);
        player.SetQuickBarEntityShortcut(mag1, 2, true);
        EntityAI mag2;
        mag2 = player.GetInventory().CreateInInventory(mag_type);
        player.SetQuickBarEntityShortcut(mag2, 3, true);
    }
    EntityAI baikerClass(PlayerBase player)
    {
     EntityAI gun = player.GetInventory().CreateInInventory("AKM");
     gun.GetInventory().CreateAttachment("AK_FoldingBttstck");
     gun.GetInventory().CreateAttachment("AK_RailHndgrd");
     gun.GetInventory().CreateAttachment("AK_Suppressor");
     gun.GetInventory().CreateAttachment("KobraOptic");
     EntityAI aspants = player.GetInventory().CreateInInventory("CargoPants_Black");
     EntityAI asjacket = player.GetInventory().CreateInInventory("RidersJacket_Black");
     EntityAI asboots = player.GetInventory().CreateInInventory("CombatBoots_Black");
     EntityAI helmet = player.GetInventory().CreateInInventory("MotoHelmet_Black");
     EntityAI asbag = player.GetInventory().CreateInInventory("CourierBag");
     addMags(player, "Mag_AKM_30Rnd", 3);

     return gun;
    }

Share this post


Link to post
Share on other sites
15 hours ago, mastaZz said:

 

the weapon appears in the hands  and in the fast slot

Does this mean that your problem is solved?

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, ColKernel said:

Означает ли это, что ваша проблема решена?

 

the weapon was sealed not in the hands but only in the fast slot

Share this post


Link to post
Share on other sites
On 10/20/2018 at 1:53 AM, mastaZz said:

the weapon was sealed not in the hands but only in the fast slot

I did some testing and I cannot get player.LocalTakeEntityToHands(primary) to work.

I found a workaround that seems to be working for me. In each of your player classes you need to replace the line where you create the gun

EntityAI gun = player.GetInventory().CreateInInventory("AKM");

with these lines instead

InventoryLocation handInventoryLocation = new InventoryLocation;
handInventoryLocation.SetHands(player, null);
EntityAI gun = player.GetInventory().SpawnItemOnLocation("AKM", handInventoryLocation, false);

In each player class you need to replace the "AKM" with the gun you want. This will create the gun directly in the player's hands.

Also you should probably delete the player.LocalTakeEntityToHands(primary) from the code.

Hope this helps!

  • Like 1

Share this post


Link to post
Share on other sites

 

 

5 hours ago, ColKernel said:

I did some testing and I cannot get player.LocalTakeEntityToHands(primary) to work.

I found a workaround that seems to be working for me. In each of your player classes you need to replace the line where you create the gun


EntityAI gun = player.GetInventory().CreateInInventory("AKM");

with these lines instead


InventoryLocation handInventoryLocation = new InventoryLocation;
handInventoryLocation.SetHands(player, null);
EntityAI gun = player.GetInventory().SpawnItemOnLocation("AKM", handInventoryLocation, false);

In each player class you need to replace the "AKM" with the gun you want. This will create the gun directly in the player's hands.

Also you should probably delete the player.LocalTakeEntityToHands(primary) from the code.

Hope this helps!

 

 

 

    void addMags(PlayerBase player, string mag_type, int count)
    {
  		EntityAI mag;
        mag = player.GetInventory().CreateInInventory(mag_type);
		player.SetQuickBarEntityShortcut(mag, 1, true);
		EntityAI mag1;
        mag1 = player.GetInventory().CreateInInventory(mag_type);
		player.SetQuickBarEntityShortcut(mag1, 2, true);
		EntityAI mag2;
        mag2 = player.GetInventory().CreateInInventory(mag_type);
		player.SetQuickBarEntityShortcut(mag2, 3, true);
    }
    EntityAI baikerClass(PlayerBase player)
    {
     InventoryLocation handInventoryLocation = new InventoryLocation;
     handInventoryLocation.SetHands(player, null);
     EntityAI gun = player.GetInventory().SpawnItemOnLocation("AKM", handInventoryLocation, false);
	 gun.GetInventory().CreateAttachment("AK_FoldingBttstck");
	 gun.GetInventory().CreateAttachment("AK_RailHndgrd");
	 gun.GetInventory().CreateAttachment("AK_Suppressor");
	 EntityAI aspants = player.GetInventory().CreateInInventory("CargoPants_Black");
	 EntityAI asjacket = player.GetInventory().CreateInInventory("RidersJacket_Black");
     EntityAI asboots = player.GetInventory().CreateInInventory("CombatBoots_Black");
	 EntityAI helmet = player.GetInventory().CreateInInventory("MotoHelmet_Black");
	 EntityAI asbag = player.GetInventory().CreateInInventory("CourierBag");
	 addMags(player, "Mag_AKM_30Rnd", 3);

     return gun;
    }



    EntityAI mosinaClass(PlayerBase player)
    {
     InventoryLocation handInventoryLocation = new InventoryLocation;
     handInventoryLocation.SetHands(player, null);
     EntityAI gun = player.GetInventory().SpawnItemOnLocation("svd", handInventoryLocation, false);	 
	 EntityAI asgpants = player.GetInventory().CreateInInventory("BDUPants");
	 EntityAI asjacket = player.GetInventory().CreateInInventory("Sweater_Green");
     EntityAI asgboots = player.GetInventory().CreateInInventory("CombatBoots_Black");
	 EntityAI helmet = player.GetInventory().CreateInInventory("Ssh68Helmet");
	 addMags(player, "Mag_SVD_10Rnd", 5);

     return gun;
    }


    EntityAI FirefightersClass(PlayerBase player)
    {
     InventoryLocation handInventoryLocation = new InventoryLocation;
     handInventoryLocation.SetHands(player, null);
     EntityAI gun = player.GetInventory().SpawnItemOnLocation("M4A1", handInventoryLocation, false);		
	 gun.GetInventory().CreateAttachment("M4_RISHndgrd_Black");
	 gun.GetInventory().CreateAttachment("M4_MPBttstck_Black");
	 gun.GetInventory().CreateAttachment("M4_Suppressor");
     EntityAI asboots = player.GetInventory().CreateInInventory("CombatBoots_Black");
     EntityAI asjacket = player.GetInventory().CreateInInventory("Hoodie_Grey");
	 EntityAI asmask = player.GetInventory().CreateInInventory("GasMask");
	 EntityAI asbag = player.GetInventory().CreateInInventory("CourierBag");
	 EntityAI aspants = player.GetInventory().CreateInInventory("FirefightersPants_Black");
	 EntityAI asvest = player.GetInventory().CreateInInventory("PoliceVest");	
	 addMags(player, "Mag_STANAG_30Rnd", 5);

     return gun;
    }


    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
	 player.RemoveAllItems();

   
     EntityAI primary;
	 
        switch (Math.RandomInt(0, 2)) {
         case 0: primary = baikerClass(player); break;

         case 1: primary = mosinaClass(player); break;

		 case 2: primary = FirefightersClass(player); break;

        }
		
	 player.SetQuickBarEntityShortcut(primary, 0, true);
	 player.GetInventory().CreateInInventory("HuntingKnife");
	 ItemBase rags = player.GetInventory().CreateInInventory("Rag");
	 rags.SetQuantity(2);	 

    }

};
  
  
  
Mission CreateCustomMission(string path)
{
	return new CustomMission();
}

 

weapon in hand but only 1 case falls out (((

Share this post


Link to post
Share on other sites

I'm sorry I checked on 2 cases. when I added 3 cases, they began to drop out 1-2 without 3. many thanks for helping !!!

Share this post


Link to post
Share on other sites
6 hours ago, ColKernel said:

Я провел некоторое тестирование, и я не могу получить player.LocalTakeEntityToHands (основной) для работы.

Я нашел обходное решение, которое, похоже, работает на меня. В каждом из ваших игровых классов вам нужно заменить линию, в которой вы создаете оружие


вместо этих строк


  
 

В каждом классе игроков вам нужно заменить «AKM» на пистолет, который вы хотите. Это создаст пистолет прямо в руках игрока.

Также вы должны, вероятно, удалить player.LocalTakeEntityToHands (первичный) из кода.

Надеюсь это поможет!

 

do you happen to know how to add magazin to gun in this form at the start ??? and how to add a sight with the battery inserted ??? thanks in advance
 

     InventoryLocation handInventoryLocation = new InventoryLocation;
     handInventoryLocation.SetHands(player, null);
     EntityAI gun = player.GetInventory().SpawnItemOnLocation("AKM", handInventoryLocation, false);
	 gun.GetInventory().CreateAttachment("Mag_AKM_30Rnd");
	 gun.GetInventory().CreateAttachment("AK_FoldingBttstck");
	 gun.GetInventory().CreateAttachment("AK_RailHndgrd");
	 gun.GetInventory().CreateAttachment("AK_Suppressor");
	 EntityAI aspants = player.GetInventory().CreateInInventory("CargoPants_Black");
	 EntityAI asjacket = player.GetInventory().CreateInInventory("RidersJacket_Black");
     EntityAI asboots = player.GetInventory().CreateInInventory("CombatBoots_Black");
	 EntityAI helmet = player.GetInventory().CreateInInventory("MotoHelmet_Black");
	 EntityAI asbag = player.GetInventory().CreateInInventory("CourierBag");
	 addMags(player, "Mag_AKM_30Rnd", 3);

 

this option does not work properly

Share this post


Link to post
Share on other sites

The Math.RandomInt(a, b) function returns a random integer between a and b, where b is exclusive. So Math.RandomInt(0, 2) returns 0 or 1. You have 3 cases in your example, so you want Math.RandomInt(0, 3), which will return 0, 1, or 2.

44 minutes ago, mastaZz said:

do you happen to know how to add magazin to gun in this form at the start ???

Unfortunately, I do not know how to do this properly yet.

45 minutes ago, mastaZz said:

and how to add a sight with the battery inserted ???

In the FirefightersClass case with the M4:

EntityAI sight = gun.GetInventory().CreateAttachment("M68Optic");
sight.GetInventory().CreateAttachment("Battery9V");

It works similarly for the PSO-1 scope.

  • Like 1

Share this post


Link to post
Share on other sites
52 minutes ago, ColKernel said:

The Math.RandomInt(a, b) function returns a random integer between a and b, where b is exclusive. So Math.RandomInt(0, 2) returns 0 or 1. You have 3 cases in your example, so you want Math.RandomInt(0, 3), which will return 0, 1, or 2.

Unfortunately, I do not know how to do this properly yet.

In the FirefightersClass case with the M4:


EntityAI sight = gun.GetInventory().CreateAttachment("M68Optic");
sight.GetInventory().CreateAttachment("Battery9V");

It works similarly for the PSO-1 scope.

 

cases earned correctly, it turned out I did not erase the server database. You do not know how to do what magazin was inserted into the gun at the start right away?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×