Kill achievement

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

    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.

Dan_k

Member
Apr 25, 2019
28
0
0
19
I tried to create that if you will kill 5 zombies it will teleport you to another world.
Code:
variables:
    {kill counter.%player%.kills_total} = 0
  
on death of a zombie:
    attacker is a player
    add 1 to {kill counter.%attacker%.kills_total}
every 1 second:
    loop all players:
        if {kill counter.%attacker%.kills_total} equals to 5
        make console execute "mw move %player% rpg"
what is wrong with the code?
 
I tried to create that if you will kill 5 zombies it will teleport you to another world.
Code:
variables:
    {kill counter.%player%.kills_total} = 0
 
on death of a zombie:
    attacker is a player
    add 1 to {kill counter.%attacker%.kills_total}
every 1 second:
    loop all players:
        if {kill counter.%attacker%.kills_total} equals to 5
        make console execute "mw move %player% rpg"
what is wrong with the code?
You're using attacker and player in a every 1 second event, both don't exist there.
The correct condition is %object% is equal to %object%. You can also use `%object% is %object%`
(The indentation on line 10 is wrong and you're missing a `:` after line 9) or (you added an `if` where you didn't need it)
 
You're using attacker and player in a every 1 second event, both don't exist there.
The correct condition is %object% is equal to %object%. You can also use `%object% is %object%`
(The indentation on line 10 is wrong and you're missing a `:` after line 9) or (you added an `if` where you didn't need it)
can you send me the fixed code pls? Cuz I am not at home right now to fix the code.
 
can you send me the fixed code pls? Cuz I am not at home right now to fix the code.
Why are you asking for the code? You won't learn by us just writing the code for you. I will give you the wrong things and also I will explain it, hope you will understand...
So. First of all, in line 10, you don't need to write ,,if'', you can just use it as a condition. Also, 'equals to 5' didn't work for me, changed it to 'is 5'
Also line 10: there is no %attacker% in a every second event. You're looping all players, that's good, so put loop-player (because when you're looping stuff (e.g values in a list-variable) you always put loop- before it. E.g loop {something::*}: if loop-value is ....) instead of attacker.
And line 11 I just changed make console execute to execute console command

You can now change the things in your code.

Also... I just don't want you to use this long code when you can do it easier. There you go, learn from this:
(So if all you want is that a player kills 5 zombie then console executes MW move player rpg then use this)
Code:
on death of zombie:
    attacker is a player #tests if it was killed by a player
    if {kills.%attacker%} is set: #if the variable exists (so the player may already killed some zombies)
        add 1 to {kills.%attacker%} #adds one to the kill numbers
        {kills.%attacker%} is 5 #This is a condition. You don't need to write if. If it's true (so the variable is 5) it will continue doing the things. If not, then it stops executing the command. This tests if the variable's value is 5 (so if the player killed 5 zombies)
        execute console command "mw move %attacker% rpg" #console executes the command
        delete {kills.%attacker%} #Delete the variable for some reasons:p
    else: #Variable is not set, 0 zombie killed:
        set {kills.%attacker%} to 1 #already one, gg...
 
Why are you asking for the code? You won't learn by us just writing the code for you. I will give you the wrong things and also I will explain it, hope you will understand...
So. First of all, in line 10, you don't need to write ,,if'', you can just use it as a condition. Also, 'equals to 5' didn't work for me, changed it to 'is 5'
Also line 10: there is no %attacker% in a every second event. You're looping all players, that's good, so put loop-player (because when you're looping stuff (e.g values in a list-variable) you always put loop- before it. E.g loop {something::*}: if loop-value is ....) instead of attacker.
And line 11 I just changed make console execute to execute console command

You can now change the things in your code.

Also... I just don't want you to use this long code when you can do it easier. There you go, learn from this:
(So if all you want is that a player kills 5 zombie then console executes MW move player rpg then use this)
Code:
on death of zombie:
    attacker is a player #tests if it was killed by a player
    if {kills.%attacker%} is set: #if the variable exists (so the player may already killed some zombies)
        add 1 to {kills.%attacker%} #adds one to the kill numbers
        {kills.%attacker%} is 5 #This is a condition. You don't need to write if. If it's true (so the variable is 5) it will continue doing the things. If not, then it stops executing the command. This tests if the variable's value is 5 (so if the player killed 5 zombies)
        execute console command "mw move %attacker% rpg" #console executes the command
        delete {kills.%attacker%} #Delete the variable for some reasons:p
    else: #Variable is not set, 0 zombie killed:
        set {kills.%attacker%} to 1 #already one, gg...
okey,Thank you very much.
[doublepost=1559848640,1559848219][/doublepost]
Why are you asking for the code? You won't learn by us just writing the code for you. I will give you the wrong things and also I will explain it, hope you will understand...
So. First of all, in line 10, you don't need to write ,,if'', you can just use it as a condition. Also, 'equals to 5' didn't work for me, changed it to 'is 5'
Also line 10: there is no %attacker% in a every second event. You're looping all players, that's good, so put loop-player (because when you're looping stuff (e.g values in a list-variable) you always put loop- before it. E.g loop {something::*}: if loop-value is ....) instead of attacker.
And line 11 I just changed make console execute to execute console command

You can now change the things in your code.

Also... I just don't want you to use this long code when you can do it easier. There you go, learn from this:
(So if all you want is that a player kills 5 zombie then console executes MW move player rpg then use this)
Code:
on death of zombie:
    attacker is a player #tests if it was killed by a player
    if {kills.%attacker%} is set: #if the variable exists (so the player may already killed some zombies)
        add 1 to {kills.%attacker%} #adds one to the kill numbers
        {kills.%attacker%} is 5 #This is a condition. You don't need to write if. If it's true (so the variable is 5) it will continue doing the things. If not, then it stops executing the command. This tests if the variable's value is 5 (so if the player killed 5 zombies)
        execute console command "mw move %attacker% rpg" #console executes the command
        delete {kills.%attacker%} #Delete the variable for some reasons:p
    else: #Variable is not set, 0 zombie killed:
        set {kills.%attacker%} to 1 #already one, gg...
Yeah,And I wanted to ask, I am new to skript soo I want to learn, where I should start to learn? I watched couple of videos in youtube and learn some really basic things in skript like making gui and other stuff but this is too easy, maybe you know where should I learn more about skript?
 
okey,Thank you very much.
[doublepost=1559848640,1559848219][/doublepost]
Yeah,And I wanted to ask, I am new to skript soo I want to learn, where I should start to learn? I watched couple of videos in youtube and learn some really basic things in skript like making gui and other stuff but this is too easy, maybe you know where should I learn more?
Well, for small things, you can try searching them on google, OR in the docs: https://skripthub.net/docs/ (I think everything can be found there about Skript, every expressions, events, also same with addons..)
For example, you don't know how to change the tab name of a player. How to search it in the docs: Just write ,,tab name'' How to search it in google: ,,minecraft skript tab name'' (Well I can't found any real answer for it on google (didn't search for too much time, I have to go) that's why you should use a docs)
-And I will edit this message tomorrow, link you some more things-
 
Well, for small things, you can try searching them on google, OR in the docs: https://skripthub.net/docs/ (I think everything can be found there about Skript, every expressions, events, also same with addons..)
For example, you don't know how to change the tab name of a player. How to search it in the docs: Just write ,,tab name'' How to search it in google: ,,minecraft skript tab name'' (Well I can't found any real answer for it on google (didn't search for too much time, I have to go) that's why you should use a docs)
-And I will edit this message tomorrow, link you some more things-
Thank you!!
[doublepost=1560508018,1559880878][/doublepost]
Well, for small things, you can try searching them on google, OR in the docs: https://skripthub.net/docs/ (I think everything can be found there about Skript, every expressions, events, also same with addons..)
For example, you don't know how to change the tab name of a player. How to search it in the docs: Just write ,,tab name'' How to search it in google: ,,minecraft skript tab name'' (Well I can't found any real answer for it on google (didn't search for too much time, I have to go) that's why you should use a docs)
-And I will edit this message tomorrow, link you some more things-
Didn't edit the message XD
 
Status
Not open for further replies.