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

Results 1 to 5 of 5

Thread: New C++ script interface

  1. #1
    Administrator
    Join Date
    Jun 2011
    Location
    Germany
    Posts
    1,057
    Blog Entries
    5

    New C++ script interface

    The next snapshot will come with the revised scripting interface. You can now write scripts in C, C++ and PAWN. C++ scripts are fully binary compatible, so you should be able to use any C++11 compiler to write scripts for vaultmp.

    The C++ part now includes game object class wrappers to enable scripting in an object-oriented manner (with little to no overhead, though). For example, the rewritten example OnSpawn:

    Code cpp:
    Void VAULTSCRIPT OnSpawn(ID object) noexcept
    {
    	Player player(object);
     
    	if (player)
    	{
    		player.UIMessage("Hello, " + player.GetName() + "!");
     
    		Base pipboy = static_cast<Base>(0x00015038);
     
    		if (player.GetContainerItemCount(pipboy) == 0)
    		{
    			player.AddItem(pipboy);
    			player.EquipItem(pipboy);
    		}
    	}
    }

    In addition to that, C++ functions are now much more typesafe. Consider CreateTimer (CreateTimerEx, now overloaded):

    Code cpp:
    Result example(const char* var1, UCount var2, ID var3) noexcept
    {
    	return static_cast<Result>(0);
    }
     
    Void VAULTSCRIPT exec() noexcept
    {
    	CreateTimer<const char*, UCount, ID>(example, static_cast<Interval>(500), "Example text", 123, static_cast<ID>(123123123123));
    }

    Template metaprogramming auto-generates the type specifier string for you. No chance to make an error anymore.
    Last edited by foxtacles; 05-20-2012 at 05:43 PM.

  2. #2
    Is the next snapshot come with database ?
    https://www.vaultmp.com/image.php?type=sigpic&userid=527&dateline=13353568  95

  3. #3
    Awesome, I'm going to try to train my C++ skills by making scripts in it .
    I'm getting a little tired of PAWN's syntax therefore it is necessary.

    Quote Originally Posted by Oufz0r View Post
    Is the next snapshot come with database ?

    I'm sure someone is going to create a simple file system with PAWN or C++.

    I'm curious as to whether we can use includes such as Vectors, and Strings in the STD.
    Last edited by Aeronix; 05-21-2012 at 11:42 AM.


    I just come here to view whether there has been any progress or not, and review the wonderful progress that Recycler and the development team has made.
    My sincere thanks goes to them and to others who value my contributions the community, not to mention the ones that solely contribute.

  4. #4
    Administrator
    Join Date
    Jun 2011
    Location
    Germany
    Posts
    1,057
    Blog Entries
    5
    Quote Originally Posted by Aleksander View Post
    I'm curious as to whether we can use includes such as Vectors, and Strings in the STD.
    You can use everything from the C++11 standard library, basically every C++ extension / code you want. The only restriction is that you must not throw exceptions in your code (at least, you must not allow exceptions to leave the scope of your script)

  5. #5
    Neat. Looking forward to trying this out properly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •