Sign in to follow this  
Vladislav Gnatovskyi

/weapon unit id

Recommended Posts

Здравствуйте! Представляю для вас пример исполнения команды /weapon unit id где:

unit - это блок оружия а имеено:

  • Handguns
  • Machine
  • Assault
  • Sniper
  • ShotGun
  • Heavy
  • Thorow

id это само оружие в блоке

Для начала работи - нам нужно в паке "events" создать файл "weapon.js"

Затем объявляем в нём глобальную переменную:

global.weapon = 
{
  
};

 После объявляєм сам unit (блок), в котором будет находиться определеный тип оружия. Вставляем между фигурных скобок: 

Handguns: mp.joaat(["weapon_pistol"])

Полный код файла "weapon.js":

global.weapon=
{
Handguns: mp.joaat(["weapon_pistol",
	"weapon_CombatPistol",
	"weapon_Pistol50",
	"weapon_SNSPistol",
	"weapon_HeavyPistol",
	"weapon_VintagePistol",
	"weapon_MarksmanPistol",
	"weapon_revolver",
	"weapon_APPistol",
	"weapon_StunGun",
	"weapon_FlareGun"]),
Machine: mp.joaat(["weapon_MachinePistol",
	"weapon_SMG",
	"weapon_AssaultSMG",
	"weapon_CombatPDW",
	"weapon_MG",
	"weapon_CombatMG",
	"weapon_Gusenberg",
	"weapon_MiniSMG"]),
Assault: mp.joaat(["weapon_assaultrifle",
	"weapon_carbinerifle",
	"weapon_advancedrifle",
	"weapon_specialcarbine",
	"weapon_bullpuprifle",
	"weapon_compactrifle"]),
Sniper: mp.joaat(["weapon_SniperRifle",
	"weapon_heavySniper",
	"weapon_MarksmanRifle"]),
ShotGun: mp.joaat(["weapon_pumpShotgun",
	"weapon_SawnoffShotgun",
	"weapon_bullpupshotgun",
	"weapon_assaultshotgun",
	"weapon_musket",
	"weapon_HeavyShotgun",
	"weapon_AutoShotgun"]),
Heavy: mp.joaat(["weapon_grenadelauncher",
	"weapon_RPG",
	"weapon_Minigun",
	"weapon_Firework",
	"weapon_Railgun",
	"weapon_HomingLauncher"]),
Thorow: mp.joaat(["weapon_Grenade",
	"weapon_StickyBomb",
	"weapon_Proximitymine",
	"weapon_BZGas",
	"weapon_Molotov",
	"weapon_Flare",
	"weapon_PetrolCan",
	"weapon_FireExtinguisher"])
};

Теперь нам нужно создать саму команду, которая будет вызывать наш блок, тип оружия.

После сохранения файла, открываем файл который находиться в паке "commands" - "basiccommands.js"

В нем нужно найти команду /weapon и заменить её кодом ниже:

"weapon": (player, args) =>
	{
		let id = parseInt(args[1]);
		switch (id){
		case 0:{if (args[2]>=0 && args[2]<=10){player.giveWeapon(weapon.Handguns[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit Handguns");}else player.outputChatBox("Use /weapon 0 [0-10]");break;}
		case 1:{if (args[2]>=0 && args[2]<=7){player.giveWeapon(weapon.Machine[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit Machine");}else player.outputChatBox("Use /weapon 1 [0-7]");break;}
		case 2:{if (args[2]>=0 && args[2]<=5){player.giveWeapon(weapon.Assault[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit Assault");}else player.outputChatBox("Use /weapon 2 [0-5]");break;}
		case 3:{if (args[2]>=0 && args[2]<=2){player.giveWeapon(weapon.Sniper[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit Sniper");}else player.outputChatBox("Use /weapon 3 [0-2]");break;}
		case 4:{if (args[2]>=0 && args[2]<=6){player.giveWeapon(weapon.ShotGun[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit ShotGun");}else player.outputChatBox("Use /weapon 4 [0-6]");break;}
		case 5:{if (args[2]>=0 && args[2]<=5){player.giveWeapon(weapon.Heavy[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit Heavy");} else player.outputChatBox("Use /weapon 5 [0-5]");break;}
		case 6:{if (args[2]>=0 && args[2]<=7){player.giveWeapon(weapon.Thorow[args[2]],1000);
		player.outputChatBox("Weapon: "+args[2]+" of unit Thorow");} else player.outputChatBox("Use /weapon 6 [0-7]");break;}
		default:
		player.outputChatBox("Use /weapon 0-6 [id]");
		break;
		}
	},

Сам файл: weapon.js

Скачать: https://drive.google.com/open?id=0B__EFpIDYcQ6ZEc0akc1S0JFcEE

Если возникнут проблемы обращайтесь! 

Edited by Vladislav Gnatovskyi

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.