Jump to content

Function based skripting


TKChino

Recommended Posts

Iv used it once, i saw a method of using it i incorporated it and it worked with making enchants.

My proglem is i dont thinki learnt anything from it to be honest.

function newCost(i: integer, l: integer) :: number:
    # i = cost for first level, l = current level
    return {_i} * ({_l}^2 / 2 + 1)

function getLevelNeed(level: number, pres: number) :: number:
    return (5*{_pres})+10

function checkLevel(p: player):
    if {level::%{_p}%} >= getLevelNeed({level::%{_p}%}, {prestige::%{_p}%}):
        remove getLevelNeed({level::%{_p}%}, {prestige::%{_p}%}) from {level::%{_p}%}
        prestige({_p})

function sendMessage(p: player, mode: text, message: text, message2: text):
    if {_mode} is "Title":
        send title {_message} with subtitle {_message2} to {_p}
    else if {_mode} is "Actionbar":
        send action bar "%{_message}% &8| %{_message2}%" to {_p}
    else if {_mode} is "Chat":
        send "%{_message}% &8| %{_message2}%" to {_p}

function prestige(p: player):
    add 1 to {prestige::%{_p}%}
    sendMessage({_p}, {toggle::%{_p}%::msgs}, "PRESTIGE","%{prestige::%{_p}%}-1% &7&l▶ %{prestige::%{_p}%}%")

This is the function i feel would be able to be used, but i dont know how to stick it into an actual command. So right now im using 

command /levelup:
	trigger:
		set {lvlprice::%player's uuid%} to {@levelUp}
		set {_needed} to {lvl::%player's uuid%} * {lvlprice::%player's uuid%}
		if balance of player >= {_needed}:
			if  {lvl::%player's uuid%} < 100:
				add 1 to {lvl::%player's uuid%}
				remove {_needed} from balance of player
				send player title "&c&lLEVEL UP!" with subtitle "&l+1 Level" for 2 seconds
			else:
				send "Your 100" to player
		else:
			if balance of player <= {_needed}:
				send "&a&lYou need &6&lⓉ%{_needed}% &a&lto level up!" to player

The basic side of command to trigger works, but i want to use the functions instead, any help and guideance would be be greatful useful 😄

Link to comment
Share on other sites

Oh, duh, yeah forgot people need know what i actually want lol.

Its a leveling / prestige skript kinda, not really as you can see.

Ill check that function tut you sent though tomoz and see if i understand a little more

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...