Skript

Forum > Scripts

SkriptApi 1.1 [Skript 2.1.2] - [Dev]

    #1 Dec 27, 2013 at 19:00 UTC - 2 likes

    SkriptApi 1.1 [Skript 2.1.2] - [Dev]

    Description

    This is my Skript Add-on like SkriptPlus. I created new events, effects and expressions you can use in any skript!.

    Place this in your scripts folder, run "/sk reload scripts" and you can use my events, effects and expressions.

    Features

    Events:

    • on fish catch

    Effects:

    • give <player> <item> in slot <number>
    • set name of item in slot <number> to <text>
    • remove all potions from <player>

    Expressions:

    • slot <number> of <player>

    Permissions

    Permission to use the commands

    • sk.skriptapi.admin

    How to use

    on fish catch

    Example:
    
    on pick up of fish or clownfish or salmon or pufferfish:
    	{catch.fish.%player%} is true
    	# your code here, example:
    	send "Great, you caught a fish!"
    

    give <player> <item> in slot <number>

    Example:
    
    on mine of dirt:
    	execute console command "/giveitem %player% 2 dirt in slot 9"
    

    set name of item in slot <number> to <text>

    Example:
    
    on drop:
    	execute console command "/setnameofiteminslot 9 of %player% to Don't drop me!"
    

    remove all potions from <player>

    Example:
    
    on join:
    	execute console command "/removeallpotionsfrom %player%"
    

    slot <number> of <player>

    Example:
    
    on pick up:
    	wait 2 ticks
    	execute console command "/slot 9 of %player%"
    	set {_slot.of.player} to {slot.of.player}
    	{_slot.of.player} is not air
    	send "You don't have place in slot 9"
    

    To-Do

    • Color support for renaming
    • Suggest something
    Last edited Aug 28, 2014 by GeekWithAChick
    Name Description Size MD5
    SkriptApi.sk &emdash; 4.9 KiB 8648a364120e...
    SkriptApi.sk Skript 2.1.2 4.8 KiB cc26e3f87b9d...

    SkriptApi - Gates - SilkTouchSpawners - DiscoDisco - PistonsPlus - SignEdit BFAK:90859160,7cd1071402494202a8252524cab9e168e0b0e8f13cdbd42eb5cf2e4d45d41016

    #2 Dec 27, 2013 at 21:21 UTC - 0 likes

    Does this only work with the console, or can you say use execute console command "/slot 9 of %player%" On walking on pressure plate: set slot 1 to red

    Or does it need to be Esecute console command...

    Anyway good job, may try it soon :P When you wanted to make that fish skript... i didnt think you would make a whole new api :P

    IT must of been hard learning java :P I tried to learn Java but skript had confused me a lot :P

    #3 Dec 27, 2013 at 21:34 UTC - 0 likes

    @beauhobba: Go

    It only works with the command but can be exected by players too if they have the permission

    #4 Dec 29, 2013 at 15:02 UTC - 0 likes

    @beauhobba: Go

    You can't set a slot, only check what item it is.

    But you can give the player an item in that slot :)

    #5 Dec 30, 2013 at 02:10 UTC - 0 likes

    Ahh another skript expansion if it can be called so....
    Well I wasn´t aware of these possibilities ... probably have to look at during daytime duh...

    Last edited Dec 30, 2013 by Cool3303
    Quote from andorra000: Go

    Do you think that your some sort of Aryan skripter above all else?

    Quote from Cool3303: Go

    Yeah off course! I am German!
    At the moment I am sitting at my computer with Lederhosen and a Fedora Hat enjoying some Sauerkraut and a Mass Bier.
    Oh and look at my Reputation 88=HH = Heil Hitler

    Guess I worked too hard on my reputation,its not easy to be german

    #6 Dec 30, 2013 at 10:40 UTC - 0 likes

    @Cool3303: Go

    You can see it as a library for script where you can use code with commands :)

    #7 Jan 03, 2014 at 07:14 UTC - 0 likes

    Maybe on fish of player :P would be cool

    #8 Jan 03, 2014 at 10:16 UTC - 0 likes

    That would be

    on damage:
    	damage was caused by projectile
    	projectile is fish
    	victim is player
    	send "You're fishing %victim%" to attacker
    
    #9 Jan 03, 2014 at 10:37 UTC - 0 likes

    @GeekWithAChick: Go

    Never knew fish were projectiles :P Thanks :D But anyway I like this plugin as it can implanment 1.7.4 features :P Hmm may make a funny skript where you switch places with the fishes :P

    #10 Jan 03, 2014 at 10:53 UTC - 0 likes

    @beauhobba: Go

    Sounds really cool ;p

    #11 Jan 04, 2014 at 03:45 UTC - 0 likes

    It's possible to add: "on first login"?

    because i have a Cracked Server, and i wan't that the Player get's a Teleporter on his first login, if i do "on frist join" the Inventory is not the same than after login."

    so:

    on first login: execute console command "/give %player% 399 1 name:&b&lTemeporter"

    #12 Jan 04, 2014 at 03:46 UTC - 0 likes

    @AVAPLAYS: Go

    Read the documentation. Yes its possible.

    #13 Jan 04, 2014 at 08:25 UTC - 0 likes

    @AVAPLAYS: Go

    http://njol.ch/projects/skript/doc/events/#first_join

    #14 Apr 10, 2014 at 12:06 UTC - 0 likes

    Ah I remember this, didn't you get the fish thing from my post? I was asking if there's a way to make it so you can catch fish? :P A long time ago? or not?

    #15 Apr 10, 2014 at 12:11 UTC - 1 like

    @Gen0ezTeam: Go

    Yes indeed :D

    #16 Apr 15, 2014 at 07:37 UTC - 0 likes

    I did something similiar like your "on fish catch" because I needed some statistics and Skript doesn't yet support the native statistics of Minecraft.

    If you wish to improve your code and make it more robust in case of cheating or other strange behaviour (in case, for example, if someone is spamming fishing rod and another player is dropping fishes) you can adopt my code. I modified it a bit for you so it would be more useful and added comments to explain what's going on. Also your code doesn't take into account fishes that are caught but not picked up or not picked up in time (5 ticks).

    Here:

    on fishing:
    
    # Lets wait for a while for item spawn event and see if a fish appears
    # We grab the location of the fisher and store it
      set {fishing.event.toggle::%player%} to location of player          
    
    # This can probably be less if needed. Even 1 ticks could work, but I haven't tested it
    # increase the delay to account for server load etc. Smaller delay = more accurate results.
      wait for 3 ticks                                                                        
      delete {fishing.event.toggle::%player%}
    
    # Let's make sure there is no cheating/fooling the code by spamming the fishing rod
    # and dropping fishes
    
    on drop of fish:
      if {fishing.event.toggle::*} is set:       
    
        if {fishing.event.toggle::%player%} is set:
          delete {fishing.event.toggle::%player%}
          exit trigger
    
    # If someone drops a fish near you when you toggle the fishing rod, we don't
    #  want to do anything or there will be false positives, so let's check for it:
        loop {fishing.event.toggle::*}:
    
    # I did NOT measure the length of the fishing line, this is an estimate that needs verifying
          if distance between loop-value and event-location is less than 50:
            delete {fishing.event.toggle::%loop-index%}
    
    # Fish spawned but was it from fishing?
    on item spawning of raw fish or raw salmon or pufferfish or clownfish:
      if {fishing.event.toggle::*} is set:
        loop {fishing.event.toggle::*}:
          if distance between location of loop-value and event-location is less than 50:
    
    # It has now been confirmed that fish has been caught from fishing (with some certainty)
    # Let's fire up the "on fish event"
            execute console command "/on_fish_event %loop-index%"
    
    # on fish event
    # If you need other information like location of fisher or location of spawned fish
    # you need to modify the code for a bit and use variables to store the locations
    # I didn't include them here since I don't need them myself but since this is an API
    # You probably should provide them. Also fish type would be nice.
    
    command /on_fish_event <player>:
      executable by: console
      trigger:
        set {_fisher} to arg 1
    
    # Put all your code HERE that you wish to do with this event!
    
    # Statistics for example:
    
        if {statistics.caught.fish::%{_fisher}%} is set:
          increase {statistics.caught.fish::%{_fisher}%} by 1
        if {statistics.caught.fish::%{_fisher}%} is not set:
          set {statistics.caught.fish::%{_fisher}%} to 1
    
    
    
    # Finally let's clean temporary variables in case there was a crash etc
    on Skript start:
      if {fishing.event.toggle::*} is set:
        delete {fishing.event.toggle::*}
    
    Last edited Apr 15, 2014 by pilvimaa
    #17 Apr 15, 2014 at 07:44 UTC - 0 likes

    The thought crossed my mind just now:

    The code I posted doesn't take into account some of the more esoteric stuff like one player spamming a fishing rod and another player breaking chests full of fishes at the same time to cheat the statistics.

    But that also could easily be accounted for. And probably should. Just add on break of chest or trapped chest event and like above check existence of fishing event toggle and compare with distance. Delete the variable if distance between the two is less than the length of fishing line.

    EDIT: Also check for all other containers + add checks for dispensers firing.

    Last edited Apr 15, 2014 by pilvimaa
    #18 Apr 15, 2014 at 11:56 UTC - 0 likes

    @pilvimaa: Go

    Thanks but I don't think people will know about this "cheat" :)

    #19 Aug 28, 2014 at 16:44 UTC - 0 likes

    Uploaded a new version working for Skript 2.1.2

    #20 Aug 30, 2014 at 12:19 UTC - 0 likes

    This is helpful (the give player item in slot), through how would I give the player a named item in the slot?

    "/giveitem %player% 1 chest named ""&fBackpack"" in slot 8" doesnt work." (console command)

    I wish I could change my BukkitDev name, if you know, please PM Me!
    My server is gone. The website is still here until Janurary! http://jackzcraft.com
    If you want to be nice and donate and help make Jackz Craft 2.0 (hopefully more skript-based, then plugin-based :D)

You must login to post a comment. Don't have an account? Register to get one!