Optional string.
#1

Hi,

I got this function
pawn Code:
stock PInfoStr(p, varname[], str[])
I want it act like this:

pawn Code:
stock PInfoStr(p, varname[], str[])
{
    if(str[] is specified, ex:'PInfoStr(playerid, "bob", "ohshi")' )
    {
        SetPVarString(p, varname, str);
        return 1;
    }
    else if(str[] not specified, ex:'PInfoStr(playerid, "bob")' )
    {
        new tempstr[128];
        GetPVarString(p, varname, tempstr, sizeof(tempstr));
        return tempstr;
    }
}
So, is it possible to specify an optional string in the function? Like with integers or floats:
pawn Code:
SomeFunc(playerid, iwontusethis=1)
Reply
#2

pawn Code:
SomeFunc(playerid, str[]="Hello World")
Reply
#3

Quote:
Originally Posted by Jefff
View Post
pawn Code:
SomeFunc(playerid, str[]="Hello World")
Yeah, tried this (again) an hour ago on a clean GM, it worked. Last times it gave me some strange errors about 'non-constant variables'...

Thanks anyway!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)