View Single Post
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 07-27-2010 , 13:26   Re: Dynamic number of arguments in functions
Reply With Quote #9

Quote:
Originally Posted by ehha View Post
How can i do this?
PHP Code:
public function_meansome_intsome_float, ... ) 
{
    
//bla

What index would the other parameters have?
PHP Code:
public function_meansome_intFloat:some_float, ... ) 
{
    
//some_int is considered parameter 0
    //some_float is considered parameter 1
    //therefore the next parameter would start at 2

It should also be noted that you can tag the dynamic arguments in order to prevent tag mismatch warnings.
PHP Code:
public function_meanFloat:... )
{
    
// You need to pass the first 2 arguments as float values or else this calculation
    // Will be messed up
    // Also the third parameter is a integer (normal value)
    
setarg(2floatround((Float:getarg(1)+Float:getarg(0)) / 2.0))

Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`