This site has been archived and made available for preservation purposes. No edits can be made.

MakePublic

(Difference between revisions)
Return to current revision
  1.  
    Makes a function public. A public function can be called from other scripts.
    [h="2"] Declaration [/h]
  2. -
    <code cpp>
  3. +
    [highlight=cpp]
  4.  
    VAULTSCRIPT void (*MakePublic)(vaultmp::Function, std::string, std::string);
    native MakePublic(const func{}, const name{}, const def{});
  5. -
    </code>
  6. +
    [/highlight]
  7.  
    [h="2"] Parameters [/h]
    [b][wiki="Function"]vaultmp::Function[/wiki][/b] (C++ only) - the function
    [b]func[/b] (PAWN only) - the name of the function
    [b]name[/b] - the public name of the function (must be unique)
    [b]def[/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)
  8. +
    [*]p - Pointer (4 byte)
  9.  
    [*]s - String (const char*)
    [/LIST]
    [h="2"] Return value [/h]
    None.
    [h="2"] Usage example (C++) [/h]
  10. -
    <code cpp>
  11. +
    [highlight=cpp]
  12.  
    vaultmp::Result VAULTSCRIPT MyPublic(unsigned int a, unsigned int b, const char* c)
    {
    // Public function
    return (a + b);
    }
    void VAULTSCRIPT exec()
    {
    MakePublic(reinterpret_cast<Function>(&MyPublic), "MagicFunction", "iis");
    }
  13. -
    </code>
  14. +
    [/highlight]
  15.  
    [h="2"] Usage example (PAWN) [/h]
  16. -
    <code c>
  17. +
    [highlight=c]
  18.  
    forward MyPublic(a, b, const c{});
    public MyPublic(a, b, const c{})
    {
    // Public function
    return (a + b);
    }
    main()
    {
    MakePublic("MyPublic", "MagicFunction", "iis");
    }
  19. -
    </code>
  20. +
    [/highlight]
  21.  
    [h="2"] Related pages [/h]
    [list][*][wiki]CallPublic[/wiki]
    [/LIST]
    [category]VaultMP interface[/category]
    [category]Scripting functions[/category]
    [category]Misc functions[/category]