-
Makes a function public. A public function can be called from other scripts.
-
-
== Declaration ==
<code cpp>
VAULTSCRIPT void (*MakePublic)(vaultmp::Function, std::string, std::string);
-
+
[h="2"] Declaration [/h]
[highlight=cpp]
VAULTSCRIPT VAULTSPACE Void (*VAULTAPI(MakePublic))(VAULTSPACE RawFunction(), VAULTSPACE cRawString, VAULTSPACE cRawString) _CPP(noexcept);
[/highlight]
[highlight=c]
-
native MakePublic(const func{}, const name{}, const def{});
-
-
</code>
== Parameters ==
'''[[Function|vaultmp::Function]]''' (C++ only) - the function
'''func''' (PAWN only) - the name of the function
'''name''' - the public name of the function (must be unique)
'''def''' - the parameter list of the function. This is a string containing a sequence of:
*i - Integer (4 byte)
*l - Long integer (8 byte)
*f - Floating-point (8 byte)
*s - String (const char*)
== Return value ==
-
+
[/highlight]
[h="2"] Parameters [/h]
[b][wiki="Function"]Function[/wiki][/b] - the function
[b][wiki]cRawString[/wiki][/b] - the public name of the function (must be unique)
[b][wiki]cRawString[/wiki][/b] - the parameter list of the function. This is a string containing a sequence of:
[list][*]i - Integer (4 byte)
[*]l - Long integer (8 byte)
[*]f - Floating-point (8 byte)
[*]p - Pointer (4 byte)
[*]s - String (const char*)
[/LIST]
[h="2"] Return value [/h]
-
None.
-
-
== Usage example (C++) ==
<code cpp>
vaultmp::Result VAULTSCRIPT MyPublic(unsigned int a, unsigned int b, const char* c)
-
+
[h="2"] Usage example (C++) [/h]
[highlight=cpp]
Result VAULTSCRIPT MyPublic(unsigned int a, unsigned int b, const char* c)
-
{
// Public function
-
-
return (a + b);
-
+
return static_cast<Result>(a + b);
-
}
-
-
void VAULTSCRIPT exec()
-
+
Void VAULTSCRIPT exec() noexcept
-
{
-
-
MakePublic(reinterpret_cast<Function>(&MyPublic), "MagicFunction", "iis");
// The following call will likely be made from some other script
vaultmp::Result result = CallPublic("MagicFunction", 1, 2, "www.vaultmp.com");
-
+
// C++ template version (type-safe, deduces type string)
MakePublic(MyPublic, "MagicFunction");
-
}
-
-
</code>
== Usage example (PAWN) ==
<code c>
-
+
[/highlight]
[h="2"] Usage example (PAWN) [/h]
[highlight=c]
-
forward MyPublic(a, b, const c{});
-
-
-
public MyPublic(a, b, const c{})
{
// Public function
return (a + b);
}
-
-
-
main()
{
MakePublic("MyPublic", "MagicFunction", "iis");
-
-
// The following call will likely be made from some other script
new result = CallPublic("MagicFunction", 1, 2, "www.vaultmp.com");
-
}
-
-
</code>
== Related pages ==
*[[CallPublic]]
[[Category:VaultMP interface]]
[[Category:Scripting functions]]
[[Category:Misc functions]]
-
+
[/highlight]
[h="2"] Related pages [/h]
[list][*][wiki]CallPublic[/wiki]
[/LIST]
[category]VaultMP interface[/category]
[category]Scripting functions[/category]
[category]Misc functions[/category]