Public Start Unused Items - 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: Public Start Unused Items (
/showthread.php?tid=130054)
Public Start Unused Items -
Norn - 25.02.2010
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.
Re: Public Start Unused Items -
Correlli - 25.02.2010
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.
Re: Public Start Unused Items -
Norn - 25.02.2010
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!