Jump to content
nanakiwurtz

F_RandMes suggestion

Recommended Posts

I think it could be simplified like this:

function    script    F_RandMes    {

    set [email protected], getargcount();

    return getarg(rand(1,[email protected]));

}

What do you think? /ok
Link to comment
Share on other sites

It should be : 

function    script    F_RandMes    {
    set [email protected], getargcount();
    return getarg(rand(0,[email protected]));
}

since the first argument will be remove ( number of arguments ) 

callfunc("F_RandMes",1129,1222,1163,1357,1360,1522,1811,1410);
Link to comment
Share on other sites

Is there any specific reason a variable is initialized for only one use?

Wouldn't 

function script F_RandMes {
    return getarg(rand(0, (getargcount() - 1)));
}

 

be better?

Link to comment
Share on other sites

Why not, your way is easier to use.

Also F_RandMes is only used in F_Hi and F_Bye functions in a clean version, it's not a lot of work (lol) to change them

//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Hi"
//////////////////////////////////////////////////////////////////////////////////
//returns random HELLO message

function	script	F_Hi	{
	return callfunc("F_RandMes",5,"Hi!","Hello!","Good day!","How are you?","Hello there.");
}


//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Bye"
//////////////////////////////////////////////////////////////////////////////////
//returns random BYE message

function	script	F_Bye	{
	return callfunc("F_RandMes",6,"Bye. See you again.","Later.","Goodbye.","Good luck!","Have a nice day!","Byebye!!!");
}
Link to comment
Share on other sites

I think it could be simplified like this:

function    script    F_RandMes    {
    set [email protected], getargcount();
    return getarg(rand(1,[email protected]));
}
What do you think? /ok

 

Nanakiwurtz, I think this is very cool... You're awesome to request this :)

  • Upvote 1
Link to comment
Share on other sites



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.