SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 20/08/2010, 05:32 PM   #1
CaHbKo
Huge Clucker
 
Join Date: Nov 2007
Posts: 459
Reputation: 41
Default Optional string.

Hi,

I got this function
Code:
stock PInfoStr(p, varname[], str[])

I want it act like this:

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:
Code:
SomeFunc(playerid, iwontusethis=1)
CaHbKo is offline  
Old 20/08/2010, 07:01 PM   #2
Jefff
High-roller
 
Join Date: Dec 2007
Posts: 2,042
Reputation: 185
Default Re: Optional string.

Code:
SomeFunc(playerid, str[]="Hello World")
Jefff is offline  
Old 20/08/2010, 07:43 PM   #3
CaHbKo
Huge Clucker
 
Join Date: Nov 2007
Posts: 459
Reputation: 41
Default Re: Optional string.

Quote:
Originally Posted by Jefff View Post
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!
CaHbKo is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Easy Registration - 20/12/2010 Grim_ Filterscripts 148 27/01/2011 09:06 PM
Optional parameters? Gozerr Help Archive 1 27/02/2010 03:21 PM
Sm like an optional Parameter Rauminator Help Archive 2 06/02/2010 06:40 PM
Optional Parameters Dreftas Help Archive 1 11/10/2009 11:34 AM
using sscanf for optional integer inputs at the end of a command ( possible?) iLinx Help Archive 1 31/07/2009 08:00 PM


All times are GMT. The time now is 01:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.