guns.sk

Created by Zeldaboy111

Other available versions. Ordered by newest to oldest versions:

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.

#©
#- Reselling/Reuploading while claiming that it is yours or made by you is disallowed
#- Do not edit it and upload it as your own
#- While using it in a video, please feature everything under "Video"
#©
#
#Video:
#Skript made by Zeldaboy111
#More content of the creator: https://forums.skunity.com/search/26443679/

options:
	logo: &6Guns &8:&7
	cLogo: &f[&6Guns&f] &8:&7

on enable:
	set {guns.list::*} to "pistol", "desert_eagle", "rifle" and "machine_gun"
	set {guns.info.names::*} to "&7Pistol", "&7Desert Eagle", "&9Rifle" and "&6Machine Gun"
	set {guns.specs.shooting.shotCooldown::*} to "10", "9", "2" and "0.1"
	set {guns.specs.shooting.strength::*} to "2", "3", "3" and "1"
	set {guns.specs.shooting.range::*} to "16", "19", "22" and "27"
	set {guns.specs.reload.speed::*} to "5", "10", "2" and "2"
	set {guns.specs.reload.amount::*} to "7", "5", "31" and "40"

#========================================
#           F U N C T I O N S
#========================================
function getGun(p: Player, gun: String):
	loop {guns.list::*}:
		if loop-value is {_gun} in lower case:
			set {_value} to loop-index
			stop loop

	if {_value} is set:
		give {_p} iron horse armor named "%{guns.info.names::%{_value}%}%" with lore "" and "&7Ammo: %{guns.specs.reload.amount::%{_value}%}% / %{guns.specs.reload.amount::%{_value}%}%" without any NBT
		send "{@logo} &e%{_gun}% &7given!" to {_p}

	else:
		send "{@logo} The gun &e%{_gun}% &7doesn't exist." to {_p}

function selectGun(p: Player):
	delete {heldGun.%{_p}%}
	delete {heldGun.%{_p}%.index}
	set {_name} to name of {_p}'s held item
	
	loop {guns.info.names::*}:
		if loop-value is {_name}:
			set {heldGun.%{_p}%} to {guns.list::%loop-index%}
			set {heldGun.%{_p}%.index} to loop-index
			stop loop


function gunInfo(p: Player, gun: String):
	send "{@logo} &c&lWIP &8(&7Work In Progress&8)" to {_p}
	
#========================================
#            C O M M A N D S
#========================================
command /guns [<text>] [<text>]:
	aliases: /gun
	trigger:
		executor is player:
			if player has permission "guns":
				if arg-1 is "help":
					send "&7&m                 &7{ &6Guns &7}&m                  "
					send "<cmd:/guns list><ttp:&8Get a list of all the guns>&e/guns list"
					send "<sgt:/guns get <gun>><ttp:&8Get a gun>&e/guns get <gun>"
					send "<sgt:/guns info [gun]><ttp:&8Get the information [about a gun]>&e/guns info [gun]"
					send "&7Tip&8: &7Try hovering over and clicking on the messages!"
					send "&7&m                 &7{ &6Guns &7}&m                  "

				else if arg-1 is "list":
					send "{@logo} &7Here is a list from all the guns&8:%nl%&epistol&8, &edesert_eagle&8, &erifle&8, &emachine_gun"

				else if arg-1 is "get":
					if arg-2 is set:
						getGun(player, arg-2)

					else:
						send "{@logo} &7You need to give up a &egun&7."

				else if arg-1 is "info":
					if arg-2 is set:
						gunInfo(player, arg-2)

					else:
						send "{@logo} &7You need to give up a &egun&7."

				else:
					send "{@logo} &7Do &e/guns help &7for more info!"

		else:
			send "{@cLogo} &7This command can only be executed by a player!"

on right click with iron horse armor:
	if {reloading.%player%} is true:
		send "{@logo} You can't shoot whilst reloading!"
		stop

	if {heldGun.%player%} or {heldGun.%player%.index} is not set:
		set {_new} to true

	else if {heldGun.%player%} is not name of player's held item:
		set {_new} to true

	if {_new}:
		selectGun(player)

	if {heldGun.%player%} and {heldGun.%player%.index} is set:
		if {lastShoot.%player%} is set:
			if difference between {lastShoot.%player%} and now <= "%{guns.specs.shooting.shotCooldown::%{heldGun.%player%.index}%}% ticks" parsed as a timespan:
				stop


		set {lastShoot.%player%} to now
		set {_lore::*} to lore of player's held item
		set {_ammo} to {_lore::2}
		
		replace all "&7Ammo: " in {_ammo} with ""
		replace all " / %{guns.specs.reload.amount::%{heldGun.%player%.index}%}%" in {_ammo} with ""
		set {_ammo} to {_ammo} parsed as a number
		
		if {_ammo} < 1:
			send "{@logo} You have to reload!"

		else:
			set {_newLore::*} to {_lore::*}
			set {_newLore::2} to "&7Ammo: %{_ammo} - 1% / %{guns.specs.reload.amount::%{heldGun.%player%.index}%}%"

			set lore of player's held item to {_newLore::*}
			play raw sound "BLOCK_LEVER_CLICK" at player with pitch 7 volume 10

			loop {guns.specs.shooting.range::%{heldGun.%player%.index}%} parsed as a number times:
				set {_loc} to location 1 meters above and loop-value-0.5 meters in front of player
				show 10 "Smoke Normal" particles at {_loc} for player offset by 0.2, 0.2, 0.2
				loop all entities in radius 1 meters around {_loc}:
					if loop-entity is not player:
						damage loop-entity by ({guns.specs.shooting.strength::%{heldGun.%player%.index}%} parsed as a number)
				
on left click with iron horse armor:
	wait 1 tick
	if {heldGun.%player%} or {heldGun.%player%.index} is not set:
		set {_new} to true

	else if {heldGun.%player%} is not name of player's held item:
		set {_new} to true

	if {_new}:
		selectGun(player)

	if {heldGun.%player%} and {heldGun.%player%.index} is set:
		set {_lore::*} to lore of player's held item
		set {_ammo} to {_lore::2}

		if {reloading.%player%} is true:
			send "{@logo} You already are reloading!"
			stop

		if {_lore::2} is not "&7Ammo: %{guns.specs.reload.amount.%{heldGun.%player%.index}%}% / %{guns.specs.reload.amount::%{heldGun.%player%.index}%}%":
			replace all "&7Ammo: " in {_ammo} with ""
			replace all " / %{guns.specs.reload.amount::%{heldGun.%player%.index}%}%" in {_ammo} with ""

			set {_ammo} to {_ammo} parsed as a number
			set {_reload.current} to 0

			send "{@logo} Reloading..."
			set {reloading.%player%} to true
			set {heldSlot.%player%} to current hotbar slot of player

			while {_lore::2} is not "&7Ammo: %{guns.specs.reload.amount::%{heldGun.%player%.index}%}% / %{guns.specs.reload.amount::%{heldGun.%player%.index}%}%":
				if {reloading.%player%} is not true:
					stop loop
				
				if "%{_reload.current}%" = "%{guns.specs.reload.speed::%{heldGun.%player%.index}%}%":
					play raw sound "UI_BUTTON_CLICK" at player with pitch 3 volume 10
					set {_reload.current} to 0
					add 1 to {_ammo}
					set {_lore::2} to "&7Ammo: %{_ammo}% / %{guns.specs.reload.amount::%{heldGun.%player%.index}%}%"
					set lore of player's held item to {_lore::*}

				else:
					add 1 to {_reload.current}

				wait 1 tick
				
			delete {reloading.%player%}
			send "{@logo} Reloaded!"
			play raw sound "ENTITY_ITEM_PICKUP" at player with pitch 3 volume 10

		else:
			send "{@logo} You do not have to reload!"

every 1 tick:
	loop all players:
		if {reloading.%loop-player%} is true:
			if current hotbar slot of loop-player is not {heldSlot.%loop-player%}:
				set current hotbar slot of loop-player to {heldSlot.%loop-player%}

on inventory click:
	if {reloading.%player%} is true:
		cancel event


on quit:
	delete {reloading.%player%}

on join:
	if {reloading.%player%} is set:
		delete {reloading.%player%}