I remember a while ago I was told that something such as the following would possess the same qualities as overloading functions (and I'm pretty sure it was from Stefan). However, now that I've found a place where I want to use it, I find that params aren't even loading into the function.
PHP Code:
function myFunction() {
switch (params.size()) {
case 1:
case 2:
case 3:
default:
}
}
Here is the script that I am working with.
PHP Code:
function dropitem() {
player.chat = params.size();
switch (params.size()) {
case 1:
temp.dropitem = params[0];
break;
case 2:
temp.tpercents = params[1];
for (i=0;i<temp.tpercents.size();i++)
tpercents[i] += tpercents[i-1];
temp.choice = random(0,100);
for (i=0;i<temp.tpercents.size();i++) {
if (temp.choice <= temp.tpercents[i]) {
temp.dropitem = params[0][i];
break;
}
}
break;
}
if (temp.dropitem) {
putnpc2(x-1,y-1,"join dropitem_"@temp.dropitem@";");
}
}
I would have revived the thread that this was said in, but I can't find it. Unfortunately, I guess I'll have to go about other methods. If I'm just screwing things up, please help me. If not, move this to the future improvements forum or something.