PDA

View Full Version : How to make an array argument in stock optional...


pasha97
08/02/2013, 05:58 AM
I'm not sure how to express what I want correctly, but I hope you'll understand me. In one of stock functions in my gm, there is an argument... Not an integer argument, but array. This array must include titles for textdraw menu, like:
new vnames[][] =
{
"Planes",
"Helicopters",
"Bikes",
"Cars",
"Boats",
"Specials",
"RC vehicles"
};

So, when I use this stock function, i must add:

ShowTextDrawMenu(playerid, menuid, "Vehicles spawn",vnames,0x990000AA);


As you can see, vnames is that veriable with array with titles.

But if I don't want to add any title, it gives me an error, that number of arguments does not much the defenition. So, I want to ask you, if there is any way to make this function argument optional? Thanks in advance.

pasha97
08/02/2013, 07:04 AM
Anybody answer please.

Scenario
08/02/2013, 07:07 AM
I believe this will work for you: make vnames the last piece of the syntax and replace "vnames" with this:

vnames = "NULL"

RajatPawar
08/02/2013, 07:08 AM
To make something optional, I would do, this is not the best method, this is a guess:
SomeFunction(some integer = 0);
This would set the value already to 0, and wouldn't give anything even if you type:
SomeFunction(); //I guess?

pasha97
08/02/2013, 07:22 AM
To make something optional, I would do, this is not the best method, this is a guess:
SomeFunction(some integer = 0);
This would set the value already to 0, and wouldn't give anything even if you type:
SomeFunction(); //I guess?

What you say is only for integer variables, but my one is an array with some number of strings(see the first post)

Scenario
08/02/2013, 07:24 AM
*cough* (http://forum.sa-mp.com/showpost.php?p=2371947&postcount=3)

pasha97
08/02/2013, 07:25 AM
*cough* (http://forum.sa-mp.com/showpost.php?p=2371947&postcount=3)

doesn't work. I get this:

G:\Ultra Fun Freeplay\pawno\include\TDMEN.inc(315) : error 001: expected token: "{", but found "-string-"
G:\Ultra Fun Freeplay\gamemodes\UFFtest.pwn(9670) : error 047: array sizes do not match, or destination array is too small

if i make this:

titles_array[][]= {"NULL"}

then there is only the second error

RajatPawar
08/02/2013, 07:28 AM
Err...something like, I am not sure, but:
vnames = ""

pasha97
08/02/2013, 08:42 AM
Err...something like, I am not sure, but:
vnames = ""

:cry: