Vastpark Server tutorials

Added by Tiffan Teofano 11 months ago

Hi!
is it possible for you guys to prepare tutorials on how to configure, and how to code to control say multiple game players, or multiple avatars whe sharing a park?

for instance, I create my park as a home family, where I want kids to be restricted from entering into parents room.intead of doing all this on the client side, I wanna do it on the server side which I think it will help writing fewer lines of code than on the clients side.

For my case I want to control playing turn for the two players in the game I am creating.

cheers!


Replies (2)

RE: Vastpark Server tutorials - Added by Craig Presti 11 months ago

Did you want to do this purely using script (Lua)?

Have a read of the how to send network messages page, this shows some C# code (for plugins) showing how to structure messages and send/receive.

Scripting is similar except you listen to the NetworkCustomMessage trigger, ie:

<IMML Author="craigomatic" Camera="Camera" xmlns="http://schemas.vastpark.com/2007/imml/">
  <Camera Name="Camera" Position="0,0,-5" />

  <Trigger Event="NetworkCustomMessage" Target="OnMessageReceived" />

  <Script Name="OnMessageReceived">
    function main(obj, args)

      --args.data contains the networkmessage object
      m = args.data

      --use m.id to work out which message it is
      m:readint()      
      m:readstring(3)

      --etc

    end
  </Script>

  <Script Name="SendMessage">
    function main(obj, args)
      nm = networkmessage()
      nm.id = 10001 --can be any integer
      nm:writeint(3)
      nm:writestring('abc')

      --broadcast sends to everyone
      --scene.network:broadcast(nm)

      --send to a specific client 
      --scene.network:send(nm, clientId)

      --send a message directly to the host (server imml)
      scene.network:send(nm)
    end
  </Script>
</IMML>

The VastScript API PDF has some info worth reading also.

Let us know if you need more info :)

RE: Vastpark Server tutorials - Added by Tiffan Teofano 11 months ago

thanks Craig, I will go through this and get back to you for more help

Regards

(1-2/2)