How do I create a stock with optional parameters?
#1

I have this stock:

Код:
stock SS(playerid, color, eng[], ro[])
{
	if(playerVariables[playerid][pLang] == 0) //Ro
	{
		SCM(playerid, color, ro);
	}
	else if(playerVariables[playerid][pLang] == 1) //En
	{
		SCM(playerid, color, eng);
	}
	return 1;
}
If pLang == 0, it send the message ro[], else it sends the message eng[].
How can I make it so when you use: SS(playerid, COLOR_WHITE, "Test message");
it would send a normal message to the user, instead of checking if the variable is 0 or 1?
Reply
#2

You should use y_text or something similar if you want to make a multi-lang system.
But to answer your question, you can try doing this:

Код:
stock SS(playerid, color, eng[], ro[] = "")
{
	if (ro[0] == 0)
		return SCM(playerid, color, eng);
	switch(playerVariables[playerid][pLang])
	{
		case 0: SCM(playerid, color, ro);
		case 1: SCM(playerid, color, eng);
	}
	return 1;
}
Reply
#3

pawn Код:
stock SS(playerid, color, eng[], ro[] = "")
{
    if (ro[0] == EOS)
        return SCM(playerid, color, eng);
    switch(playerVariables[playerid][pLang])
    {
        case 0: SCM(playerid, color, ro);
        case 1: SCM(playerid, color, eng);
    }
    return 1;
}
Function, not stock.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)