SA-MP Forums Archive
stock - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: stock (/showthread.php?tid=198162)



stock - GaGlets(R) - 11.12.2010

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

stock Function(playerid,optionalvar1,optionalbool1 ... )


Re: stock - The_Gangstas - 11.12.2010

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



Re: stock - JaTochNietDan - 11.12.2010

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

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



Re: stock - GaGlets(R) - 11.12.2010

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


Re: stock - JaTochNietDan - 11.12.2010

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..?