SA-MP Forums Archive
Optional string. - 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: Optional string. (/showthread.php?tid=169718)



Optional string. - CaHbKo - 20.08.2010

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)



Re: Optional string. - Jefff - 20.08.2010

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



Re: Optional string. - CaHbKo - 20.08.2010

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!