#1

Hi everyone, sorry for post i just forgot...
How to add optional stock function? :

stock Function(playerid,optionalvar1,optionalbool1 ... )
Reply
#2

pawn Код:
stock HelloMoto(playerid,&Var,&Bool:Var1)
{
    return 1;
}
Reply
#3

You simply add a default value to the parameters you want to be optional, like so:

pawn Код:
stock Function(playerid,optional = 1, optionalstring[] = "default")
Reply
#4

JaToch. sory but yours is not that what i wanted..

i want to create stock function with optional vars/strings or smth that wont give warnings about tag mismatch.. so i could use : function(playerid) instead of function(playerid,var1,var2)

edit:
bwah soz for dp something messed up ;S Delete thank you post or give me a warning
Reply
#5

What I pasted is working fine for me, I tested it.

pawn Код:
stock Message(string[],optionalstring[] = "")
{
    print(string);
    if(!strlen(optionalstring)) print("No value entered for optional string");
    else print(optionalstring);
    return 1;
}
Using

pawn Код:
Message("Hello");
I get no errors or warnings and the same if I use

pawn Код:
Message("Hello","Sir");
There's an optional parameter..?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)