Public Start Unused Items
#1

For example, i may have this:

pawn Код:
public PublicFunction(string[], integer)
But what i want is this:

pawn Код:
public PublicFunction(string[], integer, string1[], integer1)
But if string1 and integer1 is not used then it will still work without warning,

PublicFunction("test", 1);

But then if in another part of the script this is used
PublicFunction("test", 1, "test2", 2);

It will work without warning also, i've seen how to do this in the past but i can't remember how to do it.
Reply
#2

pawn Код:
stock myFunction(string[], integer, string1[]="", integer1=0)
{
  printf("%s, %i, %s, %i", string, integer, string1, integer1);
  return true;
}

/* usage (example) */
myFunction("text", 64); // string1 is empty and integer1 is 0.
If you change myFunction to public one then it will output an error (error 059: function argument may not have a default value (variable "string1")) because somehow you can't use this with strings if the function is public, but you can for integer type.
Reply
#3

Quote:
Originally Posted by Don Correlli
pawn Код:
stock myFunction(string[], integer, string1[]="", integer1=0)
{
  printf("%s, %i, %s, %i", string, integer, string1, integer1);
  return true;
}

/* usage (example) */
myFunction("text", 64); // string1 is empty and integer1 is 0.
If you change myFunction to public one then it will output an error (error 059: function argument may not have a default value (variable "string1")) because somehow you can't use this with strings if the function is public, but you can for integer type.
Thanks, i had tried that earlier but the error popped up so i thought there must be another way around it.

Changed to stock and it works great, cheers!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)