Discord Thread Fully Working Gun System :)

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

This thread came from the skUnity Discord. You can't reply to it here but if you join the skUnity Discord, you'll be able to post a reply there. The thread link is part of the thread's message.
Status
Not open for further replies.

skUnity Discord

Site Manager
Aug 5, 2023
12,749
1
0
The skUnity Discord
discord.gg
Hello, i am willing to create a fully working gun system for my server, but since i dont have much experience with skript its gonna be hard for me. Thats why im here, i need help with the following stuff (Ammo System, Bullets dont work if they hit wall and gravity for bullets). Also, here is my code:


on right click:
if player's held item is white dye named "&2&lPISTOL":
if {pistol.%uuid of player%} is less than 1:
play sound "block.fire.ambient" to player
loop 200 times:
set {_loc} to location (loop-value / 5) meters in front of and 1.3 meters above the player
draw 1 of dustcolortransition using dustTransition(gray, yellow, 2) at {_loc}
set {_range} to 50
if distance between location of player and targeted entity of player < {_range}:
loop all entities in radius 1 around targeted entity:
loop-entity isn't a dropped item or projectile or the player
set loop-entity on fire for 3 seconds
damage loop-entity by 2
send action bar "&cYou just hit %loop-entity% with your ability!" to player
set {pistol.%uuid of player%} to 10
loop 10 times:
wait 1 second
remove 1 from {pistol.%uuid of player%}
else:
send "{@prefix} &aYou still need to wait &c%{pistol.%uuid of player%}%"
play sound "block.note_block.bass" to player


on join:
if {pistol.%uuid of player%} is not set:
set {pistol.%uuid of player%} to 0

on join:
set {pistol.%uuid of player%} to 0

Posted by: CompX from the skUnity Discord. View the thread on skUnity Discord here
 
Tips for the future may helps you:
-
code_language.skript:
loop 200 times is very bad because it's can create lag to your server 
- change the variables name from {pistol.%uuid of player%} to {pistol::%uuid of player%}
- why you are setting the variables 2 times in the end of your code?
code_language.skript:
applescript
#YOU DON'T NEED TO HAVE THIS PART!
on join:
    if {pistol.%uuid of player%} is not set:
        set {pistol.%uuid of player%} to 0

on join:
    set {pistol.%uuid of player%} to 0

Posted by: eult from the skUnity Discord.
 
ok I just stol tud function you can use it
code_language.skript:
applescript
function drawLine(loc1: location, loc2: location, d: number) :: locations:
    set {_vector} to vector from {_loc1} to {_loc2}
    loop round(distance between {_loc1} and {_loc2}*{_d}) times:
        set vector length of {_vector} to loop-value/{_d}
        add {_loc1} ~ {_vector} to {_locs::*}
    return {_locs::*}

here is how you can use it
applescript
set {_targetBloc} to target block's location
draw 1 of dust using dustOption(white, 1) at drawLine(player's eyes, {_targetBloc}, 2) with extra 0

Posted by: eult from the skUnity Discord.
 
Status
Not open for further replies.