Home
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Details for command function:
* function <function name>;
* <function name>;
* function <function name> { <code> }
This works like callfunc. It's used for cleaner
and fast script. Also they must be inside a script.
They're not separated scripts and they work more like labels.
Note it looks like the normal declaration
Usage:
You first Declare the function with function <function name>;.
Put the rest of your code. You can use then <function name>; to call the function.
And at least, but inside the script itself, put the function <function name> {<code>}.
Example:
prontera,154,189,4 script Item seller 767,{
function SF_Selling;
mes "I'll open this now if you have more than 50z and you are level 50 or bigger";
next;
if (Zeny > 50) && (BaseLevel > 50) {
mes "Welcome";
next;
SF_Selling;
close;
} else
set @needed,50-BaseLevel;
mes "You either are Level "+BaseLevel+", thus you need "+@needed+" more levels";
mes "to be able to use this npc; or you don't have enough zeny, so get some please";
close;
function SF_Selling {
mes "Would you like to buy a phracon for 50z?";
switch(select("Yes","No, thanks")) {
case 1:
mes "Ok, how many?";
input @quantity;
set @check,Zeny/50;
if (@quantity > @check) {
mes "Sorry but you can only have "+@check+" Phracons with "+Zeny;
close;
} else
next;
mes "here you have";
set Zeny,Zeny-@quantity*50;
getitem 1010,@quantity;
close;
case 2:
mes "Good bye then";
close;
}
}
return;
}
}