Custom Score Counting Method * Example *

Custom Score Counting Method * Example *

Postby dzienny » 28 Jan 2012, 21:18

Here's a simple code that overrides the default score counting method.
* UPDATED! change was need in order to make the code compatible with the version 7.4.2+ *

Code: Select all
using System;

namespace MCDzienny
{
   public class CmdCustomScoreCounting : Command
   {
      // Don't change it.
      public override string name { get { return ""; } }
      public override string shortcut { get { return ""; } }
      public override string type { get { return ""; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }

      // Init is executed when the code is loaded.
      public override void Init()
      {
         // You tell the server to send arguments to CustomScoreCounting method when CountScore event occures.
         LavaSystem.CountScore -= LavaSystem.CountScoreDefault;
         LavaSystem.CountScore += CustomScoreCounting;
      }

      // Here's the place where you are supposed to write your score counting method.
      // Player p - represents a player that was among the winners,
      // int blocksAround - describes how many blocks were around the player at the end of the round,
      // mind that blocks that were located below the sea level are counted as 0,3 of a normal block.
      // The counted score has to be written to 'p.score' as in example below.
      
      private void CustomScoreCounting(Player p, int blocksAround)
      {
         p.score = 150 + blocksAround + p.lives * 20;
      }

      // Don't change it.
      public override void Help(Player p) { }
      public override void Use(Player p, string message) { }
   }
}
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: Custom Score Counting Method * Example *

Postby Ultima » 29 Jan 2012, 15:13

NICE :mrgreen:
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: Custom Score Counting Method * Example *

Postby Ultima » 03 Feb 2012, 11:38

Is it possible to override money with this to?
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: Custom Score Counting Method * Example *

Postby dzienny » 04 Feb 2012, 12:55

Ultima wrote:Is it possible to override money with this to?

Nope, I would have to change a code a bit and add another event to make it possible.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: Custom Score Counting Method * Example *

Postby Ultima » 05 Feb 2012, 13:16

Code: Select all
----5-2-2012 13:14:57 ----
Type: MissingMethodException
Source: CmdCustomScoreCounting
Message: Methode niet gevonden: Void MCDzienny.LavaSystem.CountPlayerScore(MCDzienny.Player, Int32).
Target: Init
Trace:    bij MCDzienny.CmdCustomScoreCounting.Init()
   bij MCDzienny.Scripting.Load(String command)

-------------------------

Edit:
Never mind, had to recompile it :|
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: Custom Score Counting Method * Example *

Postby dzienny » 05 Feb 2012, 15:45

Ultima wrote:
Code: Select all
----5-2-2012 13:14:57 ----
Type: MissingMethodException
Source: CmdCustomScoreCounting
Message: Methode niet gevonden: Void MCDzienny.LavaSystem.CountPlayerScore(MCDzienny.Player, Int32).
Target: Init
Trace:    bij MCDzienny.CmdCustomScoreCounting.Init()
   bij MCDzienny.Scripting.Load(String command)

-------------------------

Edit:
Never mind, had to recompile it :|


There was a change in source code - The LavaSystem.CountPlayerScore was renamed to LavaSystem.CountScoreDefault . The code in this post is up to date and should work.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27


Return to Knowledge Base

Who is online

Users browsing this forum: No registered users and 2 guests

cron