Random Command

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

Bendik0208

Member
Jul 26, 2017
16
0
0
So I make a random command on join, but it get a error all the time..
Can someone help me out?

code_language.skript:
on join:
  chance of 10%:
  make player execute command "/suicide"
  chance of 90%:
  make player execute command "/tp"
 
So I make a random command on join, but it get a error all the time..
Can someone help me out?

code_language.skript:
on join:
  chance of 10%:
  make player execute command "/suicide"
  chance of 90%:
  make player execute command "/tp"
First, when you use the expression "chance of" it's actually rolling both of your chances. So you could end up with the joining player executing both commands or no commands at all. If that's your goal, then you're fine. If not you can fix that like this:
code_language.skript:
on join:
    set {_random} to a random integer between 1 and 2:
        if {_random} is 1:
            make player execute command "/suicide"
        if {_random} is 2:
            make player execute command "/tp"
Second, unless you have a custom command, /tp needs an argument to teleport someone somewhere. /tp PlayerName or /tp Player1 Player2 for instance.
If those aren't the issue, what error exactly to you get?
 
  • Like
Reactions: Bendik0208
First, when you use the expression "chance of" it's actually rolling both of your chances. So you could end up with the joining player executing both commands or no commands at all. If that's your goal, then you're fine. If not you can fix that like this:
code_language.skript:
on join:
    set {_random} to a random integer between 1 and 2:
        if {_random} is 1:
            make player execute command "/suicide"
        if {_random} is 2:
            make player execute command "/tp"
Second, unless you have a custom command, /tp needs an argument to teleport someone somewhere. /tp PlayerName or /tp Player1 Player2 for instance.
If those aren't the issue, what error exactly to you get?

Not I got this error..
https://gyazo.com/14c0565220f92b583179e845dba285ae

and yes, I know that /tp needs an argument
 
are you using benksu's skript fork? if not, i think thats the problem
 
Not I got this error..
https://gyazo.com/14c0565220f92b583179e845dba285ae

and yes, I know that /tp needs an argument
Ah that's probably because of my spacing and the misplaced colon.
try this instead:
code_language.skript:
on join:
    set {_random} to a random integer between 1 and 2
    if {_random} is 1:
        make player execute command "/suicide"
    if {_random} is 2:
        make player execute command "/tp"
[doublepost=1501112815,1501112612][/doublepost]
are you using benksu's skript fork? if not, i think thats the problem
I didnt think the random integer, chance or make player execute expressions were specific to Bensku. While I do have Bensku and they load fine for me, all of them are just plain Skript
 
Ah that's probably because of my spacing and the misplaced colon.
try this instead:
code_language.skript:
on join:
    set {_random} to a random integer between 1 and 2
    if {_random} is 1:
        make player execute command "/suicide"
    if {_random} is 2:
        make player execute command "/tp"
[doublepost=1501112815,1501112612][/doublepost]
I didnt think the random integer, chance or make player execute expressions were specific to Bensku. While I do have Bensku and they load fine for me, all of them are just plain Skript
oh ya good point but the reason why i think not having bensku's fork is the issue is because his original code shouldnt be giving an error even though its probably not what he wanted as you explained

unless he didnt mean a reload error in which case youre absolutely right
 
First, when you use the expression "chance of" it's actually rolling both of your chances. So you could end up with the joining player executing both commands or no commands at all. If that's your goal, then you're fine. If not you can fix that like this:
code_language.skript:
on join:
    set {_random} to a random integer between 1 and 2:
        if {_random} is 1:
            make player execute command "/suicide"
        if {_random} is 2:
            make player execute command "/tp"
Second, unless you have a custom command, /tp needs an argument to teleport someone somewhere. /tp PlayerName or /tp Player1 Player2 for instance.
If those aren't the issue, what error exactly to you get?
Or just use chance like he wanted
code_language.skript:
if chance of 10:

else if chance of 90:
 
Or just use chance like he wanted
code_language.skript:
if chance of 10:

else if chance of 90:
The else if doesn't matter it works for me the way he originally had it as well. My only thought is he had some other issue or was hitting the chances on not getting any command. He never posted the original error, just my code's initial one.
 
Status
Not open for further replies.