How to make an array argument in stock optional...
#1

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:
pawn Код:
new vnames[][] =
{
"Planes",
"Helicopters",
"Bikes",
"Cars",
"Boats",
"Specials",
"RC vehicles"
};
So, when I use this stock function, i must add:
pawn Код:
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.
Reply
#2

Anybody answer please.
Reply
#3

I believe this will work for you: make vnames the last piece of the syntax and replace "vnames" with this:

pawn Код:
vnames = "NULL"
Reply
#4

To make something optional, I would do, this is not the best method, this is a guess:
pawn Код:
SomeFunction(some integer = 0);
This would set the value already to 0, and wouldn't give anything even if you type:
pawn Код:
SomeFunction();  //I guess?
Reply
#5

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
To make something optional, I would do, this is not the best method, this is a guess:
pawn Код:
SomeFunction(some integer = 0);
This would set the value already to 0, and wouldn't give anything even if you type:
pawn Код:
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)
Reply
#6

*cough*
Reply
#7

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
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
Reply
#8

Err...something like, I am not sure, but:
pawn Код:
vnames = ""
Reply
#9

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Err...something like, I am not sure, but:
pawn Код:
vnames = ""
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)