Need some help!

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

CorpralBlack

New Member
Apr 23, 2020
7
0
1
Hey, I've been trying to make custom spawning in Skript. I don't have any addons for Skript itself.
I am new to Skript, so all help trying to make this work is very appreciated! Here is my code:

mobs: skeleton, creeper, zombie, baby zombie, villager zombie, enderman, endermite, phantom, and ender dragon
on first join:
clear inventory of the player
on respawn:
apply resistance 10 to the player
apply weakness 10 to the player
x:
y:
z:
if player's x coordinate is between 2 and -2:
set {@x} to true
else:
set {@x} to false
if player's z coordinate is between 2 and -2
set {@z} to true
else:
set {@z} to false
if player's y coordinate is between 10 and 13
set {@y} to true
else:
set {@y} to false
if {@x}, {@z}, and {@y} are true:
on damage of {@mobs}:
end event

Again, any help is very appreciated. If you have questions about my code, please do ask!
 
Please format the code and tell us what you need help with.
Since I made this post, I've learned a bit more about Skript and its formatting, didn't know that then tho lol. Let me reformat this.

Code:
Options:
        mobs: skeleton, creeper, zombie, baby zombie, villager zombie, enderman, endermite, phantom, and ender dragon
        x:
        y:
        z:



on first join:
        clear inventory of the player

if player's x coordinate is between 2 and -2:
        set {@x} to true
else:
        set {@x} to false


if player's z coordinate is between 2 and -2
        set {@z} to true
else:
        set {@z} to false


if player's y coordinate is between 10 and 13
        set {@y} to true
else:
        set {@y} to false


if {@x}, {@z}, and {@y} are true:
        on damage of {@mobs}:
        cancel event

I'm not 100% sure if this code would work, I haven't tested it, but essentially what I was trying to do, was when the player was in a 5x5 spawn area and a mob tried to attack them, the event would be cancelled. I was trying to put the coordinates blank so that I could make them booleans. I went a bit further as to clear the inventory of the player so that the player would immediately lose the received kit from essentials on their first login. I didn't want to have this set to all players as a collective, though. I wanted this to work for each individual player, which didn't work when I redid the code. Hopefully this makes a bit more sense now.
 
Last edited:
upload_2020-4-25_14-30-39.png

please insert code in codeblocks
 
Uhhm, why check if the player is within a certain distance of the mob? Why not just cancel the event anyways?
I think, checking for a players distance to a mob, overcomplicates a really simple skript way to much.

This is all the code you would need to cancel damage of mobs to players
Code:
on damage of entities:
    cancel event

@CorpralBlack
 
Uhhm, why check if the player is within a certain distance of the mob? Why not just cancel the event anyways?
I think, checking for a players distance to a mob, overcomplicates a really simple skript way to much.

This is all the code you would need to cancel damage of mobs to players
Code:
on damage of entities:
    cancel event

@CorpralBlack

Well, what I'm trying to do isn't checking the players distance to a mob, but more check if a player is in the spawn area, a 5 by 5 square with a middle point of 0, 0. If they are inside of that area, and a mob attacks them, the attack will be cancelled. Not sure how to do that though...
 
Well, what I'm trying to do isn't checking the players distance to a mob, but more check if a player is in the spawn area, a 5 by 5 square with a middle point of 0, 0. If they are inside of that area, and a mob attacks them, the attack will be cancelled. Not sure how to do that though...
But why would you do that? What is the reason you just isn’t cancelling the event?
 
But why would you do that? What is the reason you just isn’t cancelling the event?
I've tried that, but simply cancelling the event ANY time a player gets damaged seems to disable pvp around the entire map and for all damage events. I don't want this to happen, but have it happen only in the spawn region. Again, the spawn region is a small 5x5 area centered on 0, 0. I want to disable mob and player attacks within this region.
 
I've tried that, but simply cancelling the event ANY time a player gets damaged seems to disable pvp around the entire map and for all damage events. I don't want this to happen, but have it happen only in the spawn region. Again, the spawn region is a small 5x5 area centered on 0, 0. I want to disable mob and player attacks within this region.

This is all the code you need.
It only cancels whenever a player is attacked by a entity
Code:
on damage of player:
    if attacker is a entity:
        cancel event
 
try "If attacker is a mob:"

Yeah actually, i realised that entities would include a lot more than just mobs.
But this isn't a thing, according to the skunity parser
upload_2020-4-27_11-24-2.png


So I guess, that you @CorpralBlack will need to do something like this

Code:
options:
    mobs: creeper, zombie and spider #just add all of the mobs here, that should do no damage
    
on damage of player:
    if attacker is a {@mobs}:
        cancel event
 
Status
Not open for further replies.